please review 7018392, update URLJarFile.java to use try-with-resources

Chris Hegarty chris.hegarty at oracle.com
Fri Feb 11 03:06:59 PST 2011


Stuart,

Thanks for doing this. The new code looks much cleaner. Please go ahead 
and push this change.

-Chris.

On 10/02/2011 21:13, Stuart Marks wrote:
> Webrev is here:
>
> http://cr.openjdk.java.net/~smarks/reviews/7018392/webrev.0/
>
> This uses try-with-resources to close the InputStream reliably, and it
> uses Files.copy() to avoid dealing directly with an OutputStream.
>
> We had also discussed the circumstances when the temp file should be
> removed. Instead of using a boolean to keep track of whether the
> operation had completed successfully, I created a local variable to
> contain the JarFile instance. If it's null and the finally block is
> reached, we know an error has occurred so we attempt to remove the temp
> file.
>
> I also moved the return statement outside the inner try-block. I could
> have left it inside but I found it quite counterintuitive to read, since
> the finally block is executed before the method actually returns.
>
> Thanks!
>
> s'marks
>



More information about the net-dev mailing list