Bug 62324 - <delete> task issues missing-directory diagnostic twice when "-d" and 'quiet=true'
Summary: <delete> task issues missing-directory diagnostic twice when "-d" and 'quiet=...
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.10.3
Hardware: PC All
: P2 trivial (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-24 18:57 UTC by freakoftheindustry
Modified: 2018-06-18 19:21 UTC (History)
1 user (show)



Attachments
A test case (195 bytes, text/xml)
2018-06-03 09:49 UTC, Gintas Grigelionis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description freakoftheindustry 2018-04-24 18:57:21 UTC
Given
    <property file="this_sets_all_the_'generated.*'_stuff.properties"/>
    ....
    <property name="objdir" location="${generated.objdir}" relative="true"/>

and a cleanup target including a task like
    <delete includeEmptyDirs="true">
      <fileset dir="${objdir}"/>
      .... lots of other filesets ....
    </delete>

I wanted to demonstrate to a new developer that running the cleanup target when the "generated-stuff" properties file was missing, didn't really do anything but was "safe" in that it wasn't going to run amok on the filesystem, etc.  And everything was fine; we got the diagnostic:

    BUILD FAILED
    C:\example\build.xml:1234: Directory does not exist: C:\example\${generated.objdir}

Yes, the constructed pathname has the un-expanded property name inside it, "C:\example\${generated.objdir}", and that's correct behavior for Ant.  Everything still fine.

I then ran Ant with '-d' to show what <delete> was trying to do behind the scenes, and got:
[delete] Directory does not exist: C:\example\${generated.objdir}
        at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:777)
        .... stacktrace ....

Again, fine.  We then added quiet="true" attribute back to the <delete> task (I had removed it for demonstration purposes to the new boy).  And that was fine.

However, when running with "-d", the diagnostic looks like this:

[delete] Directory does not exist: C:\example\${generated.objdir}Directory does not exist: C:\example\${generated.objdir}
        at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:777)
        at org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:681)

The bug is that the diagnostic is printed twice.  And honestly even that would be fine if there were a newline between the two, but as it is, things get difficult to read once "C:\example" is replaced by an actual real-world path.

Using the web interface at git-wip-us, I looked at taskdefs/Delete.java and I still don't know why it's being printed twice.  Presumably the -d flag sets 'failonerror', I guess, but I don't know why that would case the line now at 679 to be invoked twice -- or rather, why it's being called *more than once* and simultaneously *not infinitely* if there's no break/continue out of the filesets loop after the 'handle' call.  Too difficult to figure out over the web, anyhow.  :-)

Anyhow, it's only a minor bit of noise and doesn't break anything.  Cheers!
Comment 1 Stefan Bodewig 2018-04-25 05:46:10 UTC
Hmm, strange, will need to have a closer look later.

All -d does is change the threshold of messages that will be swallowed so that everything gets logged. It might be a DEBUG message that is only visible when d is used.

The github mirror might provider a nicer UI https://github.com/apache/ant/ - but it would still be web :-)
Comment 2 Gintas Grigelionis 2018-06-03 09:49:33 UTC
Created attachment 35951 [details]
A test case
Comment 3 Gintas Grigelionis 2018-06-03 09:51:52 UTC
AFAICS, <delete> puts a message inside a BuildException, then the message and the exception are logged, and DefaultLogger does not put a separator between them.