Skip to content

Commit 69d356b

Browse files
committed
NamespaceResolver.compiled now uses generics
1 parent 04193cc commit 69d356b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
6565
*/
6666
public static final boolean USE_SOFT_CACHE = true;
6767
private static final Compiler COMPILER = new TreeCompiler();
68-
private static Map compiled = new HashMap();
68+
private static Map<String, Object> compiled = new HashMap<>();
6969
private static int cleanupCount;
7070
private static NodePointerFactory[] nodeFactoryArray;
7171
// The frequency of the cache cleanup
@@ -235,9 +235,9 @@ private Expression compileExpression(final String xpath) {
235235
synchronized (compiled) {
236236
if (USE_SOFT_CACHE) {
237237
expr = null;
238-
final SoftReference ref = (SoftReference) compiled.get(xpath);
238+
final SoftReference<Expression> ref = (SoftReference) compiled.get(xpath);
239239
if (ref != null) {
240-
expr = (Expression) ref.get();
240+
expr = ref.get();
241241
}
242242
} else {
243243
expr = (Expression) compiled.get(xpath);
@@ -250,16 +250,16 @@ private Expression compileExpression(final String xpath) {
250250
synchronized (compiled) {
251251
if (USE_SOFT_CACHE) {
252252
if (cleanupCount++ >= CLEANUP_THRESHOLD) {
253-
final Iterator it = compiled.entrySet().iterator();
253+
final Iterator<Entry<String, Object>> it = compiled.entrySet().iterator();
254254
while (it.hasNext()) {
255-
final Entry me = (Entry) it.next();
256-
if (((SoftReference) me.getValue()).get() == null) {
255+
final Entry<String, ?> me = it.next();
256+
if (((SoftReference<Expression>) me.getValue()).get() == null) {
257257
it.remove();
258258
}
259259
}
260260
cleanupCount = 0;
261261
}
262-
compiled.put(xpath, new SoftReference(expr));
262+
compiled.put(xpath, new SoftReference<>(expr));
263263
} else {
264264
compiled.put(xpath, expr);
265265
}

0 commit comments

Comments
 (0)