src/java.base/share/classes/java/net/URLStreamHandler.java
changeset 57895 82a71d82e326
parent 55711 0c143aaa2c99
child 58242 94bb65cb37d3
equal deleted inserted replaced
57894:01b9c26e2651 57895:82a71d82e326
    28 import java.io.IOException;
    28 import java.io.IOException;
    29 import java.io.InputStream;
    29 import java.io.InputStream;
    30 import java.io.File;
    30 import java.io.File;
    31 import java.io.OutputStream;
    31 import java.io.OutputStream;
    32 import java.util.Hashtable;
    32 import java.util.Hashtable;
       
    33 import java.util.Objects;
    33 import sun.net.util.IPAddressUtil;
    34 import sun.net.util.IPAddressUtil;
    34 import sun.net.www.ParseUtil;
    35 import sun.net.www.ParseUtil;
    35 
    36 
    36 /**
    37 /**
    37  * The abstract class {@code URLStreamHandler} is the common
    38  * The abstract class {@code URLStreamHandler} is the common
   341      * considered equal, i.e. they refer to the same
   342      * considered equal, i.e. they refer to the same
   342      * fragment in the same file.
   343      * fragment in the same file.
   343      * @since 1.3
   344      * @since 1.3
   344      */
   345      */
   345     protected boolean equals(URL u1, URL u2) {
   346     protected boolean equals(URL u1, URL u2) {
   346         String ref1 = u1.getRef();
   347         return Objects.equals(u1.getRef(), u2.getRef()) && sameFile(u1, u2);
   347         String ref2 = u2.getRef();
       
   348         return (ref1 == ref2 || (ref1 != null && ref1.equals(ref2))) &&
       
   349                sameFile(u1, u2);
       
   350     }
   348     }
   351 
   349 
   352     /**
   350     /**
   353      * Provides the default hash calculation. May be overridden by handlers for
   351      * Provides the default hash calculation. May be overridden by handlers for
   354      * other protocols that have different requirements for hashCode
   352      * other protocols that have different requirements for hashCode