You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2025/10/13 13:48:34 UTC
(jackrabbit-oak) branch OAK-11981 created (now ed3a643683)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a change to branch OAK-11981
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at ed3a643683 OAK-11981: blob-plugins - remove use of TransientFileFactory
This branch includes the following new commits:
new ed3a643683 OAK-11981: blob-plugins - remove use of TransientFileFactory
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-11981: blob-plugins - remove use of TransientFileFactory
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-11981
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit ed3a6436831ee0e900def083a81c9e95f03db4c5
Author: Julian Reschke <re...@apache.org>
AuthorDate: Mon Oct 13 14:48:14 2025 +0100
OAK-11981: blob-plugins - remove use of TransientFileFactory
---
.../oak/plugins/blob/AbstractSharedCachingDataStore.java | 14 ++++++++------
.../jackrabbit/oak/plugins/blob/datastore/FSBackend.java | 11 +++++------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java
index 2497499035..7a0f8493b5 100644
--- a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java
+++ b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java
@@ -224,9 +224,9 @@ public abstract class AbstractSharedCachingDataStore extends AbstractDataStore
public DataRecord addRecord(InputStream inputStream, BlobOptions blobOptions)
throws DataStoreException {
Stopwatch watch = Stopwatch.createStarted();
+ File tmpFile = null;
try {
- TransientFileFactory fileFactory = TransientFileFactory.getInstance();
- File tmpFile = fileFactory.createTransientFile("upload", null, tmp);
+ tmpFile = File.createTempFile("upload", null, tmp);
// Copy the stream to the temporary file and calculate the
// stream length and the message digest of the stream
@@ -251,16 +251,18 @@ public abstract class AbstractSharedCachingDataStore extends AbstractDataStore
LOG.debug("Added blob [{}] to backend", identifier);
// offer to download cache
cache.getDownloadCache().put(identifier.toString(), tmpFile);
-
- // Attempt deleting the temporary file
- boolean deletedTemp = FileUtils.deleteQuietly(tmpFile);
- LOG.trace("Temporary file deleted {}", deletedTemp);
}
return getRecordIfStored(identifier);
} catch (Exception e) {
LOG.error("Error in adding record");
throw new DataStoreException("Error in adding record ", e);
+ } finally {
+ // Attempt deleting the temporary file
+ if (tmpFile != null) {
+ boolean deletedTemp = FileUtils.deleteQuietly(tmpFile);
+ LOG.trace("Temporary file {} deleted: {}", tmpFile, deletedTemp);
+ }
}
}
diff --git a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FSBackend.java b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FSBackend.java
index 8392394969..28bf7c6123 100644
--- a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FSBackend.java
+++ b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FSBackend.java
@@ -40,7 +40,6 @@ import org.apache.jackrabbit.core.data.LazyFileInputStream;
import org.apache.jackrabbit.oak.commons.io.FileTreeTraverser;
import org.apache.jackrabbit.oak.spi.blob.AbstractDataRecord;
import org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend;
-import org.apache.jackrabbit.util.TransientFileFactory;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -102,18 +101,18 @@ public class FSBackend extends AbstractSharedBackend {
@Override
public void write(DataIdentifier identifier, File file) throws DataStoreException {
- TransientFileFactory fileFactory = TransientFileFactory.getInstance();
- File tmpFile = null;
-
File dest = getFile(identifier, fsPathDir);
+
if (dest.exists()) {
long now = System.currentTimeMillis();
if (getLastModified(dest) < now + ACCESS_TIME_RESOLUTION) {
setLastModified(dest, now + ACCESS_TIME_RESOLUTION);
}
} else {
+ File tmpFile = null;
+
try {
- tmpFile = fileFactory.createTransientFile("fsbackend", null, fsPathDir);
+ tmpFile = File.createTempFile("fsbackend", null, fsPathDir);
FileUtils.copyFile(file, tmpFile);
File parent = dest.getParentFile();
@@ -129,7 +128,7 @@ public class FSBackend extends AbstractSharedBackend {
+ " (media read only?)");
}
}
- } catch (IOException e) {
+ } catch (IOException e) {
throw new DataStoreException("Could not add record", e);
} finally {
if (tmpFile != null) {