From 045ec77262f81c2ce0a6b58bd5816711577af5ed Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 27 Jul 2011 14:08:00 +0000 Subject: [PATCH] restore RCW id once augment has performed its job so it can be reused by other targets. PR 50894 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1151473 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ .../tools/ant/taskdefs/AugmentReference.java | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/WHATSNEW b/WHATSNEW index 13c10002e..6ccdfc706 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -73,6 +73,10 @@ Fixed bugs: * didn't work properly when working on resource collections. Bugzilla Report 51462. + * cause a NullPointerException if it was used in a target + that was invoked by multiple targets from the command line. + Bugzilla Report 50894. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java b/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java index 4ebe40ccf..ec761c144 100644 --- a/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java +++ b/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java @@ -70,4 +70,26 @@ public class AugmentReference extends Task implements TypeAdapter { wrapper.setElementTag("augmented reference \"" + id + "\""); } } + + /** + * Overridden to restore the wrapper once it is no longer needed. + * @since Ant 1.8.3 + */ + public void execute() { + restoreWrapperId(); + } + + /** + * Needed if two different targets reuse the same instance. + * @see https://issues.apache.org/bugzilla/show_bug.cgi?id=50894 + */ + private synchronized void restoreWrapperId() { + if (id != null) { + log("restoring augment wrapper " + id, Project.MSG_DEBUG); + RuntimeConfigurable wrapper = getWrapper(); + wrapper.setAttribute("id", id); + wrapper.setElementTag(getTaskName()); + } + } + }