-
Notifications
You must be signed in to change notification settings - Fork 143
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
Try to eager load Servlets at startup. #23970
Conversation
This will trigger all the required CDI events, with as side-effect that we also created the Servlet in advance. According to the Servlet spec, this is allowed, and the Servlet TCK indeed passes with this change. Signed-off-by: Arjan Tijms <arjan.tijms@gmail.com>
continue; | ||
nonLoadOnStartupServlets.add(wrapper); | ||
} else { | ||
loadOnStartupServlets.computeIfAbsent(loadOnStartup, e -> new ArrayList<>()) |
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.
loadOnStartupServlets.computeIfAbsent(loadOnStartup, e -> new ArrayList<>()) | |
loadOnStartupServlets.computeIfAbsent(loadOnStartup, ArrayList::new) |
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 think arraylist::new will not work, as the key will be input into the ctor. With the key being an integer and the ctor setting the size, they will cause an out of memory with the huge key values being used.
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.
Wow, Arjan is right, I had the same idea, we discussed it in a chat and I started googling:
https://community.sonarsource.com/t/java-bug-using-collectors-tomap-with-arraylist-new/7661
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 happy to learn it now and not from the GF bug 😄
for (Wrapper wrapper : nonLoadOnStartupServlets) { | ||
try { | ||
wrapper.tryLoad(); | ||
} catch (Throwable t) { |
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.
One day I will remove all these dangerous "catch-all" blocks. ;-)
This will trigger all the required CDI events, with as side-effect that
we also created the Servlet in advance.
According to the Servlet spec, this is allowed, and the Servlet TCK
indeed passes with this change.
Signed-off-by: Arjan Tijms arjan.tijms@gmail.com