You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by st...@jpmorgan.com on 2006/08/04 17:56:00 UTC

mina-core: VmPipeConnector and AnonymousSocketAddress

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.

Cheers,
Steve.

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

-    public static final AnonymousSocketAddress INSTANCE = new 
AnonymousSocketAddress();
-
     /**
      * 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 
).hashCode();
     }

-    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.
 

Re: mina-core: VmPipeConnector and AnonymousSocketAddress

Posted by st...@jpmorgan.com.
> Your patch looks OK, and thank you for your contribution! :)
> Could you create a JIRA issue and attach the patch file to clear a legal 
issue?

No worries. I registered and created DIRMINA-240 with patch attached.

Cheers,
Steve.

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.
 

Re: mina-core: VmPipeConnector and AnonymousSocketAddress

Posted by Trustin Lee <tr...@gmail.com>.
Hi Steven,

On 8/5/06, steven.x.shaw@jpmorgan.com <st...@jpmorgan.com> wrote:
>
>
> 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.
>

Your patch looks OK, and thank you for your contribution! :)
Could you create a JIRA issue and attach the patch file to clear a legal
issue?

Thank you in advance,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: mina-core: VmPipeConnector and AnonymousSocketAddress

Posted by st...@jpmorgan.com.
I tried to build mina-core with 'mvn clean install' and then I get a 
problem that I cannot download the maven clean plugin :). 
org.apache.maven.plugins:maven-clean-plugin:pom:2.1.1-SNAPSHOT.
Maybe I'm using the wrong version of Maven. I've currently tried 2.0.2 and 
2.0.4.

Cheers,
Steve.

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.
 

Re: mina-core: VmPipeConnector and AnonymousSocketAddress

Posted by Trustin Lee <tr...@gmail.com>.
On 8/7/06, Trustin Lee <tr...@gmail.com> wrote:
>
> On 8/5/06, steven.x.shaw@jpmorgan.com <st...@jpmorgan.com> wrote:
>
> > 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!
> >
>
> Hmm... I will try to run 'mvn package' by myself after clearing my local
> repository.  Thank you for the heads up.
>

Please try again with 'mvn clean install'.  It runs OK for me.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: mina-core: VmPipeConnector and AnonymousSocketAddress

Posted by Trustin Lee <tr...@gmail.com>.
On 8/5/06, steven.x.shaw@jpmorgan.com <st...@jpmorgan.com> wrote:
>
> 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!
>

Hmm... I will try to run 'mvn package' by myself after clearing my local
repository.  Thank you for the heads up.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6