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
Prevent UOE when MessageBodyReader can handle multiple media types #14604
Conversation
...active/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/Serialisers.java
Outdated
Show resolved
Hide resolved
It might be a stupid idea but why don't you sort them once and for all before making the list immutable? Or do you expect the list to be sorted in different ways depending on the context? |
Although this makes sense, it won't work because the |
But this indeed warrants another look into how the readers are determined (although I really hate this part as there are so many TCK tests that fail even when the slightest change is made...) |
The basic idea of the PR is to get rid of the useless usages of MediaTypeHelper.getBestMatch. Because of that we can now enforce the immutability of the media types in ResourceReader and ResourceWriter. Furthermore the PR applies some extra polish to MediaTypeHelper and does away with the Iterator allocation in during the lookup of the appropriate MessageBodyReader and MessageBodyWriter classes Related to: quarkusio#13997 (comment)
a5b0dfd
to
f4c07dc
Compare
I totally changed the PR and also updated the description. |
if (!hasAtMostOneItem(provided)) { | ||
provided = new ArrayList<>(provided); | ||
sortByWeight(provided); | ||
} |
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.
This is never used in a hot path? Because I could see how the extra allocations could slow things down.
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.
It is not, because I removed the calls to getBestMatch
from the hot path. The remaining calls to it are obscure features
The basic idea of the PR is to get rid of the useless usages of
MediaTypeHelper#getBestMatch
.Because of that we can now enforce the immutability of the media types in
ResourceReader
andResourceWriter
. This change is also beneficial from a performance standpoint.The places that do indeed need
getBestMatch
are very unlikely to be on the hot path, so I went ahead and made that method use a copy of the list and operate on it.Furthermore the PR applies some extra polish to MediaTypeHelper and
does away with the Iterator allocation in during the lookup
of the appropriate
MessageBodyReader
andMessageBodyWriter classes
Related to: #13997 (comment)