Add null checks to vertx 4.5.1 instrumentation #1927
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #1774
Customers were seeing NPEs after upgrading to version 8.9.0 of the agent, which added support for vertx 4.5.1. The NPEs were happening inside our
AsyncHandlerWrapper
class.This PR updates the instrumentation to prevent the creation of an
AsyncHandlerWrapper
if the originalresultHandler
is null. A further null check is added toAsyncHandlerWrapper
itself to safeguard against the possibility thathandle
might get called twice somewhere later in the code.I added a unit test where the resultHandler is null. However, this test isn't a "true" test because the existing NPE doesn't cause the test to fail (this NPE occurs off the main thread). Instead, an ugly SEVERE message appears in the stack trace without the fix.
I wasn't able to find a way to improve the test to truly capture the NPE, but decided to leave it in just to verify that the transaction and future handling still works as expected.