Conversation
vpaturet
left a comment
There was a problem hiding this comment.
Looks good.
Could you document:
- thread safety: why it works.
- memory leak: why this is a limited risk.
|
I'm actually not sure how many threads are using the adapter concurrently. If there is a chance that it's multiple, we can synchronize the map map or use a concurrent one. Any opinions? |
The Unmarshaller is documented as not thread-safe and the reference JAXB implementation creates one instance of Adapter per Unmarshaller. But this is not mandated by the spec. |
This implements deduplication of instances of
LocalTime.This is okay, because it's an immutable value object where one instance truly can be replaced with an equal one.
Improvement
In my current example file this can cut down the number of instances from around 30 million to a few thousand, saving around 800MB of RAM!
cc @vpaturet
Ref: #284
Ref: noi-techpark/opendatahub-mentor-otp#273
cc @rcavaliere