commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r429852 - in /jakarta/commons/proper/httpclient/trunk: ./ src/java/org/apache/commons/httpclient/protocol/ src/test/org/apache/commons/httpclient/
Date Tue, 08 Aug 2006 22:14:37 GMT
Author: olegk
Date: Tue Aug  8 15:14:36 2006
New Revision: 429852

URL: http://svn.apache.org/viewvc?rev=429852&view=rev
Log:
Fix for [HTTPCLIENT-593]: ProtocolSocketFactory equals and hashCode don't support subclassing

Contributed by Chris Audley <chrisaudley at yahoo.com>
Reviewed by Oleg Kalnichevski, Ortwin Gl├╝ck and Roland Weber

Modified:
    jakarta/commons/proper/httpclient/trunk/release_notes.txt
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEquals.java

Modified: jakarta/commons/proper/httpclient/trunk/release_notes.txt
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/release_notes.txt?rev=429852&r1=429851&r2=429852&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/release_notes.txt (original)
+++ jakarta/commons/proper/httpclient/trunk/release_notes.txt Tue Aug  8 15:14:36 2006
@@ -1,6 +1,10 @@
 -------------------
 Changes since Release 3.1 Alpha 1:
 
+* [HTTPCLIENT-593] - Fixed problem with #equals() and #hashCode() methods in subclasses of

+           DefaultProtocolSocketFactory and SSLProtocolSocketFactory
+           Contributed by Chris Audley <chrisaudley at yahoo.com>
+
 * [HTTPCLIENT-594] - HttpMethodBase#aborted variable was declared transient instead of volatile
            by mistake.
            Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java?rev=429852&r1=429851&r2=429852&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java
Tue Aug  8 15:14:36 2006
@@ -143,14 +143,14 @@
      * All instances of DefaultProtocolSocketFactory are the same.
      */
     public boolean equals(Object obj) {
-        return ((obj != null) && obj.getClass().equals(DefaultProtocolSocketFactory.class));
+        return ((obj != null) && obj.getClass().equals(getClass()));
     }
 
     /**
      * All instances of DefaultProtocolSocketFactory have the same hash code.
      */
     public int hashCode() {
-        return DefaultProtocolSocketFactory.class.hashCode();
+        return getClass().hashCode();
     }
 
 }

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java?rev=429852&r1=429851&r2=429852&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java
Tue Aug  8 15:14:36 2006
@@ -168,14 +168,14 @@
      * All instances of SSLProtocolSocketFactory are the same.
      */
     public boolean equals(Object obj) {
-        return ((obj != null) && obj.getClass().equals(SSLProtocolSocketFactory.class));
+        return ((obj != null) && obj.getClass().equals(getClass()));
     }
 
     /**
      * All instances of SSLProtocolSocketFactory have the same hash code.
      */
     public int hashCode() {
-        return SSLProtocolSocketFactory.class.hashCode();
+        return getClass().hashCode();
     }    
     
 }

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEquals.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEquals.java?rev=429852&r1=429851&r2=429852&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEquals.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEquals.java
Tue Aug  8 15:14:36 2006
@@ -86,6 +86,21 @@
         
     }
     
+    public void testProtocolSocketFactorySublass() {
+        ProtocolSocketFactory factory1 = new DefaultProtocolSocketFactory();
+        ProtocolSocketFactory factory2 = new DefaultProtocolSocketFactory() {};
+
+        Protocol protocolA = new Protocol("http", factory1, 80);
+        Protocol protocolB = new Protocol("http", factory2, 80);
+        Protocol protocolC = new Protocol("http", factory2, 80);
+
+        assertTrue(protocolB.equals(protocolC));
+        assertFalse(protocolA.equals(protocolB));
+        assertFalse(protocolB.equals(protocolA));
+        assertFalse(protocolA.equals(protocolB) != protocolB.equals(protocolA));
+        assertTrue(protocolB.equals(protocolB));
+    }
+    
     public void testHostConfiguration() {
         
         HostConfiguration hc1 = new HostConfiguration();



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message