Skip to content

Commit

Permalink
Lenient fallback when cached WeakReference returns null
Browse files Browse the repository at this point in the history
Closes gh-34423
  • Loading branch information
jhoeller committed Feb 26, 2025
1 parent b6a5402 commit 06721ba
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ public Predicate getUniqueNamePredicate() {
}

public Object get(AbstractClassGenerator gen, boolean useCache) {
if (!useCache) {
return gen.generate(ClassLoaderData.this);
}
else {
// SPRING PATCH BEGIN
Object value = null;
if (useCache) {
Object cachedValue = generatedClasses.get(gen);
return gen.unwrapCachedValue(cachedValue);
value = gen.unwrapCachedValue(cachedValue);
}
if (value == null) { // fallback when cached WeakReference returns null
value = gen.generate(ClassLoaderData.this);
}
return value;
// SPRING PATCH END
}
}

Expand Down

0 comments on commit 06721ba

Please sign in to comment.