From 6d13fceec8ddb1813346fcf4e3f95b9083e4fd77 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 10 Feb 2010 05:37:30 +0000 Subject: [PATCH] filesmatch throws NPE when comparing texts and the second one has fewer lines. PR 48715 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@908356 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 5 ++ .../apache/tools/ant/util/ResourceUtils.java | 3 + .../taskdefs/condition/filesmatch-test.xml | 57 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 src/tests/antunit/taskdefs/condition/filesmatch-test.xml diff --git a/WHATSNEW b/WHATSNEW index 6e1e4dacd..8b787bafa 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -13,6 +13,11 @@ Fixed bugs: maps. Bugzilla Report 48310. + * The filesmatch condition threw a NullPointerException when + comparing text files and the second file contained fewer lines than + the first one. + Bugzilla Report 48715. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/util/ResourceUtils.java b/src/main/org/apache/tools/ant/util/ResourceUtils.java index c2e03168e..d269ad4cb 100644 --- a/src/main/org/apache/tools/ant/util/ResourceUtils.java +++ b/src/main/org/apache/tools/ant/util/ResourceUtils.java @@ -666,6 +666,9 @@ public class ResourceUtils { while (expected != null) { String actual = in2.readLine(); if (!expected.equals(actual)) { + if (actual == null) { + return 1; + } return expected.compareTo(actual); } expected = in1.readLine(); diff --git a/src/tests/antunit/taskdefs/condition/filesmatch-test.xml b/src/tests/antunit/taskdefs/condition/filesmatch-test.xml new file mode 100644 index 000000000..67e7c00f6 --- /dev/null +++ b/src/tests/antunit/taskdefs/condition/filesmatch-test.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +