Skip to content
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

Merged
merged 1 commit into from
Jun 6, 2022

Conversation

arjantijms
Copy link
Contributor

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

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>
@arjantijms arjantijms added bug Something isn't working ee10-tck EE 10 TCK failures labels Jun 6, 2022
@arjantijms arjantijms added this to the 7.0.0 milestone Jun 6, 2022
@arjantijms arjantijms self-assigned this Jun 6, 2022
continue;
nonLoadOnStartupServlets.add(wrapper);
} else {
loadOnStartupServlets.computeIfAbsent(loadOnStartup, e -> new ArrayList<>())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
loadOnStartupServlets.computeIfAbsent(loadOnStartup, e -> new ArrayList<>())
loadOnStartupServlets.computeIfAbsent(loadOnStartup, ArrayList::new)

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

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) {
Copy link
Contributor

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. ;-)

@dmatej dmatej merged commit b52539c into eclipse-ee4j:master Jun 6, 2022
@dmatej dmatej linked an issue Jun 9, 2022 that may be closed by this pull request
11 tasks
@arjantijms arjantijms deleted the try_eager_load_servlets branch June 19, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ee10-tck EE 10 TCK failures
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CDI Test failures with GlassFish 7
3 participants