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

Stuart Marks stuart.marks at oracle.com
Thu Feb 10 13:13:25 PST 2011


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