ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: svn commit: r557025 - /ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
Date Tue, 17 Jul 2007 19:00:49 GMT
I think that the cloning is not complete.
There is a patch in http://issues.apache.org/bugzilla/attachment.cgi?id=18662
that tries to get a clone of this horrible class. I did not apply it
at the time as I was scared of the potential bugs.
Peter


On 7/17/07, mbenson@apache.org <mbenson@apache.org> wrote:
> Author: mbenson
> Date: Tue Jul 17 11:55:42 2007
> New Revision: 557025
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=557025
> Log:
> Cloneable; update Delegate order on re-add
>
> Modified:
>     ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
>
> Modified: ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java?view=diff&rev=557025&r1=557024&r2=557025
> ==============================================================================
> --- ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java (original)
> +++ ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java Tue Jul 17 11:55:42
2007
> @@ -57,7 +57,7 @@
>   *
>   * @since Ant 1.6
>   */
> -public class PropertyHelper {
> +public class PropertyHelper implements Cloneable {
>
>      /**
>       * Marker interface for a PropertyHelper delegate.
> @@ -198,6 +198,7 @@
>       *  least for non-dynamic properties)
>       *
>       * @param next the next property helper in the chain.
> +     * @deprecated
>       */
>      public void setNext(PropertyHelper next) {
>          this.next = next;
> @@ -207,6 +208,7 @@
>       * Get the next property helper in the chain.
>       *
>       * @return the next property helper.
> +     * @deprecated
>       */
>      public PropertyHelper getNext() {
>          return next;
> @@ -707,7 +709,6 @@
>       *             the return value is also <code>null</code>.
>       * @return the property value, or <code>null</code> for no match
>       *         or if a <code>null</code> name is provided.
> -     * @deprecated namespaces are unnecessary.
>       */
>      public synchronized Object getUserProperty(String name) {
>          if (name == null) {
> @@ -909,9 +910,10 @@
>                  list = new ArrayList();
>                  delegates.put(key, list);
>              }
> -            if (!list.contains(delegate)) {
> -                list.add(0, delegate);
> +            if (list.contains(delegate)) {
> +                list.remove(delegate);
>              }
> +            list.add(0, delegate);
>          }
>      }
>
> @@ -939,6 +941,21 @@
>              if (Delegate.class.isAssignableFrom(c[i]) && !Delegate.class.equals(c[i]))
{
>                  result.add(c[i]);
>              }
> +        }
> +        return result;
> +    }
> +
> +    /**
> +     * Make a clone of this PropertyHelper.
> +     * @return the cloned PropertyHelper.
> +     * @since Ant 1.8
> +     */
> +    public Object clone() {
> +        PropertyHelper result;
> +        try {
> +            result = (PropertyHelper) super.clone();
> +        } catch (CloneNotSupportedException e) {
> +            throw new BuildException(e);
>          }
>          return result;
>      }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message