This is an automated email from the ASF dual-hosted git repository.
mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/master by this push:
new 8f57984 avoid unnecessary work
8f57984 is described below
commit 8f57984b1b4f80d960e247165fc646a16e256d7d
Author: Matt Benson <[email protected]>
AuthorDate: Sat Feb 5 14:39:18 2022 -0600
avoid unnecessary work
---
.../org/apache/tools/ant/RuntimeConfigurable.java | 15 +++---
src/main/org/apache/tools/ant/UnknownElement.java | 60 +++++++++++-----------
2 files changed, 39 insertions(+), 36 deletions(-)
diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java
b/src/main/org/apache/tools/ant/RuntimeConfigurable.java
index bf82fb7..001c9d8 100644
--- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java
+++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java
@@ -488,14 +488,15 @@ public class RuntimeConfigurable implements Serializable {
return;
}
- // Configure the object
- Object target = (wrappedObject instanceof TypeAdapter)
- ? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject;
-
- IntrospectionHelper ih =
- IntrospectionHelper.getHelper(p, target.getClass());
- ComponentHelper componentHelper =
ComponentHelper.getComponentHelper(p);
if (attributeMap != null) {
+ // Configure the object
+ Object target = (wrappedObject instanceof TypeAdapter)
+ ? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject;
+
+ IntrospectionHelper ih =
+ IntrospectionHelper.getHelper(p, target.getClass());
+ ComponentHelper componentHelper =
ComponentHelper.getComponentHelper(p);
+
for (Map.Entry<String, Object> entry : attributeMap.entrySet()) {
String name = entry.getKey();
// skip restricted attributes such as if:set
diff --git a/src/main/org/apache/tools/ant/UnknownElement.java
b/src/main/org/apache/tools/ant/UnknownElement.java
index fce4466..0bb755a 100644
--- a/src/main/org/apache/tools/ant/UnknownElement.java
+++ b/src/main/org/apache/tools/ant/UnknownElement.java
@@ -339,6 +339,10 @@ public class UnknownElement extends Task {
Object parent,
RuntimeConfigurable parentWrapper)
throws BuildException {
+
+ if (children == null || children.isEmpty()) {
+ return;
+ }
if (parent instanceof TypeAdapter) {
parent = ((TypeAdapter) parent).getProxy();
}
@@ -347,38 +351,36 @@ public class UnknownElement extends Task {
Class<?> parentClass = parent.getClass();
IntrospectionHelper ih = IntrospectionHelper.getHelper(getProject(),
parentClass);
- if (children != null) {
- Iterator<UnknownElement> it = children.iterator();
- for (int i = 0; it.hasNext(); i++) {
- RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
- UnknownElement child = it.next();
- try {
- if (!childWrapper.isEnabled(child)) {
- if (ih.supportsNestedElement(
- parentUri, ProjectHelper.genComponentName(
- child.getNamespace(), child.getTag()))) {
- continue;
- }
- // fall tru and fail in handlechild (unsupported
element)
+ Iterator<UnknownElement> it = children.iterator();
+ for (int i = 0; it.hasNext(); i++) {
+ RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
+ UnknownElement child = it.next();
+ try {
+ if (!childWrapper.isEnabled(child)) {
+ if (ih.supportsNestedElement(
+ parentUri, ProjectHelper.genComponentName(
+ child.getNamespace(), child.getTag()))) {
+ continue;
}
- if (!handleChild(
- parentUri, ih, parent, child, childWrapper)) {
- if (!(parent instanceof TaskContainer)) {
- ih.throwNotSupported(getProject(), parent,
- child.getTag());
- } else {
- // a task container - anything could happen - just
add the
- // child to the container
- TaskContainer container = (TaskContainer) parent;
- container.addTask(child);
- }
+ // fall thru and fail in handlechild (unsupported element)
+ }
+ if (!handleChild(
+ parentUri, ih, parent, child, childWrapper)) {
+ if (!(parent instanceof TaskContainer)) {
+ ih.throwNotSupported(getProject(), parent,
+ child.getTag());
+ } else {
+ // a task container - anything could happen - just add
the
+ // child to the container
+ TaskContainer container = (TaskContainer) parent;
+ container.addTask(child);
}
- } catch (UnsupportedElementException ex) {
- throw new BuildException(
- parentWrapper.getElementTag()
- + " doesn't support the nested \"" + ex.getElement()
- + "\" element.", ex);
}
+ } catch (UnsupportedElementException ex) {
+ throw new BuildException(
+ parentWrapper.getElementTag()
+ + " doesn't support the nested \"" + ex.getElement()
+ + "\" element.", ex);
}
}
}