Oleg,

You are right. I removed the localAddr using LocalHost. I did the test and 
everything is ok.

As indicated, I create a patch and submit this file to you.



Best Regards,

Philip She

Web Services and Infrastructure Software -BSD
Aviva Canada Inc.,
2206 Eglinton Avenue East, Scarborough, On. M1L 4S8
Tel: 416-2882667




Ortwin Glück <[EMAIL PROTECTED]> 
10/30/2007 04:18 AM
Please respond to
"HttpComponents Project" <[email protected]>


To
HttpComponents Project <[email protected]>
cc

Subject
Re: Compatible issue solution of HttpClient and IBM WSAD environment






[EMAIL PROTECTED] wrote:
> By the way, I am just joined the team. I donot know how to prepare the 
> changes in the unified diff format. Any doc or instruct?

If you're using Eclipse: use the Subclipse Plugin for Subversion
support, then checkout the repository from

http://svn.apache.org/repos/asf/jakarta/httpcomponents/project-trunk

Then setup the project so that it compiles.
Make your changes to the code.

Select the project in the Package Explorer, right click and select Team
> Create Patch.


If you are using the command line, just use "svn diff > patch.txt".

HTH

Odi

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: 
[EMAIL PROTECTED]


Index: C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/.classpath
===================================================================
--- C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/.classpath   
(revision 0)
+++ C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/.classpath   
(revision 0)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path=""/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="output" path=""/>
+</classpath>
Index: C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/.project
===================================================================
--- C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/.project     
(revision 0)
+++ C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/.project     
(revision 0)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>ApacheHttpClient</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
Index: 
C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/org/apache/commons/httpclient/protocol/ReflectionSocketFactory.java
===================================================================
--- 
C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/org/apache/commons/httpclient/protocol/ReflectionSocketFactory.java
  (revision 590330)
+++ 
C:/pshe/workspace/eclipse3.2.1/Apache/ApacheHttpClient/org/apache/commons/httpclient/protocol/ReflectionSocketFactory.java
  (working copy)
@@ -84,86 +84,119 @@
      * 
      */
     public static Socket createSocket(
-        final String socketfactoryName, 
-        final String host,
-        final int port,
-        final InetAddress localAddress,
-        final int localPort,
-        int timeout)
-     throws IOException, UnknownHostException, ConnectTimeoutException
-    {
-        if (REFLECTION_FAILED) {
-            //This is known to have failed before. Do not try it again
-            return null;
-        }
-        // This code uses reflection to essentially do the following:
-        //
-        //  SocketFactory socketFactory = 
Class.forName(socketfactoryName).getDefault();
-        //  Socket socket = socketFactory.createSocket();
-        //  SocketAddress localaddr = new InetSocketAddress(localAddress, 
localPort);
-        //  SocketAddress remoteaddr = new InetSocketAddress(host, port);
-        //  socket.bind(localaddr);
-        //  socket.connect(remoteaddr, timeout);
-        //  return socket;
-        try {
-            Class socketfactoryClass = Class.forName(socketfactoryName);
-            Method method = socketfactoryClass.getMethod("getDefault", 
-                new Class[] {});
-            Object socketfactory = method.invoke(null, 
-                new Object[] {});
-            method = socketfactoryClass.getMethod("createSocket", 
-                new Class[] {});
-            Socket socket = (Socket) method.invoke(socketfactory, new Object[] 
{});
-            
-            if (INETSOCKETADDRESS_CONSTRUCTOR == null) {
-                Class addressClass = 
Class.forName("java.net.InetSocketAddress");
-                INETSOCKETADDRESS_CONSTRUCTOR = addressClass.getConstructor(
-                    new Class[] { InetAddress.class, Integer.TYPE });
+            final String socketfactoryName, 
+            final String host,
+            final int port,
+            final InetAddress localAddress,
+            final int localPort,
+            int timeout)
+         throws IOException, UnknownHostException, ConnectTimeoutException
+        {
+            if (REFLECTION_FAILED) {
+                //This is known to have failed before. Do not try it again
+                return null;
             }
+            // This code uses reflection to essentially do the following:
+            //
+            //  SocketFactory socketFactory = 
Class.forName(socketfactoryName).getDefault();
+            //  Socket socket = socketFactory.createSocket();
+            //  SocketAddress localaddr = new InetSocketAddress(localAddress, 
localPort);
+            //  SocketAddress remoteaddr = new InetSocketAddress(host, port);
+            //  socket.bind(localaddr);
+            //  socket.connect(remoteaddr, timeout);
+            //  return socket;
+            try {
+                Class socketfactoryClass = Class.forName(socketfactoryName);
+                Method method = socketfactoryClass.getMethod("getDefault", 
+                    new Class[] {});
+                Object socketfactory = method.invoke(null, 
+                    new Object[] {});
                 
-            Object remoteaddr = INETSOCKETADDRESS_CONSTRUCTOR.newInstance(
-                new Object[] { InetAddress.getByName(host), new 
Integer(port)});
+                // Begin: changed by Philip She to resolve the IBM JSSE 
support issue
+                
+                // Below commented code is the original code
+//                     method = socketfactoryClass.getMethod("createSocket", 
+//                     new Class[] {});
+//                 Socket socket = (Socket) method.invoke(socketfactory, new 
Object[] {});
+//                 
+//                 if (INETSOCKETADDRESS_CONSTRUCTOR == null) {
+//                     Class addressClass = 
Class.forName("java.net.InetSocketAddress");
+//                     INETSOCKETADDRESS_CONSTRUCTOR = 
addressClass.getConstructor(
+//                         new Class[] { InetAddress.class, Integer.TYPE });
+//                 }
+//                     
+//                 Object remoteaddr = 
INETSOCKETADDRESS_CONSTRUCTOR.newInstance(
+//                     new Object[] { InetAddress.getByName(host), new 
Integer(port)});
+    //
+//                 Object localaddr = 
INETSOCKETADDRESS_CONSTRUCTOR.newInstance(
+//                         new Object[] { localAddress, new 
Integer(localPort)});
+    //
+//                 if (SOCKETCONNECT_METHOD == null) {
+//                     SOCKETCONNECT_METHOD = 
Socket.class.getMethod("connect", 
+//                         new Class[] 
{Class.forName("java.net.SocketAddress"), Integer.TYPE});
+//                 }
+    //
+//                 if (SOCKETBIND_METHOD == null) {
+//                     SOCKETBIND_METHOD = Socket.class.getMethod("bind", 
+//                         new Class[] 
{Class.forName("java.net.SocketAddress")});
+//                 }
+//                 SOCKETBIND_METHOD.invoke(socket, new Object[] { localaddr});
+//                 SOCKETCONNECT_METHOD.invoke(socket, new Object[] { 
remoteaddr, new Integer(timeout)});
+                // This new code uses reflection to essentially do the 
following:
+                //
+                //  SocketFactory socketFactory = 
Class.forName(socketfactoryName).getDefault();
+                //  InetAddress remoteaddr = InetAddress.getByName(host);
+                //  SocketAddress remoteSocketAddr = new 
InetSocketAddress(remoteaddr, port);
+                //  Socket socket = socketFactory.createSocket(remoteaddr, new 
Integer(port),localAddress, new Integer(localPort));
+                //  SocketAddress localaddr = new 
InetSocketAddress(localAddress, localPort);
+                //  socket.connect(remoteSocketAddr, timeout);
+                //  return socket;
+                       Object remoteaddr = InetAddress.getByName(host);
+                       if (INETSOCKETADDRESS_CONSTRUCTOR == null) {
+                               Class addressClass = 
Class.forName("java.net.InetSocketAddress");
+                               INETSOCKETADDRESS_CONSTRUCTOR = 
addressClass.getConstructor(
+                                       new Class[] { InetAddress.class, 
Integer.TYPE });
+                       }
+                    
+                       Object remoteSocketAddr = 
INETSOCKETADDRESS_CONSTRUCTOR.newInstance(
+                               new Object[] { InetAddress.getByName(host), new 
Integer(port)});
 
-            Object localaddr = INETSOCKETADDRESS_CONSTRUCTOR.newInstance(
-                    new Object[] { localAddress, new Integer(localPort)});
+                       method = socketfactoryClass.getMethod("createSocket", 
+                               new Class[] {InetAddress.class, Integer.TYPE, 
InetAddress.class, Integer.TYPE});
+                       Socket socket = (Socket) method.invoke(socketfactory, 
new Object[] {remoteaddr, new Integer(port),localAddress, new 
Integer(localPort) });
+                       if (SOCKETCONNECT_METHOD == null) {
+                               SOCKETCONNECT_METHOD = 
Socket.class.getMethod("connect", 
+                                       new Class[] 
{Class.forName("java.net.SocketAddress"), Integer.TYPE});
+                       }
+                       SOCKETCONNECT_METHOD.invoke(socket, new Object[] { 
remoteSocketAddr, new Integer(timeout)});
+                       // End: changed by Philip She 
 
-            if (SOCKETCONNECT_METHOD == null) {
-                SOCKETCONNECT_METHOD = Socket.class.getMethod("connect", 
-                    new Class[] {Class.forName("java.net.SocketAddress"), 
Integer.TYPE});
+                return socket;
             }
-
-            if (SOCKETBIND_METHOD == null) {
-                SOCKETBIND_METHOD = Socket.class.getMethod("bind", 
-                    new Class[] {Class.forName("java.net.SocketAddress")});
-            }
-            SOCKETBIND_METHOD.invoke(socket, new Object[] { localaddr});
-            SOCKETCONNECT_METHOD.invoke(socket, new Object[] { remoteaddr, new 
Integer(timeout)});
-            return socket;
-        }
-        catch (InvocationTargetException e) {
-            Throwable cause = e.getTargetException(); 
-            if (SOCKETTIMEOUTEXCEPTION_CLASS == null) {
-                try {
-                    SOCKETTIMEOUTEXCEPTION_CLASS = 
Class.forName("java.net.SocketTimeoutException");
-                } catch (ClassNotFoundException ex) {
-                    // At this point this should never happen. Really.
-                    REFLECTION_FAILED = true;
-                    return null;
+            catch (InvocationTargetException e) {
+                Throwable cause = e.getTargetException(); 
+                if (SOCKETTIMEOUTEXCEPTION_CLASS == null) {
+                    try {
+                        SOCKETTIMEOUTEXCEPTION_CLASS = 
Class.forName("java.net.SocketTimeoutException");
+                    } catch (ClassNotFoundException ex) {
+                        // At this point this should never happen. Really.
+                        REFLECTION_FAILED = true;
+                        return null;
+                    }
                 }
+                if (SOCKETTIMEOUTEXCEPTION_CLASS.isInstance(cause)) {
+                    throw new ConnectTimeoutException(
+                        "The host did not accept the connection within timeout 
of " 
+                        + timeout + " ms", cause);
+                }
+                if (cause instanceof IOException) {
+                    throw (IOException)cause;
+                }
+                return null;
             }
-            if (SOCKETTIMEOUTEXCEPTION_CLASS.isInstance(cause)) {
-                throw new ConnectTimeoutException(
-                    "The host did not accept the connection within timeout of 
" 
-                    + timeout + " ms", cause);
+            catch (Exception e) {
+                REFLECTION_FAILED = true;
+                return null;
             }
-            if (cause instanceof IOException) {
-                throw (IOException)cause;
-            }
-            return null;
         }
-        catch (Exception e) {
-            REFLECTION_FAILED = true;
-            return null;
-        }
-    }
 }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to