From 89373a58c6e1fe5d0e54bd20c6ae46bf4f577c02 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Tue, 24 Jul 2007 22:21:59 +0000 Subject: [PATCH] defer call to delegateIteratorToList() git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@559243 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/types/Path.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index 1a97eee58..abf4dce6d 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -142,7 +142,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { } - private final boolean preserveBC = delegateIteratorToList(); + private Boolean preserveBC; private Union union = null; @@ -687,7 +687,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { return ((Path) getCheckedRef()).iterator(); } dieOnCircularReference(); - if (preserveBC) { + if (getPreserveBC()) { return new FileResourceIterator(null, list()); } return union == null ? EMPTY_ITERATOR @@ -726,8 +726,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { * The default behavior of this method is to return true for any subclass * that implements list(); this can, of course, be avoided by overriding * this method to return false. It is not expected that the result of this - * method should change over time; thus it is called a single time during instance - * initialization. + * method should change over time, thus it is called only once. * @return true if iterator() should delegate to list(). */ protected boolean delegateIteratorToList() { @@ -742,4 +741,11 @@ public class Path extends DataType implements Cloneable, ResourceCollection { return false; } } + + private synchronized boolean getPreserveBC() { + if (preserveBC == null) { + preserveBC = delegateIteratorToList() ? Boolean.TRUE : Boolean.FALSE; + } + return preserveBC.booleanValue(); + } }