Hi Mark,
2015-07-08 21:53 GMT+03:00 <[email protected]>:
>
> Author: markt
> Date: Wed Jul 8 18:53:44 2015
> New Revision: 1689935
>
> URL: http://svn.apache.org/r1689935
> Log:
> Use try-with-resources
>
> Modified:
> tomcat/trunk/java/org/apache/catalina/ant/DeployTask.java
>
> Modified: tomcat/trunk/java/org/apache/catalina/ant/DeployTask.java
> URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/DeployTask.java?rev=1689935&r1=1689934&r2=1689935&view=diff
>
==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/ant/DeployTask.java (original)
> +++ tomcat/trunk/java/org/apache/catalina/ant/DeployTask.java Wed Jul 8
18:53:44 2015
> @@ -153,9 +153,7 @@ public class DeployTask extends Abstract
> throw new BuildException(e);
> }
> } else {
> - FileInputStream fsInput = null;
> - try {
> - fsInput = new FileInputStream(war);
> + try (FileInputStream fsInput = new FileInputStream(war))
{
The stream must stay opened.
We need to close it only if there is an Exception.
Regards,
Violeta
> long size = fsInput.getChannel().size();
>
> if (size > Integer.MAX_VALUE)
> @@ -167,13 +165,6 @@ public class DeployTask extends Abstract
> stream = new BufferedInputStream(fsInput, 1024);
>
> } catch (IOException e) {
> - if (fsInput != null) {
> - try {
> - fsInput.close();
> - } catch (IOException ioe) {
> - // Ignore
> - }
> - }
> throw new BuildException(e);
> }
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>