This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 294d9ab Fix a couple of minor resource leaks 294d9ab is described below commit 294d9ab5911be01ca9541d6b94b3bc762b2c4623 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Apr 17 10:33:59 2020 +0100 Fix a couple of minor resource leaks I was experimenting with Eclipse "potential resource leak" warnings and found these. There are lots more but quite a few look to be false positives. --- java/org/apache/catalina/ant/AbstractCatalinaTask.java | 4 +++- java/org/apache/catalina/ant/DeployTask.java | 15 ++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/java/org/apache/catalina/ant/AbstractCatalinaTask.java b/java/org/apache/catalina/ant/AbstractCatalinaTask.java index 0d30fe2..c1457af 100644 --- a/java/org/apache/catalina/ant/AbstractCatalinaTask.java +++ b/java/org/apache/catalina/ant/AbstractCatalinaTask.java @@ -319,7 +319,9 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask { hconn.connect(); // Swallow response message - IOTools.flow(hconn.getInputStream(), null); + try (InputStream is = hconn.getInputStream()) { + IOTools.flow(is, null); + } } diff --git a/java/org/apache/catalina/ant/DeployTask.java b/java/org/apache/catalina/ant/DeployTask.java index 777f015..a4c54fc 100644 --- a/java/org/apache/catalina/ant/DeployTask.java +++ b/java/org/apache/catalina/ant/DeployTask.java @@ -23,6 +23,7 @@ import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; +import java.nio.channels.FileChannel; import java.util.regex.Pattern; import org.apache.tools.ant.BuildException; @@ -139,19 +140,11 @@ public class DeployTask extends AbstractCatalinaCommandTask { throw new BuildException(e); } } else { - FileInputStream fsInput = null; - try { - fsInput = new FileInputStream(war); - contentLength = fsInput.getChannel().size(); + try (FileInputStream fsInput = new FileInputStream(war); + FileChannel fsChannel = fsInput.getChannel()) { + contentLength = fsChannel.size(); 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: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org