activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1102232 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/tcp/TcpTransport.java test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
Date Thu, 12 May 2011 10:22:20 GMT
Author: gtully
Date: Thu May 12 10:22:20 2011
New Revision: 1102232

URL: http://svn.apache.org/viewvc?rev=1102232&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3315 - Allow socket option soLinger to be enabled
on TcpTransport. allow disable, soLinger == -1, disable, > -1 enable otherwise not set
so system default

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java?rev=1102232&r1=1102231&r2=1102232&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
Thu May 12 10:22:20 2011
@@ -129,7 +129,7 @@ public class TcpTransport extends Transp
     protected final AtomicReference<CountDownLatch> stoppedLatch = new AtomicReference<CountDownLatch>();
 
     private Map<String, Object> socketOptions;
-    private int soLinger = -1;
+    private int soLinger = Integer.MIN_VALUE;
     private Boolean keepAlive;
     private Boolean tcpNoDelay;
     private Thread runnerThread;
@@ -360,8 +360,8 @@ public class TcpTransport extends Transp
     }
 
     /**
-     * Enable soLinger with the specified soLinger
-     * @param soLinger enabled if > -1
+     * Enable/disable soLinger
+     * @param soLinger enabled if > -1, disabled if == -1, system default otherwise
      */
     public void setSoLinger(int soLinger) {
         this.soLinger = soLinger;
@@ -448,8 +448,10 @@ public class TcpTransport extends Transp
             sock.setKeepAlive(keepAlive.booleanValue());
         }
 
-        if (soLinger != -1) {
+        if (soLinger > -1) {
             sock.setSoLinger(true, soLinger);
+        } else if (soLinger == -1) {
+            sock.setSoLinger(false, 0);
         }
         if (tcpNoDelay != null) {
             sock.setTcpNoDelay(tcpNoDelay.booleanValue());

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java?rev=1102232&r1=1102231&r2=1102232&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
Thu May 12 10:22:20 2011
@@ -139,6 +139,8 @@ public class TransportUriTest extends Em
         // TODO: Add more combinations.
         addCombinationValues("postfix", new Object[]
             {"?tcpNoDelay=true&keepAlive=true&soLinger=0"});
+        addCombinationValues("postfix", new Object[]
+            {"?tcpNoDelay=true&keepAlive=true&soLinger=-1"});
     }
 
     private void testValidOptionsWork(String options, String msg) {



Mime
View raw message