This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new eeff6573c57 Fix NPE in maybeDeleteDefaultTempDir and warn when
TempDirectory is ignored (#3797)
eeff6573c57 is described below
commit eeff6573c57b3659de9ea74f297a4de349221be2
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Mon Nov 30 08:06:42 2026 +0000
Fix NPE in maybeDeleteDefaultTempDir and warn when TempDirectory is ignored
(#3797)
---
core/src/main/java/org/apache/cxf/helpers/FileUtils.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
index 44894814f1c..c923b04b2db 100644
--- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
@@ -82,6 +82,10 @@ public final class FileUtils {
File f = new File(s);
if (f.mkdirs()) {
defaultTempDir = f;
+ } else if (f.isDirectory()) {
+ LogUtils.getL7dLogger(FileUtils.class).warning("The directory
" + s + " set by "
+ + FileUtils.class.getName() + ".TempDirectory already
exists and is ignored; "
+ + "a directory under java.io.tmpdir is used instead");
}
}
// also create a new directory if ours was removed, e.g. by a tmp
cleaner, while the JVM was running.
@@ -99,7 +103,9 @@ public final class FileUtils {
}
public static synchronized void maybeDeleteDefaultTempDir() {
- if (defaultTempDir != null) {
+ // with no shutdown hook the directory was configured via the
TempDirectory property,
+ // so it is managed outside of CXF and must not be removed
+ if (defaultTempDir != null && shutdownHook != null) {
Runtime.getRuntime().gc(); // attempt a garbage collect to close
any files
String[] files = defaultTempDir.list();
if (files != null && files.length > 0) {