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

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1102232 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-05-12 10:22:20 +00:00
parent e8d45cb2d0
commit 52d5189698
2 changed files with 8 additions and 4 deletions

View File

@ -129,7 +129,7 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S
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 TransportThreadSupport implements Transport, S
}
/**
* 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 TransportThreadSupport implements Transport, S
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());

View File

@ -139,6 +139,8 @@ public class TransportUriTest extends EmbeddedBrokerTestSupport {
// 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) {