INT-3843: Backport NPE Fix for TCP ConFactories
JIRA: https://jira.spring.io/browse/INT-3843 **Cherry-pick to the 3.0.x** Conflicts: spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioServerConnectionFactory.java Resolved.
This commit is contained in:
committed by
Gary Russell
parent
524177522f
commit
1934d408c1
@@ -80,7 +80,15 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto
|
||||
* Not fatal.
|
||||
*/
|
||||
try {
|
||||
socket = serverSocket.accept();
|
||||
if (this.serverSocket == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(this + " stopped before accept");
|
||||
}
|
||||
throw new IOException(this + " stopped before accept");
|
||||
}
|
||||
else {
|
||||
socket = this.serverSocket.accept();
|
||||
}
|
||||
}
|
||||
catch (SocketTimeoutException ste) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
||||
@@ -92,11 +92,17 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto
|
||||
Math.abs(this.getBacklog()));
|
||||
}
|
||||
final Selector selector = Selector.open();
|
||||
this.serverChannel.register(selector, SelectionKey.OP_ACCEPT);
|
||||
this.setListening(true);
|
||||
this.selector = selector;
|
||||
doSelect(this.serverChannel, selector);
|
||||
|
||||
if (this.serverChannel == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(this + " stopped before registering the server channel");
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.serverChannel.register(selector, SelectionKey.OP_ACCEPT);
|
||||
setListening(true);
|
||||
this.selector = selector;
|
||||
doSelect(this.serverChannel, selector);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
this.close();
|
||||
|
||||
Reference in New Issue
Block a user