You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2026/10/20 21:17:16 UTC
(tomcat) 15/21: Do not swallow exceptions when loading translation property files
This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 6eaed5ed8dbbfe6053c24f1fceadc28068998ffe
Author: opencode <re...@apache.org>
AuthorDate: Tue Oct 20 13:13:41 2026 +0200
Do not swallow exceptions when loading translation property files
Utils.load() caught IOException while reading a LocalStrings*.properties
file, only printed a stack trace, and returned an empty or partially
filled Properties object. All callers treated the result as an empty
file, so a file that could not be read silently lost all its keys in
Export and back-port output, and Import silently produced no output for
the affected language while leaving any stale file from a previous run
in place. Propagate the exception instead. All callers already declared
throws IOException except the TestFixedStrings helper and test methods
which are updated accordingly.
---
java/org/apache/tomcat/buildutil/translate/Utils.java | 4 +---
test/org/apache/tomcat/buildutil/translate/TestFixedStrings.java | 7 ++++---
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/tomcat/buildutil/translate/Utils.java b/java/org/apache/tomcat/buildutil/translate/Utils.java
index 4baa0200b4..fd7f847f52 100644
--- a/java/org/apache/tomcat/buildutil/translate/Utils.java
+++ b/java/org/apache/tomcat/buildutil/translate/Utils.java
@@ -61,14 +61,12 @@ public class Utils {
}
- static Properties load(File f) {
+ static Properties load(File f) throws IOException {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f);
Reader r = new InputStreamReader(fis, StandardCharsets.UTF_8)) {
props.load(r);
- } catch (IOException ioe) {
- ioe.printStackTrace();
}
return props;
}
diff --git a/test/org/apache/tomcat/buildutil/translate/TestFixedStrings.java b/test/org/apache/tomcat/buildutil/translate/TestFixedStrings.java
index a401611814..42942d86f7 100644
--- a/test/org/apache/tomcat/buildutil/translate/TestFixedStrings.java
+++ b/test/org/apache/tomcat/buildutil/translate/TestFixedStrings.java
@@ -17,6 +17,7 @@
package org.apache.tomcat.buildutil.translate;
import java.io.File;
+import java.io.IOException;
import java.util.Properties;
import org.junit.Assert;
@@ -25,13 +26,13 @@ import org.junit.Test;
public class TestFixedStrings {
@Test
- public void testManagerApps() {
+ public void testManagerApps() throws IOException {
doTestStartsWith("org.apache.catalina.manager", "OK -");
doTestStartsWith("org.apache.catalina.manager.host", "OK -");
}
- private void doTestStartsWith(String packageName, String text) {
+ private void doTestStartsWith(String packageName, String text) throws IOException {
File dir = new File("java/" + packageName.replace('.', '/'));
// English
@@ -52,7 +53,7 @@ public class TestFixedStrings {
}
- private void doTestStartsFile(File fileTranslated, Properties propsEn, String text) {
+ private void doTestStartsFile(File fileTranslated, Properties propsEn, String text) throws IOException {
Properties propsTranslated = Utils.load(fileTranslated);
for (Object key : propsEn.keySet()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org