You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2014/04/28 16:16:01 UTC
svn commit: r1590647 -
/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
Author: remm
Date: Mon Apr 28 14:16:01 2014
New Revision: 1590647
URL: http://svn.apache.org/r1590647
Log:
Drop useless null checks.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1590647&r1=1590646&r2=1590647&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Mon Apr 28 14:16:01 2014
@@ -605,8 +605,11 @@ public class Nio2Endpoint extends Abstra
}
public void closeSocket(SocketWrapper<Nio2Channel> socket, SocketStatus status) {
+ if (socket == null) {
+ return;
+ }
try {
- if (socket != null && socket.isComet() && status != null) {
+ if (socket.isComet() && status != null) {
socket.setComet(false);//to avoid a loop
if (status == SocketStatus.TIMEOUT) {
if (processSocket0(socket, status, true)) {
@@ -617,9 +620,9 @@ public class Nio2Endpoint extends Abstra
processSocket0(socket, status, false);
}
}
- if (socket!=null) handler.release(socket);
+ handler.release(socket);
try {
- if (socket!=null) {
+ if (socket.getSocket() != null) {
socket.getSocket().close(true);
}
} catch (Exception e){
@@ -630,17 +633,15 @@ public class Nio2Endpoint extends Abstra
}
Nio2SocketWrapper nio2Socket = (Nio2SocketWrapper) socket;
try {
- if (nio2Socket != null && nio2Socket.getSendfileData() != null
+ if (nio2Socket.getSendfileData() != null
&& nio2Socket.getSendfileData().fchannel != null
&& nio2Socket.getSendfileData().fchannel.isOpen()) {
nio2Socket.getSendfileData().fchannel.close();
}
} catch (Exception ignore) {
}
- if (nio2Socket != null) {
- nio2Socket.reset(null, -1);
- countDownConnection();
- }
+ nio2Socket.reset(null, -1);
+ countDownConnection();
} catch (Throwable e) {
ExceptionUtils.handleThrowable(e);
if (log.isDebugEnabled()) log.error("",e);
@@ -756,7 +757,7 @@ public class Nio2Endpoint extends Abstra
SocketWrapper<Nio2Channel> socket = sockets.next();
long access = socket.getLastAccess();
if (socket.getTimeout() > 0 &&
- (now-access)>socket.getTimeout()) {
+ (now-access) > socket.getTimeout()) {
processSocket(socket, SocketStatus.TIMEOUT, true);
}
}
@@ -1085,7 +1086,7 @@ public class Nio2Endpoint extends Abstra
// Upgraded connections need to allow multiple threads to access the
// connection at the same time to enable blocking IO to be used when
// NIO has been configured
- if (socket != null && socket.isUpgraded() &&
+ if (socket.isUpgraded() &&
SocketStatus.OPEN_WRITE == status) {
synchronized (socket.getWriteThreadLock()) {
doRun();
@@ -1103,7 +1104,7 @@ public class Nio2Endpoint extends Abstra
int handshake = -1;
try {
- if (socket != null && socket.getSocket() != null) {
+ if (socket.getSocket() != null) {
// For STOP there is no point trying to handshake as the
// Poller has been stopped.
if (socket.getSocket().isHandshakeComplete() ||
@@ -1151,9 +1152,7 @@ public class Nio2Endpoint extends Abstra
launch = true;
}
} else if (handshake == -1 ) {
- if (socket != null) {
- closeSocket(socket, SocketStatus.DISCONNECT);
- }
+ closeSocket(socket, SocketStatus.DISCONNECT);
if (useCaches && running && !paused) {
nioChannels.push(socket.getSocket());
}
@@ -1165,9 +1164,7 @@ public class Nio2Endpoint extends Abstra
try {
oomParachuteData = null;
log.error("", oom);
- if (socket != null) {
- closeSocket(socket, SocketStatus.ERROR);
- }
+ closeSocket(socket, SocketStatus.ERROR);
releaseCaches();
} catch (Throwable oomt) {
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org