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

In appropriate usage of static members #153

Open
jjspiegel opened this issue Feb 19, 2025 · 0 comments
Open

In appropriate usage of static members #153

jjspiegel opened this issue Feb 19, 2025 · 0 comments

Comments

@jjspiegel
Copy link
Member

In OsonFactory, OracleJsonFactory is constructed as a static member. While there is no correctness issue here, it may sometimes be beneficial to not have a single global instance with pooled memory. Also it seems incongruous for OsonFactory to not be a singleton when it wraps a singleton. Suggest making OsonFactory non-static, adding a constructor that allows OracleJsonFactory to optionally be passed from the outside, and adding a getter to access the factory.

In JacksonOsonConverter, there is a single static instance of OracleJsonFactory and ObjectMapper. ObjectMapper is mutable so handing out a single instance from getObjectMapper() isn't appropriate. One consumer could mutate the instance and the effects would be observed by all of the consumers. Suggest making both OracleJsonFactory and ObjectMapper non-static. Add a non-static method to create an objectMapper rather than get one. Although, I'm not clear on what the public usage patterns are for JacksonOsonConverter so some other solution may be more appropriate than the one I'm suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant