-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Avoid potential NPE in Metrics filter #16628
Conversation
/cc @ebullient, @jmartisk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit torn about this: it's hard for filter authors to know which (allowed) parameter may be null
, and why.
Perhaps it would be better to always have a ResourceInfo
even if its methods then throw an exception explaining that there's no resource because we had an exception before we found it.
But this would not make it easier for this particular filter which wants to ignore calls when that happens.
OTOH, is it really normal to invoke response filters when an exception happens that prevents us from finding the target resource?
Well, the spec says "A response mapped from an exception MUST be processed using the filter chain and the interceptor chain (if an entity is present in the mapped response). " So yeah, we apparently need to invoke them no matter how broken everything else is. |
Unfortunately yes... |
I actually think this would make it even more confusing |
OK hold on, the javadoc of
So that's our answer that is spec-compliant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to javadoc, the right thing to do is to have a non-null ResourceInfo
and a null
return value from its methods. Given that both options are equally confusing IMO, we should implement the one that is documented and has a better interop chance.
OK lemme do that |
The NPE could happen if an exception was thrown in a ContainerRequestFilter Fixes: quarkusio#16620
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
👍🏼 |
@geoand this one conflicts (due to the MP 4 changes). Not sure it's worth rewriting the patch? I'll let you judge of that. |
I think it's not terribly important, but I'd be up for it if someone complains :) |
The NPE could happen if an exception was thrown
in a ContainerRequestFilter
Fixes: #16620