-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Add web-flux jackson module and add check for javax.servlet package in classpath in web jackson module #6293
Conversation
in classpath in web jackson module.
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.
Thanks for the PR @finke-ba! I have commented inline. Also...Can we split this into two commits and tickets. The first is to conditionally add servlet based support and the second is to add support for WebFlux?
context.setMixInAnnotations(SavedCookie.class, SavedCookieMixin.class); | ||
SecurityJackson2Modules.enableDefaultTyping(context.getOwner()); | ||
if (ClassUtils.isPresent("javax.servlet.http.Cookie", this.getClass().getClassLoader())) { | ||
context.setMixInAnnotations(Cookie.class, CookieMixin.class); |
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.
Depending on the JDK this can cause issues. The reason is that many JDK's will load all the classes necessary for the entire class to run at once even if the code is not necessarily going to be executed. Instead, this code needs to be isolated in a separate module and then conditionally loaded.
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.
Hm, that's interesting, I didn't know that..
Is that means that some JDK(if it's fast could you give me example of that specific JDK or link to specification?) will try to load all the classes that presents in that class in initialization step of the that class? And that 'Cookie.class' will be try to load without looking at the condition?
But if I put everything in brackets into a separate class(new module) that could be load but will not instantiate, base on condition, that will work?
And that loading of all necessary classes will done only if I will try to create instance of that new module?
Thanks! Closing in favor of the two PRs |
I made it because DefaultCsrfServerToken exists in two packages at the moment(web and web.server) but only one mixin is configured(for web module).
I don't know what what to add to WebServerJackson2Module except DefaultCsrfServerTokenMixin, but in my feb-flux project that's enough.
Fixes #5623