diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index 44c973b4f..7654a7662 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -1585,24 +1585,26 @@ public final class IntrospectionHelper { if (definitions == null) { return null; } - for (int i = 0; i < definitions.size(); ++i) { - AntTypeDefinition d = (AntTypeDefinition) definitions.get(i); - Class exposedClass = d.getExposedClass(helper.getProject()); - if (exposedClass == null) { - continue; - } - Method method = findMatchingMethod(exposedClass, methods); - if (method == null) { - continue; - } - if (matchedDefinitionClass != null) { - throw new BuildException( - "ambiguous: restricted definitions for " - + componentName + " " - + matchedDefinitionClass + " and " + exposedClass); + synchronized (definitions) { + for (int i = 0; i < definitions.size(); ++i) { + AntTypeDefinition d = (AntTypeDefinition) definitions.get(i); + Class exposedClass = d.getExposedClass(helper.getProject()); + if (exposedClass == null) { + continue; + } + Method method = findMatchingMethod(exposedClass, methods); + if (method == null) { + continue; + } + if (matchedDefinitionClass != null) { + throw new BuildException( + "ambiguous: restricted definitions for " + + componentName + " " + + matchedDefinitionClass + " and " + exposedClass); + } + matchedDefinitionClass = exposedClass; + definition = d; } - matchedDefinitionClass = exposedClass; - definition = d; } return definition; }