Ensure root cause of lock creation failures is logged
Change-Id: I91cdf1e085a29c0aabd6d22c6ebe848b2d75f42c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
9add6d3e24
commit
cc29da8e0f
|
@ -48,6 +48,7 @@
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.FileAlreadyExistsException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
@ -422,7 +423,7 @@ public boolean createNewFile(File lock) throws IOException {
|
||||||
* An implementation of the File#createNewFile() semantics which can create
|
* An implementation of the File#createNewFile() semantics which can create
|
||||||
* a unique file atomically also on NFS. If the config option
|
* a unique file atomically also on NFS. If the config option
|
||||||
* {@code core.supportsAtomicCreateNewFile = true} (which is the default)
|
* {@code core.supportsAtomicCreateNewFile = true} (which is the default)
|
||||||
* then simply File#createNewFile() is called.
|
* then simply Files#createFile() is called.
|
||||||
*
|
*
|
||||||
* But if {@code core.supportsAtomicCreateNewFile = false} then after
|
* But if {@code core.supportsAtomicCreateNewFile = false} then after
|
||||||
* successful creation of the lock file a hard link to that lock file is
|
* successful creation of the lock file a hard link to that lock file is
|
||||||
|
@ -443,14 +444,17 @@ public boolean createNewFile(File lock) throws IOException {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LockToken createNewFileAtomic(File file) throws IOException {
|
public LockToken createNewFileAtomic(File file) throws IOException {
|
||||||
if (!file.createNewFile()) {
|
Path path;
|
||||||
|
try {
|
||||||
|
path = file.toPath();
|
||||||
|
Files.createFile(path);
|
||||||
|
} catch (FileAlreadyExistsException e) {
|
||||||
return token(false, null);
|
return token(false, null);
|
||||||
}
|
}
|
||||||
if (supportsAtomicCreateNewFile() || !supportsUnixNLink) {
|
if (supportsAtomicCreateNewFile() || !supportsUnixNLink) {
|
||||||
return token(true, null);
|
return token(true, null);
|
||||||
}
|
}
|
||||||
Path link = null;
|
Path link = null;
|
||||||
Path path = file.toPath();
|
|
||||||
try {
|
try {
|
||||||
link = Files.createLink(Paths.get(uniqueLinkPath(file)), path);
|
link = Files.createLink(Paths.get(uniqueLinkPath(file)), path);
|
||||||
Integer nlink = (Integer) (Files.getAttribute(path,
|
Integer nlink = (Integer) (Files.getAttribute(path,
|
||||||
|
|
Loading…
Reference in New Issue