ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kev Jackson <kevin.jack...@it.fts-vn.com>
Subject FileUtils.close()
Date Tue, 21 Jun 2005 10:01:08 GMT
This came up before, but I forgot what the consensus was (been a while 
since I've had time to play with Ant).  Whenever FileUtils.close() is 
used, any resulting exceptions are swallowed and no logging is 
performed.  I'd like to propose that instead of this "silent death" for 
close, that there is instead a record of what happened, but that the 
record is voluntary

--FileUtils
    /**
     * Close a stream without throwing any exception.
     * Record message on tasks log for tracability
     * @param device stream, can be null
     * @param user task calling this method
     * @param message message to log in case of IOException
     */
    public static void close(OutputStream device, Task user, String 
message) {
        if (device != null) {
            try {
                device.close();
            } catch (IOException ioex) {
                user.log(message);
            }
        }
    }

In use...

    } finally {
          FileUtils.close(os, this, "Failed to close output stream 
during method foo");
    }

thoughts/abuse??
Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message