rishabhdaim commented on code in PR #2744:
URL: https://github.com/apache/jackrabbit-oak/pull/2744#discussion_r2827826033
##########
oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java:
##########
@@ -323,11 +322,16 @@ 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 new FileInputStream(tmpFile);
Review Comment:
Created a new to check this on MacOS:
```
private Object[] createTempFileAndReturnStream() throws Exception {
File tempFile = File.createTempFile("test", ".txt");
System.out.println(tempFile.getAbsolutePath());
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
fos.write("hello world".getBytes());
}
FileInputStream fis = new FileInputStream(tempFile);
// Delete the file immediately after opening the stream
tempFile.delete();
return new Object[]{fis, tempFile};
}
@Test
public void testWaitForBucketNotFound() throws Exception {
FileInputStream fis = null;
String name = null;
try {
Object[] tempFileAndReturnStream =
createTempFileAndReturnStream();
fis = (FileInputStream) tempFileAndReturnStream[0];
name = tempFileAndReturnStream[1].toString();
byte[] buf = new byte[11];
int read = fis.read(buf);
Assert.assertEquals(11, read);
Assert.assertEquals("hello world", new String(buf));
System.out.println(Path.of(name));
Assert.assertFalse(Files.exists(Path.of(name)));
} finally {
if (fis != null) {
fis.close();
}
}
}
```
On Mac, it is working fine, but I couldn't test on Windows since I don't
have one.
@Joscorbe could you please try the above test on Windows if possible?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]