Author: markt
Date: Thu Aug 11 14:17:32 2016
New Revision: 1755993

URL: http://svn.apache.org/viewvc?rev=1755993&view=rev
Log:
Reduce duplication.
Ensure current concurrency is correctly tracked.

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java?rev=1755993&r1=1755992&r2=1755993&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Thu Aug 
11 14:17:32 2016
@@ -251,10 +251,23 @@ public class Http2UpgradeHandler extends
         }
 
         if (webConnection != null) {
-            // Process the initial request on a container thread
-            StreamProcessor streamProcessor = new StreamProcessor(this, 
stream, adapter, socketWrapper);
-            streamProcessor.setSslSupport(sslSupport);
+            processStreamOnContainerThread(stream);
+        }
+    }
+
+
+    private void processStreamOnContainerThread(Stream stream) {
+        StreamProcessor streamProcessor = new StreamProcessor(this, stream, 
adapter, socketWrapper);
+        streamProcessor.setSslSupport(sslSupport);
+        if (streamConcurrency == null) {
             socketWrapper.getEndpoint().getExecutor().execute(streamProcessor);
+        } else {
+            if (getStreamConcurrency() < maxConcurrentStreamExecution) {
+                increaseStreamConcurrency();
+                
socketWrapper.getEndpoint().getExecutor().execute(streamProcessor);
+            } else {
+                queuedProcessors.offer(streamProcessor);
+            }
         }
     }
 
@@ -1026,13 +1039,7 @@ public class Http2UpgradeHandler extends
 
         pushStream.sentPushPromise();
 
-        // Process this stream on a container thread
-        StreamProcessor streamProcessor = new StreamProcessor(this, 
pushStream, adapter, socketWrapper);
-        streamProcessor.setSslSupport(sslSupport);
-        if (streamConcurrency != null) {
-            increaseStreamConcurrency();
-        }
-        socketWrapper.getEndpoint().getExecutor().execute(streamProcessor);
+        processStreamOnContainerThread(pushStream);
     }
 
 
@@ -1244,19 +1251,7 @@ public class Http2UpgradeHandler extends
         setMaxProcessedStream(streamId);
         Stream stream = getStream(streamId, 
connectionState.get().isNewStreamAllowed());
         if (stream != null) {
-            // Process this stream on a container thread
-            StreamProcessor streamProcessor = new StreamProcessor(this, 
stream, adapter, socketWrapper);
-            streamProcessor.setSslSupport(sslSupport);
-            if (streamConcurrency == null) {
-                
socketWrapper.getEndpoint().getExecutor().execute(streamProcessor);
-            } else {
-                if (getStreamConcurrency() < maxConcurrentStreamExecution) {
-                    increaseStreamConcurrency();
-                    
socketWrapper.getEndpoint().getExecutor().execute(streamProcessor);
-                } else {
-                    queuedProcessors.offer(streamProcessor);
-                }
-            }
+            processStreamOnContainerThread(stream);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to