diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index d4bf771..a3218d8 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -320,7 +320,7 @@ public final class IntrospectionHelper { * * @return a helper for the specified class */ - public static synchronized IntrospectionHelper getHelper(final Class c) { + public static IntrospectionHelper getHelper(final Class c) { return getHelper(null, c); } @@ -337,7 +337,7 @@ public final class IntrospectionHelper { * * @return a helper for the specified class */ - public static synchronized IntrospectionHelper getHelper(final Project p, final Class c) { + public static IntrospectionHelper getHelper(final Project p, final Class c) { IntrospectionHelper ih = HELPERS.get(c.getName()); // If a helper cannot be found, or if the helper is for another // classloader, create a new IH @@ -346,7 +346,13 @@ public final class IntrospectionHelper { if (p != null) { // #30162: do *not* cache this if there is no project, as we // cannot guarantee that the cache will be cleared. - HELPERS.put(c.getName(), ih); + synchronized (HELPERS) { + IntrospectionHelper oh = HELPERS.get(c.getName()); + if (oh != null) + ih = oh; + else + HELPERS.put(c.getName(), ih); + } } } return ih;