-
Notifications
You must be signed in to change notification settings - Fork 355
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
JDK16 Support #4785
JDK16 Support #4785
Conversation
Signed-off-by: jansupol <jan.supol@oracle.com>
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 wrote a small comment to double check.
|
||
/* package */ Cache<Class<?>, Boolean> getJaxRsResourceCache() { | ||
/* CDI injection hack */ | ||
if (jaxRsResourceCache == null) { |
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.
Should we synchronize this or are we sure only one thread can invoke it the first time?. Something like:
/* package */ Cache<Class<?>, Boolean> getJaxRsResourceCache() {
/* CDI injection hack */
if (jaxRsResourceCache == null) {
synchronize(this) {
if (jaxRsResourceCache == null) {
jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null);
}
}
}
return jaxRsResourceCache;
}
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.
Nice catch. But invoking this multiple times would not break anything, there would be two instances of the cache & Resource.from would be invoked twice instead of having it used from the cache. I am not sure the double-checked locking is worth it in this case.
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 don't know all the details about how is going to be used, but imagine that there is a singleton that invokes that method and it saves it as a field. So next time it wants to use the cache, it reads it from the field (instead of getting it from getJaxRsResourceCache()).
It will not harm to have that lock because it will only lock at the beginning and we get rid of unnecessary extra memory usage.
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 happens that all the if (jaxRsResourceCache == null) {
block is unnecessary, so we could have dropped it
Signed-off-by: jansupol <jan.supol@oracle.com>
### What changes were proposed in this pull request? This pr aims to upgrade jersey to 2.35 ### Why are the changes needed? This jersey version starts to [support JDK 16](eclipse-ee4j/jersey#4785) and the change reports as follows: - https://github.com/eclipse-ee4j/jersey/releases/tag/2.35 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass GA Closes #35931 from LuciferYang/jersey-235. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: jansupol jan.supol@oracle.com