Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#147 trycatch task swallows exception if there is not catch eleme

closed-fixed
nobody
logic (23)
5
2006-08-09
2005-08-19
Anonymous
No

I am using version 1.0b2.

If you setup trycatch like this:

<trycatch>
<try>
Some ant tasks
</try>
<finally>
Some other ant task
</finally>
</trycatch>

If there is an exception in the try block the finally
block will be executed but then the build will complete
successfully.

It appears that problem with the code is here:

/**
* The heart of the task.
*/
public void execute() throws BuildException {
if (tryTasks == null) {
throw new BuildException("A nested <try>
element is required");
}

try {
tryTasks.perform();
} catch (Throwable e) {
if (property != null) {
/*
* Using setProperty instead of
setNewProperty to
* be able to compile with Ant < 1.5.
*/
getProject().setProperty(property,
e.getMessage());
}

if (reference != null) {
getProject().addReference(reference, e);
}

boolean executed = false;
Enumeration blocks = catchBlocks.elements();
while (blocks.hasMoreElements() && !
executed) {
CatchBlock cb =
(CatchBlock)blocks.nextElement();
executed = cb.execute(e);
}

!!! //There should be an exception right here !!!

} finally {
if (finallyTasks != null) {
finallyTasks.perform();
}
}
}

Thanks!

Discussion

  • ant build file that demonstrates the problem.

     
    Attachments
  • Matt Inger
    Matt Inger
    2006-08-09

    Logged In: YES
    user_id=83032

    This is no longer a valid bug, as it was resolved during
    code cleanup.

     
  • Matt Inger
    Matt Inger
    2006-08-09

    • status: open --> closed-fixed