Skip to content

Potential ClassCastException in RequestContextListener when destroying the request object [SPR-11378] #16005

Closed
@spring-projects-issues

Description

@spring-projects-issues

Vikram Hullukunte opened SPR-11378 and commented

In jersey-spring3, The org.glassfish.jersey.server.spring.scope.RequestContextFilter class creates JaxrsRequestAttributes datastructure and sets in the Threadlocal.

If an exception occurs in the calling chain of the jersey resource and the exception is not handled by jersey, then Spring's RequestContextListner bombs while destroying the threadlocal set as part of the request.

The exception:

SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.springframework.web.context.request.RequestContextListener
java.lang.ClassCastException: org.glassfish.jersey.server.spring.scope.JaxrsRequestAttributes cannot be cast to org.springframework.web.context.request.ServletRequestAttributes
at org.springframework.web.context.request.RequestContextListener.requestDestroyed(RequestContextListener.java:70)
at org.apache.catalina.core.StandardContext.fireRequestDestroyEvent(StandardContext.java:6080)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:207)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1686)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)


Affects: 3.2.7, 4.0.1

Reference URL: https://gist.github.com/hvvikram/8746498

Backported to: 3.2.8

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions