-
Notifications
You must be signed in to change notification settings - Fork 80
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
Use ReentrantLock
s instead of synchronized blocks
#184
Conversation
cbor/src/main/java/com/fasterxml/jackson/jaxrs/cbor/CBORMapperConfigurator.java
Show resolved
Hide resolved
base/src/main/java/com/fasterxml/jackson/jaxrs/cfg/MapperConfiguratorBase.java
Show resolved
Hide resolved
I don't see much value in doing any of this proactively. Let's wait until someone actually requests these changes. EDIT: changed my mind, see later comments. |
I don't see why locking this code helps.
How are we sure that whatever is locking is creating the _mapper? It could be just another getConfiguredMapper call. |
Yeah that seems dubious, not sure why it is synchronized. ----But my bigger point is that none of these methods seems likely at all to become synchronization hotspot.--- |
Hmmh. Actually, I take that back -- this could have measurable performance impact. Given that So yeah, maybe it's worth doing after all. |
ReentrantLock
s instead of synchronized blocks
@pjfanning Merged and I think this makes sense. Would it be possible to get similar PR for https://github.com/FasterXML/jackson-jakarta-rs-providers ? |
I don't think the existing synchronized code stops multiple creations of mappers.
The new lock code double checks that the mappers are not initialized. The new locking is optimistic - we don't lock and only lock when we know we need to lazily create instances.