Skip to content

Commit 8495e7a

Browse files
committed
double check existence before throwing an exception
1 parent 864dc92 commit 8495e7a

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

core/src/main/java/lucee/commons/io/res/type/file/FileResource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ public OutputStream getOutputStream(boolean append) throws IOException {
263263
provider.lock(this);
264264
try {
265265
if (!super.exists() && !super.createNewFile()) {
266-
throw new IOException("Can't create file [" + this + "]");
266+
// It's possible that another process (outside this JVM) has already created the file
267+
// after our initial check, so we perform a double check before throwing an exception.
268+
if (!super.exists()) throw new IOException("Can't create file [" + this + "]");
267269
}
268270
return new BufferedOutputStream(new ResourceOutputStream(this, new FileOutputStream(this, append)));
269271
}

loader/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<project default="core" basedir="." name="Lucee"
33
xmlns:resolver="antlib:org.apache.maven.resolver.ant">
44

5-
<property name="version" value="6.0.4.9-SNAPSHOT"/>
5+
<property name="version" value="6.0.4.10-SNAPSHOT"/>
66

77
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
88
<classpath>

loader/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>org.lucee</groupId>
55
<artifactId>lucee</artifactId>
6-
<version>6.0.4.9-SNAPSHOT</version>
6+
<version>6.0.4.10-SNAPSHOT</version>
77
<packaging>jar</packaging>
88

99
<name>Lucee Loader Build</name>

0 commit comments

Comments
 (0)