tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1599711 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/coyote/http11/ webapps/docs/
Date Tue, 03 Jun 2014 18:05:03 GMT
Author: kkolinko
Date: Tue Jun  3 18:05:02 2014
New Revision: 1599711

URL: http://svn.apache.org/r1599711
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56582
Convert implementations of ActionHook.action(..) to use switch(enum) operator.
Part 2/2: HTTP processors.

It is backport of r1599393 from tomcat/trunk.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1599393

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1599711&r1=1599710&r2=1599711&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Jun
 3 18:05:02 2014
@@ -751,7 +751,8 @@ public abstract class AbstractHttp11Proc
     @SuppressWarnings("deprecation") // Inbound/Outbound based upgrade mechanism
     public final void action(ActionCode actionCode, Object param) {
 
-        if (actionCode == ActionCode.CLOSE) {
+        switch (actionCode) {
+        case CLOSE: {
             // End the processing of the current request
 
             try {
@@ -760,8 +761,9 @@ public abstract class AbstractHttp11Proc
                 // Set error flag
                 error = true;
             }
-
-        } else if (actionCode == ActionCode.COMMIT) {
+            break;
+        }
+        case COMMIT: {
             // Commit current response
 
             if (response.isCommitted()) {
@@ -776,8 +778,9 @@ public abstract class AbstractHttp11Proc
                 // Set error flag
                 error = true;
             }
-
-        } else if (actionCode == ActionCode.ACK) {
+            break;
+        }
+        case ACK: {
             // Acknowledge request
             // Send a 100 status back if it makes sense (response not committed
             // yet, and client specified an expectation for 100-continue)
@@ -793,8 +796,9 @@ public abstract class AbstractHttp11Proc
                 // Set error flag
                 error = true;
             }
-        } else if (actionCode == ActionCode.CLIENT_FLUSH) {
-
+            break;
+        }
+        case CLIENT_FLUSH: {
             try {
                 getOutputBuffer().flush();
             } catch (IOException e) {
@@ -802,27 +806,32 @@ public abstract class AbstractHttp11Proc
                 error = true;
                 response.setErrorException(e);
             }
-
-        } else if (actionCode == ActionCode.IS_ERROR) {
+            break;
+        }
+        case IS_ERROR: {
             ((AtomicBoolean) param).set(error);
-
-        } else if (actionCode == ActionCode.DISABLE_SWALLOW_INPUT) {
+            break;
+        }
+        case DISABLE_SWALLOW_INPUT: {
             // Do not swallow request input but
             // make sure we are closing the connection
             error = true;
             getInputBuffer().setSwallowInput(false);
-
-        } else if (actionCode == ActionCode.RESET) {
+            break;
+        }
+        case RESET: {
             // Reset response
             // Note: This must be called before the response is committed
 
             getOutputBuffer().reset();
-
-        } else if (actionCode == ActionCode.CUSTOM) {
+            break;
+        }
+        case CUSTOM: {
             // Do nothing
             // TODO Remove this action
-
-        } else if (actionCode == ActionCode.REQ_SET_BODY_REPLAY) {
+            break;
+        }
+        case REQ_SET_BODY_REPLAY: {
             ByteChunk body = (ByteChunk) param;
 
             InputFilter savedBody = new SavedRequestInputFilter(body);
@@ -832,39 +841,67 @@ public abstract class AbstractHttp11Proc
             AbstractInputBuffer<S> internalBuffer = (AbstractInputBuffer<S>)
                 request.getInputBuffer();
             internalBuffer.addActiveFilter(savedBody);
-        } else if (actionCode == ActionCode.ASYNC_START) {
+            break;
+        }
+        case ASYNC_START: {
             asyncStateMachine.asyncStart((AsyncContextCallback) param);
             // Async time out is based on SocketWrapper access time
             getSocketWrapper().access();
-        } else if (actionCode == ActionCode.ASYNC_DISPATCHED) {
+            break;
+        }
+        case ASYNC_DISPATCHED: {
             asyncStateMachine.asyncDispatched();
-        } else if (actionCode == ActionCode.ASYNC_TIMEOUT) {
+            break;
+        }
+        case ASYNC_TIMEOUT: {
             AtomicBoolean result = (AtomicBoolean) param;
             result.set(asyncStateMachine.asyncTimeout());
-        } else if (actionCode == ActionCode.ASYNC_RUN) {
+            break;
+        }
+        case ASYNC_RUN: {
             asyncStateMachine.asyncRun((Runnable) param);
-        } else if (actionCode == ActionCode.ASYNC_ERROR) {
+            break;
+        }
+        case ASYNC_ERROR: {
             asyncStateMachine.asyncError();
-        } else if (actionCode == ActionCode.ASYNC_IS_STARTED) {
+            break;
+        }
+        case ASYNC_IS_STARTED: {
             ((AtomicBoolean) param).set(asyncStateMachine.isAsyncStarted());
-        } else if (actionCode == ActionCode.ASYNC_IS_DISPATCHING) {
+            break;
+        }
+        case ASYNC_IS_DISPATCHING: {
             ((AtomicBoolean) param).set(asyncStateMachine.isAsyncDispatching());
-        } else if (actionCode == ActionCode.ASYNC_IS_ASYNC) {
+            break;
+        }
+        case ASYNC_IS_ASYNC: {
             ((AtomicBoolean) param).set(asyncStateMachine.isAsync());
-        } else if (actionCode == ActionCode.ASYNC_IS_TIMINGOUT) {
+            break;
+        }
+        case ASYNC_IS_TIMINGOUT: {
             ((AtomicBoolean) param).set(asyncStateMachine.isAsyncTimingOut());
-        } else if (actionCode == ActionCode.ASYNC_IS_ERROR) {
+            break;
+        }
+        case ASYNC_IS_ERROR: {
             ((AtomicBoolean) param).set(asyncStateMachine.isAsyncError());
-        } else if (actionCode == ActionCode.UPGRADE_TOMCAT) {
+            break;
+        }
+        case UPGRADE_TOMCAT: {
             upgradeInbound = (org.apache.coyote.http11.upgrade.UpgradeInbound) param;
             // Stop further HTTP output
             getOutputBuffer().finished = true;
-        } else if (actionCode == ActionCode.UPGRADE) {
+            break;
+        }
+        case UPGRADE: {
             httpUpgradeHandler = (HttpUpgradeHandler) param;
             // Stop further HTTP output
             getOutputBuffer().finished = true;
-        } else {
+            break;
+        }
+        default: {
             actionInternal(actionCode, param);
+            break;
+        }
         }
     }
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1599711&r1=1599710&r2=1599711&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Tue Jun  3
18:05:02 2014
@@ -266,12 +266,13 @@ public class Http11AprProcessor extends 
      * @param param Action parameter
      */
     @Override
+    @SuppressWarnings("incomplete-switch") // Other cases are handled by action()
     public void actionInternal(ActionCode actionCode, Object param) {
 
         long socketRef = socketWrapper.getSocket().longValue();
 
-        if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {
-
+        switch (actionCode) {
+        case REQ_HOST_ADDR_ATTRIBUTE: {
             // Get remote host address
             if (remoteAddr == null && (socketRef != 0)) {
                 try {
@@ -282,9 +283,9 @@ public class Http11AprProcessor extends 
                 }
             }
             request.remoteAddr().setString(remoteAddr);
-
-        } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCAL_NAME_ATTRIBUTE: {
             // Get local host name
             if (localName == null && (socketRef != 0)) {
                 try {
@@ -295,9 +296,9 @@ public class Http11AprProcessor extends 
                 }
             }
             request.localName().setString(localName);
-
-        } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_HOST_ATTRIBUTE: {
             // Get remote host name
             if (remoteHost == null && (socketRef != 0)) {
                 try {
@@ -311,9 +312,9 @@ public class Http11AprProcessor extends 
                 }
             }
             request.remoteHost().setString(remoteHost);
-
-        } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCAL_ADDR_ATTRIBUTE: {
             // Get local host address
             if (localAddr == null && (socketRef != 0)) {
                 try {
@@ -325,9 +326,9 @@ public class Http11AprProcessor extends 
             }
 
             request.localAddr().setString(localAddr);
-
-        } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_REMOTEPORT_ATTRIBUTE: {
             // Get remote port
             if (remotePort == -1 && (socketRef != 0)) {
                 try {
@@ -339,9 +340,9 @@ public class Http11AprProcessor extends 
                 }
             }
             request.setRemotePort(remotePort);
-
-        } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCALPORT_ATTRIBUTE: {
             // Get local port
             if (localPort == -1 && (socketRef != 0)) {
                 try {
@@ -353,9 +354,9 @@ public class Http11AprProcessor extends 
                 }
             }
             request.setLocalPort(localPort);
-
-        } else if (actionCode == ActionCode.REQ_SSL_ATTRIBUTE ) {
-
+            break;
+        }
+        case REQ_SSL_ATTRIBUTE: {
             if (endpoint.isSSLEnabled() && (socketRef != 0)) {
                 try {
                     // Cipher suite
@@ -402,9 +403,9 @@ public class Http11AprProcessor extends 
                     log.warn(sm.getString("http11processor.socket.ssl"), e);
                 }
             }
-
-        } else if (actionCode == ActionCode.REQ_SSL_CERTIFICATE) {
-
+            break;
+        }
+        case REQ_SSL_CERTIFICATE: {
             if (endpoint.isSSLEnabled() && (socketRef != 0)) {
                 // Consume and buffer the request body, so that it does not
                 // interfere with the client's handshake messages
@@ -440,36 +441,52 @@ public class Http11AprProcessor extends 
                     log.warn(sm.getString("http11processor.socket.ssl"), e);
                 }
             }
-
-        } else if (actionCode == ActionCode.AVAILABLE) {
+            break;
+        }
+        case AVAILABLE: {
             request.setAvailable(inputBuffer.available());
-        } else if (actionCode == ActionCode.COMET_BEGIN) {
+            break;
+        }
+        case COMET_BEGIN: {
             comet = true;
-        } else if (actionCode == ActionCode.COMET_END) {
+            break;
+        }
+        case COMET_END: {
             comet = false;
-        } else if (actionCode == ActionCode.COMET_CLOSE) {
+            break;
+        }
+        case COMET_CLOSE: {
             ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper,
                     SocketStatus.OPEN_READ);
-        } else if (actionCode == ActionCode.COMET_SETTIMEOUT) {
+            break;
+        }
+        case COMET_SETTIMEOUT: {
             //no op
-        } else if (actionCode == ActionCode.ASYNC_COMPLETE) {
+            break;
+        }
+        case ASYNC_COMPLETE: {
             if (asyncStateMachine.asyncComplete()) {
                 ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper,
                         SocketStatus.OPEN_READ);
             }
-        } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
+            break;
+        }
+        case ASYNC_SETTIMEOUT: {
             if (param==null) {
                 return;
             }
             long timeout = ((Long)param).longValue();
             socketWrapper.setTimeout(timeout);
-        } else if (actionCode == ActionCode.ASYNC_DISPATCH) {
+            break;
+        }
+        case ASYNC_DISPATCH: {
             if (asyncStateMachine.asyncDispatch()) {
                 ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper,
                         SocketStatus.OPEN_READ);
             }
+            break;
+        }
         }
-
 
     }
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1599711&r1=1599710&r2=1599711&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Tue Jun  3
18:05:02 2014
@@ -311,10 +311,11 @@ public class Http11NioProcessor extends 
      * @param param Action parameter
      */
     @Override
+    @SuppressWarnings("incomplete-switch") // Other cases are handled by action()
     public void actionInternal(ActionCode actionCode, Object param) {
 
-        if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {
-
+        switch (actionCode) {
+        case REQ_HOST_ADDR_ATTRIBUTE: {
             // Get remote host address
             if ((remoteAddr == null) && (socketWrapper != null)) {
                 InetAddress inetAddr = socketWrapper.getSocket().getIOChannel().socket().getInetAddress();
@@ -323,9 +324,9 @@ public class Http11NioProcessor extends 
                 }
             }
             request.remoteAddr().setString(remoteAddr);
-
-        } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCAL_NAME_ATTRIBUTE: {
             // Get local host name
             if ((localName == null) && (socketWrapper != null)) {
                 InetAddress inetAddr = socketWrapper.getSocket().getIOChannel().socket().getLocalAddress();
@@ -334,9 +335,9 @@ public class Http11NioProcessor extends 
                 }
             }
             request.localName().setString(localName);
-
-        } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_HOST_ATTRIBUTE: {
             // Get remote host name
             if ((remoteHost == null) && (socketWrapper != null)) {
                 InetAddress inetAddr = socketWrapper.getSocket().getIOChannel().socket().getInetAddress();
@@ -352,31 +353,31 @@ public class Http11NioProcessor extends 
                 }
             }
             request.remoteHost().setString(remoteHost);
-
-        } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCAL_ADDR_ATTRIBUTE: {
             if (localAddr == null) {
                 localAddr = socketWrapper.getSocket().getIOChannel().socket().getLocalAddress().getHostAddress();
             }
 
             request.localAddr().setString(localAddr);
-
-        } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_REMOTEPORT_ATTRIBUTE: {
             if ((remotePort == -1 ) && (socketWrapper !=null)) {
                 remotePort = socketWrapper.getSocket().getIOChannel().socket().getPort();
             }
             request.setRemotePort(remotePort);
-
-        } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCALPORT_ATTRIBUTE: {
             if ((localPort == -1 ) && (socketWrapper !=null)) {
                 localPort = socketWrapper.getSocket().getIOChannel().socket().getLocalPort();
             }
             request.setLocalPort(localPort);
-
-        } else if (actionCode == ActionCode.REQ_SSL_ATTRIBUTE ) {
-
+            break;
+        }
+        case REQ_SSL_ATTRIBUTE: {
             try {
                 if (sslSupport != null) {
                     Object sslO = sslSupport.getCipherSuite();
@@ -404,10 +405,10 @@ public class Http11NioProcessor extends 
             } catch (Exception e) {
                 log.warn(sm.getString("http11processor.socket.ssl"), e);
             }
-
-        } else if (actionCode == ActionCode.REQ_SSL_CERTIFICATE) {
-
-            if( sslSupport != null) {
+            break;
+        }
+        case REQ_SSL_CERTIFICATE: {
+            if (sslSupport != null) {
                 /*
                  * Consume and buffer the request body, so that it does not
                  * interfere with the client's handshake messages
@@ -444,14 +445,21 @@ public class Http11NioProcessor extends 
                     log.warn(sm.getString("http11processor.socket.ssl"), e);
                 }
             }
-
-        } else if (actionCode == ActionCode.AVAILABLE) {
+            break;
+        }
+        case AVAILABLE: {
             request.setAvailable(inputBuffer.available());
-        } else if (actionCode == ActionCode.COMET_BEGIN) {
+            break;
+        }
+        case COMET_BEGIN: {
             comet = true;
-        } else if (actionCode == ActionCode.COMET_END) {
+            break;
+        }
+        case COMET_END: {
             comet = false;
-        }  else if (actionCode == ActionCode.COMET_CLOSE) {
+            break;
+        }
+        case COMET_CLOSE: {
             if (socketWrapper==null || socketWrapper.getSocket().getAttachment(false)==null)
{
                 return;
             }
@@ -464,7 +472,9 @@ public class Http11NioProcessor extends 
                 // an application controlled thread) or similar.
                 socketWrapper.getSocket().getPoller().add(socketWrapper.getSocket());
             }
-        } else if (actionCode == ActionCode.COMET_SETTIMEOUT) {
+            break;
+        }
+        case COMET_SETTIMEOUT: {
             if (param==null) {
                 return;
             }
@@ -478,12 +488,16 @@ public class Http11NioProcessor extends 
             if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) {
                 attach.setTimeout(timeout);
             }
-        } else if (actionCode == ActionCode.ASYNC_COMPLETE) {
+            break;
+        }
+        case ASYNC_COMPLETE: {
             if (asyncStateMachine.asyncComplete()) {
                 ((NioEndpoint)endpoint).processSocket(socketWrapper.getSocket(),
                         SocketStatus.OPEN_READ, true);
             }
-        } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
+            break;
+        }
+        case ASYNC_SETTIMEOUT: {
             if (param==null) {
                 return;
             }
@@ -494,11 +508,15 @@ public class Http11NioProcessor extends 
             long timeout = ((Long)param).longValue();
             //if we are not piggy backing on a worker thread, set the timeout
             attach.setTimeout(timeout);
-        } else if (actionCode == ActionCode.ASYNC_DISPATCH) {
+            break;
+        }
+        case ASYNC_DISPATCH: {
             if (asyncStateMachine.asyncDispatch()) {
                 ((NioEndpoint)endpoint).processSocket(socketWrapper.getSocket(),
                         SocketStatus.OPEN_READ, true);
             }
+            break;
+        }
         }
     }
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1599711&r1=1599710&r2=1599711&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue Jun  3 18:05:02
2014
@@ -240,11 +240,12 @@ public class Http11Processor extends Abs
      * @param actionCode Type of the action
      * @param param Action parameter
      */
+    @SuppressWarnings("incomplete-switch") // Other cases are handled by action()
     @Override
     public void actionInternal(ActionCode actionCode, Object param) {
 
-        if (actionCode == ActionCode.REQ_SSL_ATTRIBUTE ) {
-
+        switch (actionCode) {
+        case REQ_SSL_ATTRIBUTE: {
             try {
                 if (sslSupport != null) {
                     Object sslO = sslSupport.getCipherSuite();
@@ -268,9 +269,9 @@ public class Http11Processor extends Abs
             } catch (Exception e) {
                 log.warn(sm.getString("http11processor.socket.ssl"), e);
             }
-
-        } else if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_HOST_ADDR_ATTRIBUTE: {
             if ((remoteAddr == null) && (socketWrapper != null)) {
                 InetAddress inetAddr = socketWrapper.getSocket().getInetAddress();
                 if (inetAddr != null) {
@@ -278,9 +279,9 @@ public class Http11Processor extends Abs
                 }
             }
             request.remoteAddr().setString(remoteAddr);
-
-        } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCAL_NAME_ATTRIBUTE: {
             if ((localName == null) && (socketWrapper != null)) {
                 InetAddress inetAddr = socketWrapper.getSocket().getLocalAddress();
                 if (inetAddr != null) {
@@ -288,9 +289,9 @@ public class Http11Processor extends Abs
                 }
             }
             request.localName().setString(localName);
-
-        } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_HOST_ATTRIBUTE: {
             if ((remoteHost == null) && (socketWrapper != null)) {
                 InetAddress inetAddr = socketWrapper.getSocket().getInetAddress();
                 if (inetAddr != null) {
@@ -305,30 +306,31 @@ public class Http11Processor extends Abs
                 }
             }
             request.remoteHost().setString(remoteHost);
-
-        } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCAL_ADDR_ATTRIBUTE: {
             if (localAddr == null)
                localAddr = socketWrapper.getSocket().getLocalAddress().getHostAddress();
 
             request.localAddr().setString(localAddr);
-
-        } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_REMOTEPORT_ATTRIBUTE: {
             if ((remotePort == -1 ) && (socketWrapper !=null)) {
                 remotePort = socketWrapper.getSocket().getPort();
             }
             request.setRemotePort(remotePort);
-
-        } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) {
-
+            break;
+        }
+        case REQ_LOCALPORT_ATTRIBUTE: {
             if ((localPort == -1 ) && (socketWrapper !=null)) {
                 localPort = socketWrapper.getSocket().getLocalPort();
             }
             request.setLocalPort(localPort);
-
-        } else if (actionCode == ActionCode.REQ_SSL_CERTIFICATE) {
-            if( sslSupport != null) {
+            break;
+        }
+        case REQ_SSL_CERTIFICATE: {
+            if (sslSupport != null) {
                 /*
                  * Consume and buffer the request body, so that it does not
                  * interfere with the client's handshake messages
@@ -348,21 +350,29 @@ public class Http11Processor extends Abs
                     log.warn(sm.getString("http11processor.socket.ssl"), e);
                 }
             }
-        } else if (actionCode == ActionCode.ASYNC_COMPLETE) {
+            break;
+        }
+        case ASYNC_COMPLETE: {
             if (asyncStateMachine.asyncComplete()) {
                 ((JIoEndpoint) endpoint).processSocketAsync(this.socketWrapper,
                         SocketStatus.OPEN_READ);
             }
-        } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
+            break;
+        }
+        case ASYNC_SETTIMEOUT: {
             if (param == null) return;
             long timeout = ((Long)param).longValue();
             // if we are not piggy backing on a worker thread, set the timeout
             socketWrapper.setTimeout(timeout);
-        } else if (actionCode == ActionCode.ASYNC_DISPATCH) {
+            break;
+        }
+        case ASYNC_DISPATCH: {
             if (asyncStateMachine.asyncDispatch()) {
                 ((JIoEndpoint) endpoint).processSocketAsync(this.socketWrapper,
                         SocketStatus.OPEN_READ);
             }
+            break;
+        }
         }
     }
 

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1599711&r1=1599710&r2=1599711&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Jun  3 18:05:02 2014
@@ -88,6 +88,10 @@
         buffer when the buffer is only partially written on a subsequent write.
         (markt)
       </fix>
+      <scode>
+        <bug>56582</bug>: Use switch(actionCode) in processors instead of a
+        chain of "elseif"s. (kkolinko)
+      </scode>
     </changelog>
   </subsection>
   <subsection name="Jasper">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message