Skip to content

Commit

Permalink
Revert "Fix #4561 (revert #4430) (#4562)"
Browse files Browse the repository at this point in the history
This reverts commit b89886a.
  • Loading branch information
cowtowncoder authored Jun 6, 2024
1 parent b89886a commit 4f3ac8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 0 additions & 5 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ Project: jackson-databind

-

2.17.2 (not yet released)

#4561: Issues using jackson-databind 2.17.1 with Reactor
(reported by @wdallastella)

2.17.1 (04-May-2024)

#4428: `ByteBuddy` scope went beyond `test` in version 2.17.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.databind.deser;

import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.*;
Expand Down Expand Up @@ -52,6 +53,12 @@ public final class DeserializerCache
protected final HashMap<JavaType, JsonDeserializer<Object>> _incompleteDeserializers
= new HashMap<JavaType, JsonDeserializer<Object>>(8);


/**
* We hold an explicit lock while creating deserializers to avoid creating duplicates.
*/
private final ReentrantLock _incompleteDeserializersLock = new ReentrantLock();

/*
/**********************************************************
/* Life-cycle
Expand Down Expand Up @@ -242,10 +249,12 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
DeserializerFactory factory, JavaType type)
throws JsonMappingException
{
// Only one thread to construct deserializers at any given point in time;
// limitations necessary to ensure that only completely initialized ones
// are visible and used.
synchronized (_incompleteDeserializers) {
/* Only one thread to construct deserializers at any given point in time;
* limitations necessary to ensure that only completely initialized ones
* are visible and used.
*/
_incompleteDeserializersLock.lock();
try {
// Ok, then: could it be that due to a race condition, deserializer can now be found?
JsonDeserializer<Object> deser = _findCachedDeserializer(type);
if (deser != null) {
Expand All @@ -268,6 +277,8 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
_incompleteDeserializers.clear();
}
}
} finally {
_incompleteDeserializersLock.unlock();
}
}

Expand Down

0 comments on commit 4f3ac8d

Please sign in to comment.