ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Glick <jesse.gl...@sun.com>
Subject Re: FileUtils.close()
Date Wed, 22 Jun 2005 23:33:34 GMT
Kev Jackson wrote:
> This came up before, but I forgot what the consensus was

Not sure there was a consensus (or that anyone cared enough).

> 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

That's one option. Another is to just assume the worst and throw the 
IOException from whatever.close() - i.e. don't use FileUtil.close at 
all. This idiom is

public void doWhatever() throws IOException {
     InputStream is = ...;
     try {
         // read from is...
     } finally {
         is.close();
     }
}

or alternatively

try {
     InputStream is = ...;
     try {
         // read from is...
     } finally {
         is.close();
     }
} catch (IOException e) {
     // handle...
}

-J.

-- 
jesse.glick@sun.com   x22801   netbeans.org   ant.apache.org


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


Mime
View raw message