From b49a9ef6f2d3b1fd599772502b76d2e4376bd660 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Wed, 5 Jul 2006 16:47:56 +0000 Subject: [PATCH] setPrefix javadoc claimed null or empty prefix would be ignored; instead an error was thrown. Bugzilla report 39954. Submitted by Ivan Ivanov. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@419276 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 5 ++++- .../testcases/taskdefs/optional/echoproperties.xml | 4 ++++ .../tools/ant/taskdefs/optional/EchoProperties.java | 12 +++++++----- .../ant/taskdefs/optional/EchoPropertiesTest.java | 6 +++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 413f07f7a..b788c825f 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -238,9 +238,12 @@ Fixed bugs: * If the class invoked by the task threw a ClassNotFoundException, this was misinterpreted as the specified class itself not being found. +* setPrefix javadoc claimed null or empty prefix would be + ignored; instead an error was thrown. Bugzilla report 39954. + Other changes: -------------- -* took in bugzilla report 39320. +* Took in bugzilla report 39320. * Improve compatibility with GNU Classpath and java versions prior to 1.5. Bugzilla 39027. diff --git a/src/etc/testcases/taskdefs/optional/echoproperties.xml b/src/etc/testcases/taskdefs/optional/echoproperties.xml index 3466642cf..9458b5224 100644 --- a/src/etc/testcases/taskdefs/optional/echoproperties.xml +++ b/src/etc/testcases/taskdefs/optional/echoproperties.xml @@ -12,6 +12,10 @@ + + + + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java index f392cbbd7..2461bfa71 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005 The Apache Software Foundation + * Copyright 2002-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -174,10 +174,12 @@ public class EchoProperties extends Task { *@param prefix The new prefix value */ public void setPrefix(String prefix) { - PropertySet ps = new PropertySet(); - ps.setProject(getProject()); - ps.appendPrefix(prefix); - addPropertyset(ps); + if (prefix != null && prefix.length() != 0) { + PropertySet ps = new PropertySet(); + ps.setProject(getProject()); + ps.appendPrefix(prefix); + addPropertyset(ps); + } } /** diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java index 152f2b2ce..0dd06c6e9 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 The Apache Software Foundation + * Copyright 2000-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,10 @@ public class EchoPropertiesTest extends BuildFileTest { expectLogContaining("testEchoToLog", "test.property="+TEST_VALUE); } + public void testEchoWithEmptyPrefixToLog() { + expectLogContaining("testEchoWithEmptyPrefixToLog", "test.property="+TEST_VALUE); + } + public void testReadBadFile() { expectBuildExceptionContaining( "testReadBadFile",