This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 06a756d Refactor to silence some false positives leak warnings in Eclipse 06a756d is described below commit 06a756dc46de76eccff02db13f1d753980a9e869 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Mar 27 21:59:45 2020 +0000 Refactor to silence some false positives leak warnings in Eclipse --- java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java | 3 ++- java/org/apache/catalina/valves/ErrorReportValve.java | 4 +++- java/org/apache/tomcat/util/file/ConfigurationSource.java | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java index 134b6a4..53fb91f 100644 --- a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java +++ b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java @@ -85,7 +85,8 @@ public class CatalinaBaseConfigurationSource implements ConfigurationSource { f = new File(catalinaBaseFile, name); } if (f.isFile()) { - return new Resource(new FileInputStream(f), f.toURI()); + FileInputStream fis = new FileInputStream(f); + return new Resource(fis, f.toURI()); } // Try classloader diff --git a/java/org/apache/catalina/valves/ErrorReportValve.java b/java/org/apache/catalina/valves/ErrorReportValve.java index 5c5c273..c8201e2 100644 --- a/java/org/apache/catalina/valves/ErrorReportValve.java +++ b/java/org/apache/catalina/valves/ErrorReportValve.java @@ -197,7 +197,9 @@ public class ErrorReportValve extends ValveBase { if (throwable != null) { String exceptionMessage = throwable.getMessage(); if (exceptionMessage != null && exceptionMessage.length() > 0) { - message = Escape.htmlElementContent((new Scanner(exceptionMessage)).nextLine()); + try (Scanner scanner = new Scanner(exceptionMessage)) { + message = Escape.htmlElementContent(scanner.nextLine()); + } } } if (message == null) { diff --git a/java/org/apache/tomcat/util/file/ConfigurationSource.java b/java/org/apache/tomcat/util/file/ConfigurationSource.java index 38228f9..2df11bc 100644 --- a/java/org/apache/tomcat/util/file/ConfigurationSource.java +++ b/java/org/apache/tomcat/util/file/ConfigurationSource.java @@ -44,7 +44,8 @@ public interface ConfigurationSource { f = new File(userDir, name); } if (f.isFile()) { - return new Resource(new FileInputStream(f), f.toURI()); + FileInputStream fis = new FileInputStream(f); + return new Resource(fis, f.toURI()); } URI uri = null; try { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org