Bug 66455 - java.lang.ClassCastException: class org.apache.coyote.http2.RecycledStream cannot be cast to class org.apache.coyote.http2.Stream
Summary: java.lang.ClassCastException: class org.apache.coyote.http2.RecycledStream ca...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 9.0.71
Hardware: PC Linux
: P2 major (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-30 10:03 UTC by Boris Petrov
Modified: 2023-01-30 15:41 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Petrov 2023-01-30 10:03:54 UTC
Today I saw some ClassCastExceptions in my logs:

java.lang.ClassCastException: class org.apache.coyote.http2.RecycledStream cannot be cast to class org.apache.coyote.http2.Stream (org.apache.coyote.http2.RecycledStream and org.apache.coyote.http2.Stream are in unnamed module of loader java.net.URLClassLoader @2a742aa2)
        at org.apache.coyote.http2.Http2UpgradeHandler.incrementWindowSize(Http2UpgradeHandler.java:1031)
        at org.apache.coyote.http2.Http2UpgradeHandler.incrementWindowSize(Http2UpgradeHandler.java:1879)
        at org.apache.coyote.http2.Http2AsyncUpgradeHandler.incrementWindowSize(Http2AsyncUpgradeHandler.java:41)
        at org.apache.coyote.http2.Http2Parser.readWindowUpdateFrame(Http2Parser.java:449)
        at org.apache.coyote.http2.Http2AsyncParser$FrameCompletionHandler.completed(Http2AsyncParser.java:274)
        at org.apache.coyote.http2.Http2AsyncParser$FrameCompletionHandler.completed(Http2AsyncParser.java:166)
        at org.apache.tomcat.util.net.SocketWrapperBase$VectoredIOCompletionHandler.completed(SocketWrapperBase.java:1122)
        at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper$NioOperationState.run(NioEndpoint.java:1697)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:1589)

I'm not sure why that happens but it seems like a bug in Tomcat.
Comment 1 Mark Thomas 2023-01-30 10:23:51 UTC
Looks like a recycled stream ended up in the backlog.

Fixing the symptom would be fairly simple but I'd rather understand the root cause. Need to see if we can figure out how this might happen.
Comment 2 Mark Thomas 2023-01-30 11:51:34 UTC
Found it. I have  a test case and a fix. Just need to run the full test suite to check for regressions.
Comment 3 Mark Thomas 2023-01-30 15:41:21 UTC
Fixed in:
- 10.1.x for 10.1.6 onwards
-  9.0.x for  9.0.72 onwards
-  8.5.x for  8.5.86 onwards

11.0.x is not affected.