This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH] libjava: java.net.URI.relativize method results inconsistent with other Java VMs
- From: Luciano Chavez <lnx1138 at us dot ibm dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, GNU Classpath Patches <classpath-patches at gnu dot org>
- Date: Mon, 21 Jan 2008 15:04:24 -0600
- Subject: Re: [PATCH] libjava: java.net.URI.relativize method results inconsistent with other Java VMs
- References: <1199846929.20059.54.camel@localhost> <m3prvvx9ei.fsf@fleche.redhat.com>
On Mon, 2008-01-21 at 12:31 -0700, Tom Tromey wrote:
> >>>>> "Luciano" == Luciano Chavez <lnx1138@us.ibm.com> writes:
>
> Luciano> This patch corrects two issues found in URI.relativize()
> Luciano> method in libjava/classpath/java/net/URI.java. It applies
> Luciano> from gcc 4.1.2 through latest trunk:
>
> Thanks. I am checking in a slightly different patch, appended.
> There's no need to use 'new String(rawPath)', because Strings are
> immutable.
>
> I'm also checking it in to Classpath.
>
> Just FYI... it is easier for us if you write a ChangeLog entry and
> submit it with your patch.
>
> Tom
>
Thanks Tom! I will remember about Changelog as well.
> ChangeLog:
> 2008-01-21 Luciano Chavez <lnx1138@us.ibm.com>
>
> PR libgcj/34369:
> * java/net/URI.java (relativize): Check initial segment for
> trailing "/".
>
> Index: java/net/URI.java
> ===================================================================
> --- java/net/URI.java (revision 131699)
> +++ java/net/URI.java (working copy)
> @@ -1,5 +1,5 @@
> /* URI.java -- An URI class
> - Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
> + Copyright (C) 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
>
> This file is part of GNU Classpath.
>
> @@ -968,12 +968,18 @@
> return uri;
> if (rawAuthority != null && !(rawAuthority.equals(uri.getRawAuthority())))
> return uri;
> - if (!(uri.getRawPath().startsWith(rawPath)))
> - return uri;
> + String basePath = rawPath;
> + if (!(uri.getRawPath().equals(rawPath)))
> + {
> + if (!(basePath.endsWith("/")))
> + basePath = basePath.concat("/");
> + if (!(uri.getRawPath().startsWith(basePath)))
> + return uri;
> + }
> try
> {
> return new URI(null, null,
> - uri.getRawPath().substring(rawPath.length()),
> + uri.getRawPath().substring(basePath.length()),
> uri.getRawQuery(), uri.getRawFragment());
> }
> catch (URISyntaxException e)
--
Luciano Chavez <lnx1138@us.ibm.com>
IBM