hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r514398 - in /jakarta/httpcomponents/httpcore/trunk: RELEASE_NOTES.txt module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
Date Sun, 04 Mar 2007 13:37:52 GMT
Author: olegk
Date: Sun Mar  4 05:37:50 2007
New Revision: 514398

URL: http://svn.apache.org/viewvc?view=rev&rev=514398
Log:
HTTPCORE-49: 

* DefaultConnectingIOReactor can now correctly handle unresolved socket addresses. It no longer
terminates with the UnresolvedAddressException runtime exception.

Modified:
    jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java

Modified: jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?view=diff&rev=514398&r1=514397&r2=514398
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Sun Mar  4 05:37:50 2007
@@ -1,6 +1,11 @@
 Changes since release 4.0 Alpha 3
 -------------------
 
+* [HTTPCORE-49]: DefaultConnectingIOReactor can now correctly handle 
+  unresolved socket addresses. It no longer terminates with the 
+  UnresolvedAddressException runtime exception.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-42]: Added server side API for the expectation verification. 
   Improved support for the 'expect: continue' handshake in HttpCore and 
   HttpCore NIO.

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java?view=diff&rev=514398&r1=514397&r2=514398
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
Sun Mar  4 05:37:50 2007
@@ -33,8 +33,10 @@
 
 import java.io.IOException;
 import java.io.InterruptedIOException;
+import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.SocketAddress;
+import java.net.UnknownHostException;
 import java.nio.channels.CancelledKeyException;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
@@ -213,6 +215,18 @@
         return sessionRequest;
     }
     
+    private void validateAddress(final SocketAddress address) throws UnknownHostException
{
+        if (address == null) {
+            return;
+        }
+        if (address instanceof InetSocketAddress) {
+            InetSocketAddress endpoint = (InetSocketAddress) address;
+            if (endpoint.isUnresolved()) {
+                throw new UnknownHostException(endpoint.getHostName());
+            }
+        }
+    }
+    
     private void processSessionRequests() throws IOReactorException {
         SessionRequestImpl request;
         while ((request = this.requestQueue.pop()) != null) {
@@ -227,12 +241,16 @@
                 throw new IOReactorException("Failure opening socket", ex);
             }
             try {
+                validateAddress(request.getLocalAddress());
+                validateAddress(request.getRemoteAddress());
+                
                 if (request.getLocalAddress() != null) {
                     socketChannel.socket().bind(request.getLocalAddress());
                 }
                 socketChannel.connect(request.getRemoteAddress());
             } catch (IOException ex) {
                 request.failed(ex);
+                return;
             }
             
             SelectionKey key;



Mime
View raw message