diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-24 07:35:40 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-24 07:35:40 +0000 |
commit | d509ef5c7aae0ad0578be5cc5e959576e4de6ce5 (patch) | |
tree | c6b9c7bb7b3ba809190cb127aa150cd7c22286f0 /libjava | |
parent | db9176e470a9534c9d275dfd3063cedcea603cf5 (diff) | |
download | gcc-d509ef5c7aae0ad0578be5cc5e959576e4de6ce5.tar.gz |
2004-09-24 Guilhem Lavaux <guilhem@kaffe.org>
* java/net/URL.java
(set): This method now matches the behaviour of the JDK.
(DEFAULT_SEARCH_PATH): Added "gnu.inet".
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88016 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 6 | ||||
-rw-r--r-- | libjava/java/net/URL.java | 42 |
2 files changed, 31 insertions, 17 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 234a0f3bda3..011bae2b973 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2004-09-24 Guilhem Lavaux <guilhem@kaffe.org> + + * java/net/URL.java + (set): This method now matches the behaviour of the JDK. + (DEFAULT_SEARCH_PATH): Added "gnu.inet". + 2004-09-24 Guilhem Lavaux <guilhem@kaffe.org> * java/net/URL.java (URL): Delete whitespaces in the protocol string. diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java index bc891f45344..71e43583736 100644 --- a/libjava/java/net/URL.java +++ b/libjava/java/net/URL.java @@ -122,7 +122,7 @@ import java.util.StringTokenizer; public final class URL implements Serializable { private static final String DEFAULT_SEARCH_PATH = - "gnu.java.net.protocol|sun.net.www.protocol"; + "gnu.java.net.protocol|gnu.inet"; /** * The name of the protocol for this URL. @@ -535,6 +535,8 @@ public final class URL implements Serializable */ public String getPath() { + // The spec says we need to return an empty string, but some + // applications depends on receiving null when the path is empty. if (file == null) return null; int quest = file.indexOf('?'); @@ -694,7 +696,8 @@ public final class URL implements Serializable * Sets the specified fields of the URL. This is not a public method so * that only URLStreamHandlers can modify URL fields. This might be called * by the <code>parseURL()</code> method in that class. URLs are otherwise - * constant. + * constant. If the given protocol does not exist, it will keep the previously + * set protocol. * * @param protocol The protocol name for this URL * @param host The hostname or IP address for this URL @@ -705,14 +708,16 @@ public final class URL implements Serializable protected void set(String protocol, String host, int port, String file, String ref) { - // TBD: Theoretically, a poorly written StreamHandler could pass an - // invalid protocol. It will cause the handler to be set to null - // thus overriding a valid handler. Callers of this method should - // be aware of this. - protocol = protocol.toLowerCase (); - if (! this.protocol.equals (protocol)) + URLStreamHandler protocolHandler = null; + protocol = protocol.toLowerCase(); + if (! this.protocol.equals(protocol)) + protocolHandler = getURLStreamHandler(protocol); + + // It is an hidden feature of the JDK. If the protocol does not exist, + // we keep the previously initialized protocol. + if (protocolHandler != null) { - this.ph = getURLStreamHandler(protocol); + this.ph = protocolHandler; this.protocol = protocol; } this.authority = ""; @@ -732,7 +737,8 @@ public final class URL implements Serializable /** * Sets the specified fields of the URL. This is not a public method so * that only URLStreamHandlers can modify URL fields. URLs are otherwise - * constant. + * constant. If the given protocol does not exist, it will keep the previously + * set protocol. * * @param protocol The protocol name for this URL. * @param host The hostname or IP address for this URL. @@ -748,14 +754,16 @@ public final class URL implements Serializable protected void set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) { - // TBD: Theoretically, a poorly written StreamHandler could pass an - // invalid protocol. It will cause the handler to be set to null - // thus overriding a valid handler. Callers of this method should - // be aware of this. - protocol = protocol.toLowerCase (); - if (! this.protocol.equals (protocol)) + URLStreamHandler protocolHandler = null; + protocol = protocol.toLowerCase(); + if (! this.protocol.equals(protocol)) + protocolHandler = getURLStreamHandler(protocol); + + // It is an hidden feature of the JDK. If the protocol does not exist, + // we keep the previously initialized protocol. + if (protocolHandler != null) { - this.ph = getURLStreamHandler(protocol); + this.ph = protocolHandler; this.protocol = protocol; } this.host = host; |