From 41e6b2c7ee45bf308d467055711172bfffdf8a01 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Thu, 16 Aug 2018 16:31:42 +0530 Subject: [PATCH 1/2] Update the EmailTaskTest to ensure that the mail task does indeed fail in expected cases --- .../org/apache/tools/ant/taskdefs/email/EmailTaskTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java index a77fc92db..200ebacbd 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java @@ -47,6 +47,7 @@ public class EmailTaskTest { public void test1() { try { buildRule.executeTarget("test1"); + Assert.fail("Execution of mail task was expected to fail"); } catch (BuildException e) { // assert it's the expected one if (!e.getMessage().equals("SMTP auth only possible with MIME mail")) { @@ -62,6 +63,7 @@ public class EmailTaskTest { public void test2() { try { buildRule.executeTarget("test2"); + Assert.fail("Execution of mail task was expected to fail"); } catch (BuildException e) { // assert it's the expected one if (!e.getMessage().equals("SSL and STARTTLS only possible with MIME mail")) { From 21de7add9a935c4ae61716cce269f58db26e949a Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Sat, 25 Aug 2018 17:13:31 +0530 Subject: [PATCH 2/2] bz-62655 throw a BuildException from augment task if the id attribute isn't specified or if the value points to an unknown reference --- src/main/org/apache/tools/ant/taskdefs/AugmentReference.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java b/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java index 637795f37..7402d4482 100644 --- a/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java +++ b/src/main/org/apache/tools/ant/taskdefs/AugmentReference.java @@ -17,6 +17,7 @@ */ package org.apache.tools.ant.taskdefs; +import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.RuntimeConfigurable; import org.apache.tools.ant.Task; @@ -48,7 +49,7 @@ public class AugmentReference extends Task implements TypeAdapter { log("project reference " + id + "=" + String.valueOf(result), Project.MSG_DEBUG); return result; } - throw new IllegalStateException("Unknown reference \"" + id + "\""); + throw new BuildException("Unknown reference \"" + id + "\""); } /** @@ -63,7 +64,7 @@ public class AugmentReference extends Task implements TypeAdapter { RuntimeConfigurable wrapper = getWrapper(); id = wrapper.getId(); if (id == null) { - throw new IllegalStateException(getTaskName() + " attribute 'id' unset"); + throw new BuildException(getTaskName() + " attribute 'id' unset"); } wrapper.setAttribute("id", null); wrapper.removeAttribute("id");