directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject mina-core: VmPipeConnector and AnonymousSocketAddress
Date Fri, 04 Aug 2006 15:56:00 GMT
Hi there, I've been using the VmPipeConnector for "unit" testing and have 
come up against a problem. The the AnonymousSocketAddresses that are 
handed out are all the very same instance. The code relies on each 
client-side socket being unique and providing a unique name via 
toString(). For an InetSocketAddress, the toString() returns 
ip-address/host and port.

I have a small patch for your consideration. Let me know if it's the wrong 
format etc. I haven't been able to run this up against the unit tests for 
mina-core as mvn isn't working for me. mvn doesn't seem to be able to find 
the jar plugin 
(org.apache.maven.plugins:maven-jar-plugin:pom:2.1-SNAPSHOT) so please be 
aware of that. If anyone know how to get around that problem, I'd love to 
hear about it!

I did write a quick shell script to compile and jar mina-core in order to 
test against my own unit tests and found that it fixes my problem.


Index: src/main/java/org/apache/mina/transport/vmpipe/
--- src/main/java/org/apache/mina/transport/vmpipe/ 
(revision 428432)
+++ src/main/java/org/apache/mina/transport/vmpipe/ 
(working copy)
@@ -85,7 +85,7 @@
                 new VmPipeSessionImpl(
                         new Object(), // lock
-                        AnonymousSocketAddress.INSTANCE,
+                        new AnonymousSocketAddress(),
Index: src/main/java/org/apache/mina/util/
--- src/main/java/org/apache/mina/util/ 
(revision 428432)
+++ src/main/java/org/apache/mina/util/ 
(working copy)
@@ -30,27 +30,21 @@
     private static final long serialVersionUID = 3978421416766944048L;

-    public static final AnonymousSocketAddress INSTANCE = new 
      * Creates a new instance with the specifid port number.
-    private AnonymousSocketAddress()
+    public AnonymousSocketAddress()

     public int hashCode()
-        return 1432482932;
+        return super.hashCode();

     public boolean equals( Object o )
-        if( o == null )
-            return false;
-        if( this == o )
-            return true;
-        return o instanceof AnonymousSocketAddress;
+        return super.equals(o);

     public int compareTo( Object o )
@@ -58,8 +52,7 @@
         return this.hashCode() - ( ( AnonymousSocketAddress ) o 

-    public String toString()
-    {
-        return "anonymous";
+    public String toString() {
+        return super.toString();

This communication is for informational purposes only. It is not intended as an offer or solicitation
for the purchase or sale of any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not warranted as to completeness
or accuracy and are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged, confidential, legally privileged,
and/or exempt from disclosure under applicable law. If you are not the intended recipient,
you are hereby notified that any disclosure, copying, distribution, or use of the information
contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission
and any attachments are believed to be free of any virus or other defect that might affect
any computer system into which it is received and opened, it is the responsibility of the
recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase
& Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising
in any way from its use. If you received this transmission in error, please immediately contact
the sender and destroy the material in its entirety, whether in electronic or hard copy format.
Thank you.
View raw message