(tomcat) branch 11.0.x updated: Fix repeated logging when file cannot be found

[email protected]
Newsgroups gmane.comp.jakarta.tomcat.devel
Message-ID <[email protected]>
This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 7256a124ed Fix repeated logging when file cannot be found
7256a124ed is described below

commit 7256a124ed1c82ea606e076668159b7692f9e82e
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Jul 6 10:33:08 2026 +0100

    Fix repeated logging when file cannot be found
---
 java/org/apache/catalina/users/MemoryUserDatabase.java | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/users/MemoryUserDatabase.java b/java/org/apache/catalina/users/MemoryUserDatabase.java
index a6543d818d..f9caa30c58 100644
--- a/java/org/apache/catalina/users/MemoryUserDatabase.java
+++ b/java/org/apache/catalina/users/MemoryUserDatabase.java
@@ -17,7 +17,6 @@
 package org.apache.catalina.users;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
@@ -392,6 +391,9 @@ public class MemoryUserDatabase implements UserDatabase {
                 // Parse the XML input to load this database
                 digester.parse(resource.getInputStream());
             } catch (IOException ioe) {
+                // The file doesn't exist / isn't accessible
+                // Set the last modified time to avoid repeated log messages
+                this.lastModified = 0;
                 log.error(sm.getString("memoryUserDatabase.fileNotFound", pathName));
             } catch (Exception e) {
                 // Fail safe on error
@@ -644,11 +646,6 @@ public class MemoryUserDatabase implements UserDatabase {
                         writeLock.unlock();
                     }
                 }
-            } catch (FileNotFoundException fnfe) {
-                // The file doesn't exist.
-                // This has been logged above. No need to log again.
-                // Set the last modified time to avoid repeated log messages
-                this.lastModified = 0;
             } catch (IOException ioe) {
                 log.warn(sm.getString("memoryUserDatabase.fileClose", pathname), ioe);
             }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.