Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.util.Iterator;
Expand All @@ -52,8 +54,6 @@
import org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend;
import org.apache.jackrabbit.oak.spi.blob.BlobOptions;
import org.apache.jackrabbit.oak.stats.StatisticsProvider;
import org.apache.jackrabbit.util.LazyFileInputStream;
import org.apache.jackrabbit.util.TransientFileFactory;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -323,11 +323,10 @@ public InputStream getStream() throws DataStoreException {
try {
// If cache configured to 0 will return null
if (cached == null || !cached.exists()) {
TransientFileFactory fileFactory = TransientFileFactory.getInstance();
File tmpFile = fileFactory.createTransientFile("temp0cache", null, temp);
final File tmpFile = Files.createTempFile(temp.toPath(), "blob-cache-", null).toFile();
try (InputStream in = backend.getRecord(getIdentifier()).getStream()) {
copyInputStreamToFile(in, tmpFile);
return new LazyFileInputStream(tmpFile);
return Files.newInputStream(tmpFile.toPath(), StandardOpenOption.DELETE_ON_CLOSE);
}
} else {
return new FileInputStream(cached);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.apache.jackrabbit.oak.spi.blob.BlobOptions;
import org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider;
import org.apache.jackrabbit.oak.stats.StatisticsProvider;
import org.apache.jackrabbit.util.LazyFileInputStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -192,13 +191,15 @@
closer.register(is);

assertNotNull(is);
assertTrue(is instanceof LazyFileInputStream);
((LazyFileInputStream)is).open();

File tmp = new File(new File(path), "tmp");
Collection<File> temp0cacheFiles =
FileUtils.listFiles(tmp, FileFilterUtils.prefixFileFilter("temp0cache"), null);
assertEquals(1, temp0cacheFiles.size());

// OAK-12098: Incorrect assumptions about files still to be present
// File tmp = new File(new File(path), "tmp");

Check warning on line 197 in oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/CachingDataStoreTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&issues=AZzT16DxGh3eRzM31JGD&open=AZzT16DxGh3eRzM31JGD&pullRequest=2744
//
// (tmp file names are implementation details)
// Collection<File> temp0cacheFiles =
// FileUtils.listFiles(tmp, FileFilterUtils.prefixFileFilter("blob-cache-"), null);
// assertEquals(1, temp0cacheFiles.size());

assertFile(is, f, folder, false);

Expand Down
Loading