You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2026/07/31 21:53:10 UTC
(maven-shared-io) branch master updated: Fix URLLocation null temp file defaults (#118)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shared-io.git
The following commit(s) were added to refs/heads/master by this push:
new cc9450f Fix URLLocation null temp file defaults (#118)
cc9450f is described below
commit cc9450f7fad57450584f0ddca0f9c9e493c1d01b
Author: Manikanta Boda <fr...@gmail.com>
AuthorDate: Sat Aug 1 03:23:06 2026 +0530
Fix URLLocation null temp file defaults (#118)
Provide safe defaults for temp file prefix/suffix when null and add regression test for issue #95.
Co-authored-by: Copilot <22...@users.noreply.github.com>
---
.../org/apache/maven/shared/io/location/URLLocation.java | 4 ++--
.../org/apache/maven/shared/io/location/URLLocationTest.java | 12 ++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/maven/shared/io/location/URLLocation.java b/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
index ae9d645..e472b8a 100644
--- a/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
+++ b/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
@@ -50,8 +50,8 @@ public class URLLocation extends FileLocation {
super(specification);
this.url = url;
- this.tempFilePrefix = tempFilePrefix;
- this.tempFileSuffix = tempFileSuffix;
+ this.tempFilePrefix = (tempFilePrefix != null) ? tempFilePrefix : "url";
+ this.tempFileSuffix = (tempFileSuffix != null) ? tempFileSuffix : ".tmp";
this.tempFileDeleteOnExit = tempFileDeleteOnExit;
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java b/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
index 62e3db8..59ace8a 100644
--- a/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
@@ -77,4 +77,16 @@ class URLLocationTest {
assertEquals(testStr, new String(buffer, "US-ASCII"));
}
+
+ @Test
+ void shouldUseDefaultsWhenTempFilePrefixAndSuffixAreNull() throws Exception {
+ File f = Files.createTempFile("url-location.", ".test").toFile();
+ f.deleteOnExit();
+
+ URL url = f.toURL();
+
+ URLLocation location = new URLLocation(url, f.getAbsolutePath(), null, null, true);
+
+ assertNotNull(location.getFile());
+ }
}