From a6429c6aa1a713c98528da55059afe9efc2ada59 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Wed, 7 Feb 2018 13:01:54 +0530 Subject: [PATCH 1/2] Fix broken link in junitreport manual --- manual/Tasks/junitreport.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manual/Tasks/junitreport.html b/manual/Tasks/junitreport.html index fea85e57b..971201431 100644 --- a/manual/Tasks/junitreport.html +++ b/manual/Tasks/junitreport.html @@ -171,12 +171,12 @@ These tags can pass XSL parameters to the stylesheet.

classpath

Since Ant 1.9.5. -Like for the XSLT task, +Like for the XSLT task, a nested <classpath> will be used to load the processor.

factory

Since Ant 1.9.5. -Like for the XSLT task, +Like for the XSLT task, a nested <factory> can be used to specify factory settings.

From e3f5250916dc0d9493b45b2d8fc6efe3a0fd9fda Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Fri, 9 Feb 2018 12:36:54 +0530 Subject: [PATCH 2/2] bz-62076 Make IdentityMapper follow the "mapFileName" API contract to avoid NPE when it deals with a non-matching source file name --- WHATSNEW | 7 +++++++ src/etc/testcases/taskdefs/pathconvert.xml | 18 ++++++++++++++++++ .../apache/tools/ant/util/IdentityMapper.java | 11 ++++++++++- .../tools/ant/taskdefs/PathConvertTest.java | 11 +++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index 17e68ca2b..2d4b6f11d 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -1,6 +1,13 @@ Changes from Ant 1.9.10 TO Ant 1.9.11 ===================================== +Fixed bugs: +----------- + + * Fixed NullPointerException when a mappedresource is used in pathconvert + Bugzilla Report 62076 + + Changes from Ant 1.9.9 TO Ant 1.9.10 ==================================== diff --git a/src/etc/testcases/taskdefs/pathconvert.xml b/src/etc/testcases/taskdefs/pathconvert.xml index 1cdcc8cda..5a1cdf74b 100644 --- a/src/etc/testcases/taskdefs/pathconvert.xml +++ b/src/etc/testcases/taskdefs/pathconvert.xml @@ -17,6 +17,8 @@ --> + + @@ -39,4 +41,20 @@ + + + + + + + + + + + + + + + diff --git a/src/main/org/apache/tools/ant/util/IdentityMapper.java b/src/main/org/apache/tools/ant/util/IdentityMapper.java index 22c6c7eae..18a31e516 100644 --- a/src/main/org/apache/tools/ant/util/IdentityMapper.java +++ b/src/main/org/apache/tools/ant/util/IdentityMapper.java @@ -46,7 +46,16 @@ public class IdentityMapper implements FileNameMapper { * @param sourceFileName the name to map. * @return the source filename in a one-element array. */ - public String[] mapFileName(String sourceFileName) { + @Override + public String[] mapFileName(final String sourceFileName) { + if (sourceFileName == null) { + // The FileNameMapper#mapFileName contract states that: + // "if the given rule doesn't apply to the source file, + // implementation must return null" + // we consider a null source file name as non-matching and + // hence return null + return null; + } return new String[] {sourceFileName}; } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PathConvertTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PathConvertTest.java index 41096b61c..f29dc12b9 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PathConvertTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PathConvertTest.java @@ -57,6 +57,17 @@ public class PathConvertTest { buildRule.executeTarget("testnotargetos"); } + /** + * Tests that if a {@code mappedresource}, that excludes certain resources, is used in a {@code pathconvert}, + * then it doesn't lead to a {@link NullPointerException}. + * + * @see bz-62076 for more details + */ + @Test + public void testNonMatchingMapper() { + buildRule.executeTarget("test-nonmatching-mapper"); + } + private void test(String target) { buildRule.executeTarget(target); assertEquals("test#" + BUILD_FILENAME, buildRule.getProject().getProperty("result"));