You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/08/27 07:04:51 UTC
(maven) branch master updated: fix: synchronize ReflectionValueExtractor class-introspection caches (impl and compat) for thread safety (#12841)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new 05657fde3c fix: synchronize ReflectionValueExtractor class-introspection caches (impl and compat) for thread safety (#12841)
05657fde3c is described below
commit 05657fde3c00485a3d9478d122a68f6dec285a70
Author: Keith E Campbell <ke...@knowledge.design>
AuthorDate: Thu Aug 27 00:04:45 2026 -0700
fix: synchronize ReflectionValueExtractor class-introspection caches (impl and compat) for thread safety (#12841)
Merging the consolidated fix for #12731 (impl + compat copies). Supersedes #12732.
---
.../model/interpolation/reflection/ReflectionValueExtractor.java | 4 +++-
.../apache/maven/impl/model/reflection/ReflectionValueExtractor.java | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/compat/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/reflection/ReflectionValueExtractor.java b/compat/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/reflection/ReflectionValueExtractor.java
index e44d2df2d1..2a5e4790ca 100644
--- a/compat/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/reflection/ReflectionValueExtractor.java
+++ b/compat/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/reflection/ReflectionValueExtractor.java
@@ -24,6 +24,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -51,7 +52,8 @@ public class ReflectionValueExtractor {
* This approach prevents permgen space overflows due to retention of discarded
* classloaders.
*/
- private static final Map<Class<?>, WeakReference<ClassMap>> CLASS_MAPS = new WeakHashMap<>();
+ private static final Map<Class<?>, WeakReference<ClassMap>> CLASS_MAPS =
+ Collections.synchronizedMap(new WeakHashMap<>());
static final int EOF = -1;
diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/reflection/ReflectionValueExtractor.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/reflection/ReflectionValueExtractor.java
index 40563b11dd..105225b79a 100644
--- a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/reflection/ReflectionValueExtractor.java
+++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/reflection/ReflectionValueExtractor.java
@@ -23,6 +23,7 @@
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -48,7 +49,8 @@ public class ReflectionValueExtractor {
* This approach prevents permgen space overflows due to retention of discarded
* classloaders.
*/
- private static final Map<Class<?>, WeakReference<ClassMap>> CLASS_MAPS = new WeakHashMap<>();
+ private static final Map<Class<?>, WeakReference<ClassMap>> CLASS_MAPS =
+ Collections.synchronizedMap(new WeakHashMap<>());
static final int EOF = -1;