You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I registered a @PreMatching ContainerRequestFilter via kafka.rest.resource.extension.class and sometimes need to throw exceptions that are mapped to responses. This works fine (client gets the correct response), but the MetricsRequestEventListener logs a NPE.
Root cause: The event RequestEvent.Type.MATCHING_START is never invoked in this case (exception is thrown in PreMatching filter), thus never initializing the wrappedRequestStream field. Later, handling the FINISHED event assumes wrappedRequestStream is set, throwin the NPE.
I believe MetricsRequestEventListener must be patched to initialize the wrappedRequestStream and started without depending on MATCHING_START event, because in this case it is never triggered.
I registered a @PreMatching ContainerRequestFilter via kafka.rest.resource.extension.class and sometimes need to throw exceptions that are mapped to responses. This works fine (client gets the correct response), but the MetricsRequestEventListener logs a NPE.
Root cause: The event RequestEvent.Type.MATCHING_START is never invoked in this case (exception is thrown in PreMatching filter), thus never initializing the wrappedRequestStream field. Later, handling the FINISHED event assumes wrappedRequestStream is set, throwin the NPE.
I believe MetricsRequestEventListener must be patched to initialize the
wrappedRequestStream
andstarted
without depending on MATCHING_START event, because in this case it is never triggered.I'm thinking about the following alternative to fix the issue: Replace the condition
if (event.getType() == RequestEvent.Type.MATCHING_START)
byif (started == 0L)
orif (wrappedRequestStream == null)
(at https://github.com/confluentinc/rest-utils/blob/5.3.1-post/core/src/main/java/io/confluent/rest/metrics/MetricsResourceMethodApplicationListener.java#L301) to initialize variables the first time any event is triggered.I'll open a PR.
Cheers,
Fabio
The text was updated successfully, but these errors were encountered: