Skip to content

In appropriate usage of static members #153

@jjspiegel

Description

@jjspiegel

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions