Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NullPointerException on tomcat #3705

Merged
merged 3 commits into from
Jul 28, 2021
Merged

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Jul 28, 2021

Resolves #3673
We store response in a request attribute and use it later to add async completion listener. Currently on tomcat we touch request a bit too early when it ins't fully initialized. Either org.apache.coyote.Request doesn't have a reference to HttpServletRequest in which case we just don't link response to request or org.apache.coyote.Request has reference to HttpServletRequest which is empty (request was recycled, reusing a previous request) in which case depending on tomcat version we could get a NullPointerException.

@@ -31,8 +31,6 @@ public void addRequestAsyncListener(
request
.getAsyncContext()
.addListener(new Listener(listener), request, (HttpServletResponse) response);
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this branch to make tests fail when response is null


transformer.applyAdviceToMethod(
isMethod()
.and(named("postParseRequest"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapter doesn't have this method. Is there any reason why we're not instrumenting CoyoteAdapter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Didn't even realize that it wasn't using CoyoteAdapter.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@trask trask merged commit d73e030 into open-telemetry:main Jul 28, 2021
@laurit laurit deleted the tomcat-async-npe branch August 24, 2021 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullPointerException when running grails tests
3 participants