Return-Path: Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 80341 invoked by uid 500); 21 Jul 2003 10:10:09 -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 80329 invoked by uid 500); 21 Jul 2003 10:10:08 -0000 Received: (qmail 80325 invoked from network); 21 Jul 2003 10:10:08 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 21 Jul 2003 10:10:08 -0000 Received: (qmail 47927 invoked by uid 1539); 21 Jul 2003 10:10:07 -0000 Date: 21 Jul 2003 10:10:07 -0000 Message-ID: <20030721101007.47926.qmail@icarus.apache.org> From: peterreilly@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs TypedefTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N peterreilly 2003/07/21 03:10:07 Modified: src/main/org/apache/tools/ant ComponentHelper.java src/etc/testcases/taskdefs typedef.xml src/testcases/org/apache/tools/ant/taskdefs TypedefTest.java Log: Fix for NPE reported by Nick Chalko. When overriding a definition the code did not check if the old (or new) definitions classes existed Revision Changes Path 1.19 +28 -2 ant/src/main/org/apache/tools/ant/ComponentHelper.java Index: ComponentHelper.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/ComponentHelper.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ComponentHelper.java 6 Jul 2003 09:57:34 -0000 1.18 +++ ComponentHelper.java 21 Jul 2003 10:10:06 -0000 1.19 @@ -587,9 +587,33 @@ } - /** return true if the two definitions are the same */ + /** + * check if definition is a valid definition - it + * may be a definition of an optional task that + * does not exist + * @param def the definition to test + * @return true if exposed type of definition is present + */ + private boolean validDefinition(AntTypeDefinition def) { + if (def.getTypeClass(project) == null + || def.getExposedClass(project) == null) { + return false; + } + return true; + } + + /** + * check if two definitions are the same + * @param def the new definition + * @param old the old definition + * @return true if the two definitions are the same + */ private boolean sameDefinition( AntTypeDefinition def, AntTypeDefinition old) { + if (!validDefinition(def) || !validDefinition(old)) { + return validDefinition(def) == validDefinition(old); + } + if (!(old.getTypeClass(project).equals(def.getTypeClass(project)))) { return false; } @@ -600,9 +624,11 @@ return true; } + /** * update the component definition table with a new or * modified definition. + * @param def the definition to update or insert */ private void updateDataTypeDefinition(AntTypeDefinition def) { String name = def.getName(); @@ -615,7 +641,7 @@ return; } Class oldClass = antTypeTable.getExposedClass(name); - if (Task.class.isAssignableFrom(oldClass)) { + if (oldClass != null && Task.class.isAssignableFrom(oldClass)) { int logLevel = Project.MSG_WARN; if (def.getClassName().equals(old.getClassName()) && def.getClassLoader() == old.getClassLoader()) { 1.2 +7 -0 ant/src/etc/testcases/taskdefs/typedef.xml Index: typedef.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/typedef.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- typedef.xml 9 Nov 2001 15:48:11 -0000 1.1 +++ typedef.xml 21 Jul 2003 10:10:06 -0000 1.2 @@ -46,4 +46,11 @@ + + + + + hi + 1.6 +8 -1 ant/src/testcases/org/apache/tools/ant/taskdefs/TypedefTest.java Index: TypedefTest.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/TypedefTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TypedefTest.java 7 Mar 2003 11:23:11 -0000 1.5 +++ TypedefTest.java 21 Jul 2003 10:10:07 -0000 1.6 @@ -104,4 +104,11 @@ ref.getClass().getName()); } + /** + * test to make sure that one can define a not present + * optional type twice and then have a valid definition. + */ + public void testDoubleNotPresent() { + expectLogContaining("double-notpresent", "hi"); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org