Skip to content

Commit

Permalink
sonarlint :: add unload method to remove ThreadLocal objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdahlke committed Jun 13, 2024
1 parent a3cb7d7 commit b80ece4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/main/java/emissary/util/ClassLookupCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ public static Class<?> lookup(final String className) throws ClassNotFoundExcept
}
}

/**
* Destroy the ThreadLocal cache object
*/
public static void unload() {
cachedLookupResult.remove();
}

/** This is a static utility class, so prevent instantiation. */
private ClassLookupCache() {}
}
7 changes: 7 additions & 0 deletions src/main/java/emissary/util/ConstructorLookupCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ public static Constructor<?> lookup(final Class<?> clazz, final Class<?>[] argTy
}
}

/**
* Destroy the ThreadLocal cache object
*/
public static void unload() {
cachedConstructorLookup.remove();
}

/** This is a static utility class, so prevent instantiation. */
private ConstructorLookupCache() {}
}
13 changes: 7 additions & 6 deletions src/main/java/emissary/util/io/FileManipulator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
$Id$
*/

package emissary.util.io;

import java.io.File;
Expand All @@ -11,8 +7,6 @@
/**
* A class of utility methods for manipulating files.
*/


public class FileManipulator implements Serializable {

static final long serialVersionUID = 365259266882118692L;
Expand Down Expand Up @@ -54,6 +48,13 @@ public static String mkTempFile(final String dirPath) {
return mkTempFile(dirPath, "temp");
}

/**
* Destroy the ThreadLocal SecureRandom object
*/
public static void unload() {
secureRandomThreadLocal.remove();
}

/** This class is not meant to be instantiated. */
private FileManipulator() {}
}

0 comments on commit b80ece4

Please sign in to comment.