summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--java/net/URLStreamHandler.java21
2 files changed, 18 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 125727d7a..740ecd896 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-27 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/28486:
+ * java/net/URLStreamHandler.java (equals): Properly handle default
+ port. Rewrote javadoc. Don't compare 'authority' parts of URLs.
+
2006-07-27 Roman Kennke <kennke@aicas.com>
* javax/swing/text/AbstractDocument.java
diff --git a/java/net/URLStreamHandler.java b/java/net/URLStreamHandler.java
index ed9509221..9a5d73ad0 100644
--- a/java/net/URLStreamHandler.java
+++ b/java/net/URLStreamHandler.java
@@ -369,13 +369,11 @@ public abstract class URLStreamHandler
}
/**
- * Provides the default equals calculation. May be overidden by handlers for
- * other protocols that have different requirements for equals(). This method
- * requires that none of its arguments is null. This is guaranteed by the
- * fact that it is only called by java.net.URL class.
+ * This is the default method for computing whether two URLs are
+ * equivalent. This method assumes that neither URL is null.
*
* @param url1 An URL object
- * @param url2 An URL object
+ * @param url2 Another URL object
*
* @return True if both given URLs are equal, false otherwise.
*/
@@ -383,16 +381,21 @@ public abstract class URLStreamHandler
{
// This comparison is very conservative. It assumes that any
// field can be null.
- return (url1.getPort() == url2.getPort()
+ int port1 = url1.getPort();
+ if (port1 == -1)
+ port1 = url1.getDefaultPort();
+ int port2 = url2.getPort();
+ if (port2 == -1)
+ port2 = url2.getDefaultPort();
+ // Note that we don't bother checking the 'authority'; it is
+ // redundant.
+ return (port1 == port2
&& ((url1.getProtocol() == null && url2.getProtocol() == null)
|| (url1.getProtocol() != null
&& url1.getProtocol().equals(url2.getProtocol())))
&& ((url1.getUserInfo() == null && url2.getUserInfo() == null)
|| (url1.getUserInfo() != null
&& url1.getUserInfo().equals(url2.getUserInfo())))
- && ((url1.getAuthority() == null && url2.getAuthority() == null)
- || (url1.getAuthority() != null
- && url1.getAuthority().equals(url2.getAuthority())))
&& ((url1.getHost() == null && url2.getHost() == null)
|| (url1.getHost() != null && url1.getHost().equals(url2.getHost())))
&& ((url1.getPath() == null && url2.getPath() == null)