https://issues.apache.org/bugzilla/show_bug.cgi?id=49891

Christian Hartmann <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
                   |                            |e

--- Comment #6 from Christian Hartmann <[email protected]> ---
Created attachment 31280
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31280&action=edit
Adding checks in addAlmostAll

I came across the same problem and think I found the behaviour-changing cause
between 1.7.1 and 1.8 (till 1.9.3).

In 1.8.0 a new method addAlmostAll() for copying properties was introduced in
Ant.java. In the past that task was delegated to PropertyHelper.java and its
copyXYProperties() methods. These methods check whether the target project
already contains the property and don't override existing values. AFAIK these
checks are missing in addAlmostAll().

Here's the implementation in copyUserProperties() with it's containsKey-check:

    public void copyUserProperties(Project other) {
        //avoid concurrent modification:
        synchronized (userProperties) {
            Enumeration<String> e = userProperties.keys();
            while (e.hasMoreElements()) {
                Object arg = e.nextElement();
                if (inheritedProperties.containsKey(arg)) {
                    continue;
                }
                Object value = userProperties.get(arg);
                other.setUserProperty(arg.toString(), value.toString());
            }
        }
    }

And here's the snippet from addAlmostAll()

    ...
    } else if (type == PropertyType.USER) {
        newProject.setUserProperty(key, value);
    }
    ...

BTW, you can produce the same effect in 1.7.1, if you remove "continue".

The attached patch adds the same checks in addAlmostAll():

    } else if (type == PropertyType.USER) {
        if
(!PropertyHelper.getPropertyHelper(this.getProject()).getInheritedProperties().containsKey(key))
{
            newProject.setUserProperty(key, value);
        }
    }


I am using this patch for several months without any (other) problem, but
perhaps there are effects I don't see.

Here's the output of your example with the patched version:

level-1:

level-2:
     [echo] Expecting 'bravo', actual 'bravo'

level-3:
     [echo] Expecting 'charlie', actual 'charlie'

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to