Skip to content

Commit 3286226

Browse files
authored
Make MethodUtils CACHE_ENABLED volatile (#414)
written under the class monitor but read lock-free in computeIfAbsent, so setCacheMethods(false) may not be visible to other threads
1 parent cfeb533 commit 3286226

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/main/java/org/apache/commons/beanutils2/MethodUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public String toString() {
118118
* would mean having a map keyed by context classloader which may introduce memory-leak problems.
119119
* </p>
120120
*/
121-
private static boolean CACHE_ENABLED = true; //NOPMD @GuardedBy("this")
121+
private static volatile boolean CACHE_ENABLED = true; //NOPMD volatile: written under the class monitor, read lock-free in computeIfAbsent
122122

123123
/**
124124
* Stores a cache of MethodKey -> Method.

0 commit comments

Comments
 (0)