(tomcat) branch main 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 main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 52c792bc7c Fix repeated logging when file cannot be found
52c792bc7c is described below

commit 52c792bc7cc18c3900cf71ca0e425802048ae0c2
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.