commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol ReflectionSocketFactory.java
Date Tue, 21 Dec 2004 23:15:21 GMT
olegk       2004/12/21 15:15:21

  Modified:    httpclient/src/java/org/apache/commons/httpclient/params
                        DefaultHttpParams.java
               httpclient/src/java/org/apache/commons/httpclient/protocol
                        ReflectionSocketFactory.java
  Log:
  PR #32607 (MultiThreadedHttpConnectionManager ingnores local address of HostConfiguration)
  
  Contributed by Oleg Kalnichevski
  Reviewed by Eric Renouf <erenouf at skaion.com> and Michael Becke
  
  Revision  Changes    Path
  1.9       +5 -5      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java
  
  Index: DefaultHttpParams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultHttpParams.java	13 May 2004 04:01:22 -0000	1.8
  +++ DefaultHttpParams.java	21 Dec 2004 23:15:21 -0000	1.9
  @@ -147,7 +147,7 @@
           }
           this.parameters.put(name, value);
           if (LOG.isDebugEnabled()) {
  -            LOG.debug("Set parameter " + name + " = " + value.toString());
  +            LOG.debug("Set parameter " + name + " = " + value);
           }
       }
       
  
  
  
  1.4       +20 -11    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/ReflectionSocketFactory.java
  
  Index: ReflectionSocketFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/ReflectionSocketFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReflectionSocketFactory.java	10 Jun 2004 18:25:24 -0000	1.3
  +++ ReflectionSocketFactory.java	21 Dec 2004 23:15:21 -0000	1.4
  @@ -53,6 +53,7 @@
       
       private static Constructor INETSOCKETADDRESS_CONSTRUCTOR = null;
       private static Method SOCKETCONNECT_METHOD = null;
  +    private static Method SOCKETBIND_METHOD = null;
       private static Class SOCKETTIMEOUTEXCEPTION_CLASS = null;
   
       private ReflectionSocketFactory() {
  @@ -98,8 +99,10 @@
           //
           //  SocketFactory socketFactory = Class.forName(socketfactoryName).getDefault();
           //  Socket socket = socketFactory.createSocket();
  -        //  SocketAddress addr = new InetSocketAddress(host, port);
  -        //  socket.connect(addr, timeout);
  +        //  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);
  @@ -114,20 +117,26 @@
               if (INETSOCKETADDRESS_CONSTRUCTOR == null) {
                   Class addressClass = Class.forName("java.net.InetSocketAddress");
                   INETSOCKETADDRESS_CONSTRUCTOR = addressClass.getConstructor(
  -                    new Class[] { String.class, Integer.TYPE });
  +                    new Class[] { InetAddress.class, Integer.TYPE });
               }
                   
  -            Object addr = INETSOCKETADDRESS_CONSTRUCTOR.newInstance(
  -                new Object[] { host, new Integer(port)});
  +            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});
               }
   
  -            SOCKETCONNECT_METHOD.invoke(socket, 
  -                new Object[] { addr, new Integer(timeout)});
  -
  +            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) {
  
  
  

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