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 2015/06/24 21:10:57 UTC
svn commit: r1687346 -
/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
Author: markt
Date: Wed Jun 24 19:10:57 2015
New Revision: 1687346
URL: http://svn.apache.org/r1687346
Log:
Fix FindBugs warnings. activeRemoteStreamCount wasn't thread safe.
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=1687346&r1=1687345&r2=1687346&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Wed Jun 24 19:10:57 2015
@@ -117,7 +117,7 @@ public class Http2UpgradeHandler extends
private long writeTimeout = 10000;
private final Map<Integer,Stream> streams = new HashMap<>();
- private volatile int activeRemoteStreamCount = 0;
+ private final AtomicInteger activeRemoteStreamCount = new AtomicInteger(0);
private volatile int maxRemoteStreamId = 0;
// Start at -1 so the 'add 2' logic in closeIdleStreams() works
private volatile int maxActiveRemoteStreamId = -1;
@@ -144,7 +144,7 @@ public class Http2UpgradeHandler extends
streams.put(key, stream);
maxRemoteStreamId = 1;
maxActiveRemoteStreamId = 1;
- activeRemoteStreamCount = 1;
+ activeRemoteStreamCount.set(1);
maxProcessedStreamId = 1;
}
}
@@ -449,7 +449,7 @@ public class Http2UpgradeHandler extends
header[4] = FLAG_END_OF_STREAM;
stream.sentEndOfStream();
if (!stream.isActive()) {
- activeRemoteStreamCount--;
+ activeRemoteStreamCount.decrementAndGet();
}
}
ByteUtil.set31Bits(header, 5, stream.getIdentifier().intValue());
@@ -788,7 +788,7 @@ public class Http2UpgradeHandler extends
Stream stream = getStream(streamId, true);
stream.receivedEndOfStream();
if (!stream.isActive()) {
- activeRemoteStreamCount--;
+ activeRemoteStreamCount.decrementAndGet();
}
}
@@ -811,9 +811,8 @@ public class Http2UpgradeHandler extends
stream.checkState(FrameType.HEADERS);
stream.receivedStartOfHeaders();
closeIdleStreams(streamId);
- if (localSettings.getMaxConcurrentStreams() > activeRemoteStreamCount) {
- activeRemoteStreamCount++;
- } else {
+ if (localSettings.getMaxConcurrentStreams() > activeRemoteStreamCount.incrementAndGet()) {
+ activeRemoteStreamCount.decrementAndGet();
throw new StreamException(sm.getString("upgradeHandler.tooManyRemoteStreams",
Long.toString(localSettings.getMaxConcurrentStreams())),
Http2Error.REFUSED_STREAM, streamId);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org