This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new ab88db97bf Fix resource leak
ab88db97bf is described below

commit ab88db97bf2e5075216cb6fb4b9f12018c15b3e3
Author: remm <r...@apache.org>
AuthorDate: Tue Aug 20 16:32:29 2024 +0200

    Fix resource leak
    
    Found by coverity.
---
 java/org/apache/catalina/realm/RealmBase.java | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/realm/RealmBase.java 
b/java/org/apache/catalina/realm/RealmBase.java
index 0021696b50..60b958d1ae 100644
--- a/java/org/apache/catalina/realm/RealmBase.java
+++ b/java/org/apache/catalina/realm/RealmBase.java
@@ -1456,15 +1456,9 @@ public abstract class RealmBase extends 
LifecycleMBeanBase implements Realm {
             // If the file name is used, then don't parse the trailing 
arguments
             argIndex = args.length;
 
-            try {
-                BufferedReader br;
-                // Special case, allow for - filename to refer to stdin
-                if (passwordFile.equals("-")) {
-                    br = new BufferedReader(new InputStreamReader(System.in));
-                } else {
-                    br = new BufferedReader(new FileReader(passwordFile));
-                }
-
+            // Special case, allow for - filename to refer to stdin
+            try (BufferedReader br = passwordFile.equals("-") ? new 
BufferedReader(new InputStreamReader(System.in))
+                    : new BufferedReader(new FileReader(passwordFile))) {
                 String line;
                 while ((line = br.readLine()) != null) {
                     // Mutate each line in the file, or stdin


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to