You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/03/20 15:27:41 UTC
(commons-jxpath) 10/11: NamespaceResolver.compiled now uses generics
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git
commit 69d356bed7031876af5b2a799b89dc8fc4e0ca12
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Mar 20 11:14:33 2025 -0400
NamespaceResolver.compiled now uses generics
---
.../commons/jxpath/ri/JXPathContextReferenceImpl.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
index 7b467bb..e28960e 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
@@ -65,7 +65,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
*/
public static final boolean USE_SOFT_CACHE = true;
private static final Compiler COMPILER = new TreeCompiler();
- private static Map compiled = new HashMap();
+ private static Map<String, Object> compiled = new HashMap<>();
private static int cleanupCount;
private static NodePointerFactory[] nodeFactoryArray;
// The frequency of the cache cleanup
@@ -235,9 +235,9 @@ public class JXPathContextReferenceImpl extends JXPathContext {
synchronized (compiled) {
if (USE_SOFT_CACHE) {
expr = null;
- final SoftReference ref = (SoftReference) compiled.get(xpath);
+ final SoftReference<Expression> ref = (SoftReference) compiled.get(xpath);
if (ref != null) {
- expr = (Expression) ref.get();
+ expr = ref.get();
}
} else {
expr = (Expression) compiled.get(xpath);
@@ -250,16 +250,16 @@ public class JXPathContextReferenceImpl extends JXPathContext {
synchronized (compiled) {
if (USE_SOFT_CACHE) {
if (cleanupCount++ >= CLEANUP_THRESHOLD) {
- final Iterator it = compiled.entrySet().iterator();
+ final Iterator<Entry<String, Object>> it = compiled.entrySet().iterator();
while (it.hasNext()) {
- final Entry me = (Entry) it.next();
- if (((SoftReference) me.getValue()).get() == null) {
+ final Entry<String, ?> me = it.next();
+ if (((SoftReference<Expression>) me.getValue()).get() == null) {
it.remove();
}
}
cleanupCount = 0;
}
- compiled.put(xpath, new SoftReference(expr));
+ compiled.put(xpath, new SoftReference<>(expr));
} else {
compiled.put(xpath, expr);
}