Use ManagedFileAccess for temp file creation
This commit is contained in:
parent
356a70a845
commit
d57008510c
|
@ -3,6 +3,7 @@ package org.hl7.fhir.utilities.npm;
|
|||
import lombok.Getter;
|
||||
import lombok.With;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -262,7 +263,7 @@ public class FilesystemPackageCacheManagerLocks {
|
|||
result = function.get();
|
||||
} finally {
|
||||
|
||||
lockFile.renameTo(File.createTempFile(lockFile.getName(), ".lock-renamed"));
|
||||
lockFile.renameTo(ManagedFileAccess.file(File.createTempFile(lockFile.getName(), ".lock-renamed").getAbsolutePath()));
|
||||
|
||||
fileLock.release();
|
||||
channel.close();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
@ -103,7 +105,7 @@ public class LockfileTestProcessUtility {
|
|||
System.out.println("File "+lockFileName+" is locked. Waiting for " + seconds + " seconds to release. ");
|
||||
Thread.sleep(seconds * 1000L);
|
||||
|
||||
lockFile.renameTo(File.createTempFile(lockFile.getName(), ".lock-renamed"));
|
||||
lockFile.renameTo(ManagedFileAccess.file(File.createTempFile(lockFile.getName(), ".lock-renamed").getAbsolutePath()));
|
||||
|
||||
fileLock.release();
|
||||
channel.close();
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LockfileTestUtility {
|
|||
throw new TimeoutException("Timed out waiting for lock file creation: " + lockFileName);
|
||||
}
|
||||
// TODO This is a workaround for an edge condition that shows up with testing, where the lock is not reflected in
|
||||
// the file system immediately. It is unlikely to appear in production environments, but should it occur, it will
|
||||
// the file system immediately. It is unlikely to appear in production environments. Should it occur, it will
|
||||
// result in a lock file being erroneously reported as not having an owning process, and will cause a package to
|
||||
// fail to be loaded from that cache until the lock is cleaned up by cache initialization.
|
||||
Thread.sleep(100);
|
||||
|
|
Loading…
Reference in New Issue