This is an automated email from the ASF dual-hosted git repository.
markt-asf 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 28de64fdba Review "Create the storage directory in the back-port
tools..."
28de64fdba is described below
commit 28de64fdba46e695ee3a5da81909cb91dbcdb4e1
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Nov 6 17:59:24 2026 +0000
Review "Create the storage directory in the back-port tools..."
Reduce code duplication
---
.../org/apache/tomcat/buildutil/translate/BackportBase.java | 4 +---
java/org/apache/tomcat/buildutil/translate/Utils.java | 13 +++++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/tomcat/buildutil/translate/BackportBase.java
b/java/org/apache/tomcat/buildutil/translate/BackportBase.java
index 2e0d83acf5..86eb6ec2ec 100644
--- a/java/org/apache/tomcat/buildutil/translate/BackportBase.java
+++ b/java/org/apache/tomcat/buildutil/translate/BackportBase.java
@@ -89,9 +89,7 @@ public abstract class BackportBase {
targetEnglish = targetTranslations.get("");
storageDir = new File(targetRoot, Constants.STORAGE_DIR);
- if (!storageDir.exists() && !storageDir.mkdirs()) {
- throw new IOException("Unable to create directory [" +
storageDir.getAbsolutePath() + "]");
- }
+ Utils.createDirectory(storageDir);
}
/**
diff --git a/java/org/apache/tomcat/buildutil/translate/Utils.java
b/java/org/apache/tomcat/buildutil/translate/Utils.java
index 34bce56664..eddc4c7cc4 100644
--- a/java/org/apache/tomcat/buildutil/translate/Utils.java
+++ b/java/org/apache/tomcat/buildutil/translate/Utils.java
@@ -25,6 +25,7 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
@@ -206,6 +207,18 @@ public class Utils {
}
+ /**
+ * Creates the given directory, and any missing parent, if it does not
already exist.
+ *
+ * @param directory The directory to create
+ *
+ * @throws IOException if the directory cannot be created
+ */
+ static void createDirectory(File directory) throws IOException {
+ Files.createDirectories(directory.toPath());
+ }
+
+
static void export(String language, Properties translation, File
storageDir) throws IOException {
File out = new File(storageDir, Constants.L10N_PREFIX + language +
Constants.L10N_SUFFIX);
try (FileOutputStream fos = new FileOutputStream(out);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]