Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 38780 invoked from network); 29 Mar 2005 21:48:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Mar 2005 21:48:02 -0000 Received: (qmail 92359 invoked by uid 500); 29 Mar 2005 21:48:01 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 92318 invoked by uid 500); 29 Mar 2005 21:48:01 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 92304 invoked by uid 500); 29 Mar 2005 21:48:00 -0000 Received: (qmail 92300 invoked by uid 99); 29 Mar 2005 21:48:00 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 29 Mar 2005 13:48:00 -0800 Received: (qmail 38748 invoked by uid 1939); 29 Mar 2005 21:47:59 -0000 Date: 29 Mar 2005 21:47:59 -0000 Message-ID: <20050329214759.38747.qmail@minotaur.apache.org> From: jglick@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs AntStructure.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N jglick 2005/03/29 13:47:59 Modified: src/main/org/apache/tools/ant IntrospectionHelper.java ProjectHelper.java UnknownElement.java src/main/org/apache/tools/ant/helper ProjectHelperImpl.java src/main/org/apache/tools/ant/taskdefs AntStructure.java Log: #30162: try to avoid a memory leak in IntrospectionHelper.getHelper(). Revision Changes Path 1.94 +14 -9 ant/src/main/org/apache/tools/ant/IntrospectionHelper.java Index: IntrospectionHelper.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v retrieving revision 1.93 retrieving revision 1.94 diff -u -r1.93 -r1.94 --- IntrospectionHelper.java 16 Dec 2004 21:11:19 -0000 1.93 +++ IntrospectionHelper.java 29 Mar 2005 21:47:59 -0000 1.94 @@ -310,12 +310,7 @@ * @return a helper for the specified class */ public static synchronized IntrospectionHelper getHelper(Class c) { - IntrospectionHelper ih = (IntrospectionHelper) helpers.get(c); - if (ih == null) { - ih = new IntrospectionHelper(c); - helpers.put(c, ih); - } - return ih; + return getHelper(null, c); } /** @@ -332,9 +327,19 @@ * @return a helper for the specified class */ public static IntrospectionHelper getHelper(Project p, Class c) { - IntrospectionHelper ih = getHelper(c); - // Cleanup at end of project - p.addBuildListener(ih); + IntrospectionHelper ih = (IntrospectionHelper) helpers.get(c); + if (ih == null) { + ih = new IntrospectionHelper(c); + if (p != null) { + // #30162: do *not* cache this if there is no project, as we + // cannot guarantee that the cache will be cleared. + helpers.put(c, ih); + } + } + if (p != null) { + // Cleanup at end of project + p.addBuildListener(ih); + } return ih; } 1.115 +3 -5 ant/src/main/org/apache/tools/ant/ProjectHelper.java Index: ProjectHelper.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/ProjectHelper.java,v retrieving revision 1.114 retrieving revision 1.115 diff -u -r1.114 -r1.115 --- ProjectHelper.java 13 Dec 2004 16:43:51 -0000 1.114 +++ ProjectHelper.java 29 Mar 2005 21:47:59 -0000 1.115 @@ -304,9 +304,7 @@ } IntrospectionHelper ih = - IntrospectionHelper.getHelper(target.getClass()); - - project.addBuildListener(ih); + IntrospectionHelper.getHelper(project, target.getClass()); for (int i = 0; i < attrs.getLength(); i++) { // reflect these into the target @@ -368,7 +366,7 @@ target = ((TypeAdapter) target).getProxy(); } - IntrospectionHelper.getHelper(target.getClass()).addText(project, + IntrospectionHelper.getHelper(project, target.getClass()).addText(project, target, text); } @@ -388,7 +386,7 @@ public static void storeChild(Project project, Object parent, Object child, String tag) { IntrospectionHelper ih - = IntrospectionHelper.getHelper(parent.getClass()); + = IntrospectionHelper.getHelper(project, parent.getClass()); ih.storeElement(project, parent, child, tag); } 1.88 +1 -1 ant/src/main/org/apache/tools/ant/UnknownElement.java Index: UnknownElement.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/UnknownElement.java,v retrieving revision 1.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- UnknownElement.java 3 Mar 2005 14:02:32 -0000 1.87 +++ UnknownElement.java 29 Mar 2005 21:47:59 -0000 1.88 @@ -320,7 +320,7 @@ String parentUri = getNamespace(); Class parentClass = parent.getClass(); - IntrospectionHelper ih = IntrospectionHelper.getHelper(parentClass); + IntrospectionHelper ih = IntrospectionHelper.getHelper(getProject(), parentClass); if (children != null) { 1.30 +1 -1 ant/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java Index: ProjectHelperImpl.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- ProjectHelperImpl.java 6 Jan 2005 12:05:09 -0000 1.29 +++ ProjectHelperImpl.java 29 Mar 2005 21:47:59 -0000 1.30 @@ -863,7 +863,7 @@ public void init(String propType, AttributeList attrs) throws SAXParseException { Class parentClass = parent.getClass(); IntrospectionHelper ih = - IntrospectionHelper.getHelper(parentClass); + IntrospectionHelper.getHelper(helperImpl.project, parentClass); try { String elementName = propType.toLowerCase(Locale.US); 1.44 +1 -1 ant/src/main/org/apache/tools/ant/taskdefs/AntStructure.java Index: AntStructure.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/AntStructure.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- AntStructure.java 9 Mar 2005 00:20:40 -0000 1.43 +++ AntStructure.java 29 Mar 2005 21:47:59 -0000 1.44 @@ -200,7 +200,7 @@ IntrospectionHelper ih = null; try { - ih = IntrospectionHelper.getHelper(element); + ih = IntrospectionHelper.getHelper(getProject(), element); } catch (Throwable t) { /* * XXX - failed to load the class properly. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org