You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/11/24 14:19:21 UTC

svn commit: r1771149 - in /tomcat/trunk/java/org/apache/coyote/http2: AbstractStream.java Stream.java

Author: markt
Date: Thu Nov 24 14:19:21 2016
New Revision: 1771149

URL: http://svn.apache.org/viewvc?rev=1771149&view=rev
Log:
Child streams are always of type Stream

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java
    tomcat/trunk/java/org/apache/coyote/http2/Stream.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java?rev=1771149&r1=1771148&r2=1771149&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/AbstractStream.java Thu Nov 24 14:19:21 2016
@@ -16,8 +16,9 @@
  */
 package org.apache.coyote.http2;
 
-import java.util.HashSet;
+import java.util.Collections;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -34,7 +35,7 @@ abstract class AbstractStream {
     private final Integer identifier;
 
     private volatile AbstractStream parentStream = null;
-    private final Set<AbstractStream> childStreams = new HashSet<>();
+    private final Set<Stream> childStreams = Collections.newSetFromMap(new ConcurrentHashMap<>());
     private long windowSize = ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE;
 
     final Integer getIdentifier() {
@@ -55,7 +56,7 @@ abstract class AbstractStream {
     }
 
 
-    final void addChild(AbstractStream child) {
+    final void addChild(Stream child) {
         child.setParentStream(this);
         childStreams.add(child);
     }
@@ -84,7 +85,7 @@ abstract class AbstractStream {
     }
 
 
-    final Set<AbstractStream> getChildStreams() {
+    final Set<Stream> getChildStreams() {
         return childStreams;
     }
 

Modified: tomcat/trunk/java/org/apache/coyote/http2/Stream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Stream.java?rev=1771149&r1=1771148&r2=1771149&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Stream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Stream.java Thu Nov 24 14:19:21 2016
@@ -110,15 +110,17 @@ class Stream extends AbstractStream impl
         // Check if new parent is a descendant of this stream
         if (isDescendant(parent)) {
             parent.detachFromParent();
-            getParentStream().addChild(parent);
+            // Cast is always safe since any descendant of this stream must be
+            // an instance of Stream
+            getParentStream().addChild((Stream) parent);
         }
 
         if (exclusive) {
             // Need to move children of the new parent to be children of this
             // stream. Slightly convoluted to avoid concurrent modification.
-            Iterator<AbstractStream> parentsChildren = parent.getChildStreams().iterator();
+            Iterator<Stream> parentsChildren = parent.getChildStreams().iterator();
             while (parentsChildren.hasNext()) {
-                AbstractStream parentsChild = parentsChildren.next();
+                Stream parentsChild = parentsChildren.next();
                 parentsChildren.remove();
                 this.addChild(parentsChild);
             }



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