hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r1142758 - /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
Date Mon, 04 Jul 2011 18:47:12 GMT
Author: asankha
Date: Mon Jul  4 18:47:12 2011
New Revision: 1142758

URL: http://svn.apache.org/viewvc?rev=1142758&view=rev
Log:
improve connection debugging for IOSession.toString() to show the local and remote ports

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java?rev=1142758&r1=1142757&r2=1142758&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
Mon Jul  4 18:47:12 2011
@@ -28,6 +28,7 @@
 package org.apache.http.impl.nio.reactor;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.nio.channels.ByteChannel;
 import java.nio.channels.Channel;
@@ -310,6 +311,27 @@ public class IOSessionImpl implements IO
     @Override
     public synchronized String toString() {
         StringBuilder buffer = new StringBuilder();
+
+        if (getRemoteAddress() instanceof InetSocketAddress &&
+            getLocalAddress()  instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) getRemoteAddress());
+            final InetSocketAddress local  = ((InetSocketAddress) getLocalAddress());
+
+            buffer.append(local.getAddress().getHostAddress())
+            .append(':')
+            .append(local.getPort())
+            .append("<->")
+            .append(remote.getAddress().getHostAddress())
+            .append(':')
+            .append(remote.getPort());
+
+        } else {
+            buffer.append(getLocalAddress())
+            .append("<->")
+            .append(getRemoteAddress());
+        }
+
         buffer.append("[");
         switch (this.status) {
         case ACTIVE:



Mime
View raw message