-
-
Notifications
You must be signed in to change notification settings - Fork 797
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
Spotbugs + Java: may expose internal representation by storing an externally mutable object into objectMapper #1382
Comments
This issue is not a Jackson issue. It is a problem with your code. Try making the objectMapper private. Contact the spotbugs community to see if they have other suggestions. |
@patpatpat123 Going forward you would want to reach out on Spring Boot forums for issues like this; as @pjfanning suggested this has little to do with Jackson based on output you shared. |
Suggests that it is not a great idea to share an ObjectMapper instance across various classes because one of those might mutate the configuration of the ObjectMapper instance - and this would affect other classes that had access to the same instance. You would be better off sharing (autowiring) ObjectReader and ObjectWriter instances. This can't be mutated. If you call an API to change the config of an ObjectReader or ObjectWriter, you are returned a new instance that has the modified config.
You may need to update your Dependency Injection code to inject an ObjectReader instance and/or ObjectWriter instance. They can be created using an ObjectMapper instance. |
Thank you all for your answers |
Hello team,
Since this is my first issue from 2025, just wanted to start by wishing you a happy new year and the best for 2025.
Wanted to reach out regarding an issue reported by spot bugs: "may expose internal representation by storing an externally mutable object into objectMapper"
We are using SpringBoot, and in many of our classes, we have this construct:
This would be flagged with
"may expose internal representation by storing an externally mutable object into objectMapper"
Could you please help fix this vulnerability?
Thank you for your time
The text was updated successfully, but these errors were encountered: