Skip to content

Commit 0b531cd

Browse files
committed
FS, FS_Posix: remove deprecated #createNewFile(File) method
Change-Id: Id34a0be998eee360e69f74b469c4990afa153c1b
1 parent 8baef22 commit 0b531cd

File tree

2 files changed

+0
-86
lines changed

2 files changed

+0
-86
lines changed

org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,25 +1762,6 @@ public void createSymLink(File path, String target) throws IOException {
17621762
FileUtils.createSymLink(path, target);
17631763
}
17641764

1765-
/**
1766-
* Create a new file. See {@link java.io.File#createNewFile()}. Subclasses
1767-
* of this class may take care to provide a safe implementation for this
1768-
* even if {@link #supportsAtomicCreateNewFile()} is <code>false</code>
1769-
*
1770-
* @param path
1771-
* the file to be created
1772-
* @return <code>true</code> if the file was created, <code>false</code> if
1773-
* the file already existed
1774-
* @throws java.io.IOException
1775-
* if an IO error occurred
1776-
* @deprecated use {@link #createNewFileAtomic(File)} instead
1777-
* @since 4.5
1778-
*/
1779-
@Deprecated
1780-
public boolean createNewFile(File path) throws IOException {
1781-
return path.createNewFile();
1782-
}
1783-
17841765
/**
17851766
* A token representing a file created by
17861767
* {@link #createNewFileAtomic(File)}. The token must be retained until the

org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -341,73 +341,6 @@ public boolean supportsAtomicCreateNewFile() {
341341
return supportsAtomicFileCreation == AtomicFileCreation.SUPPORTED;
342342
}
343343

344-
@Override
345-
@SuppressWarnings("boxing")
346-
/**
347-
* {@inheritDoc}
348-
* <p>
349-
* An implementation of the File#createNewFile() semantics which works also
350-
* on NFS. If the config option
351-
* {@code core.supportsAtomicCreateNewFile = true} (which is the default)
352-
* then simply File#createNewFile() is called.
353-
*
354-
* But if {@code core.supportsAtomicCreateNewFile = false} then after
355-
* successful creation of the lock file a hard link to that lock file is
356-
* created and the attribute nlink of the lock file is checked to be 2. If
357-
* multiple clients manage to create the same lock file nlink would be
358-
* greater than 2 showing the error.
359-
*
360-
* @see "https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html"
361-
*
362-
* @deprecated use {@link FS_POSIX#createNewFileAtomic(File)} instead
363-
* @since 4.5
364-
*/
365-
@Deprecated
366-
public boolean createNewFile(File lock) throws IOException {
367-
if (!lock.createNewFile()) {
368-
return false;
369-
}
370-
if (supportsAtomicCreateNewFile()) {
371-
return true;
372-
}
373-
Path lockPath = lock.toPath();
374-
Path link = null;
375-
FileStore store = null;
376-
try {
377-
store = Files.getFileStore(lockPath);
378-
} catch (SecurityException e) {
379-
return true;
380-
}
381-
try {
382-
Boolean canLink = CAN_HARD_LINK.computeIfAbsent(store,
383-
s -> Boolean.TRUE);
384-
if (Boolean.FALSE.equals(canLink)) {
385-
return true;
386-
}
387-
link = Files.createLink(
388-
Paths.get(lock.getAbsolutePath() + ".lnk"), //$NON-NLS-1$
389-
lockPath);
390-
Integer nlink = (Integer) Files.getAttribute(lockPath,
391-
"unix:nlink"); //$NON-NLS-1$
392-
if (nlink > 2) {
393-
LOG.warn(MessageFormat.format(
394-
JGitText.get().failedAtomicFileCreation, lockPath,
395-
nlink));
396-
return false;
397-
} else if (nlink < 2) {
398-
CAN_HARD_LINK.put(store, Boolean.FALSE);
399-
}
400-
return true;
401-
} catch (UnsupportedOperationException | IllegalArgumentException e) {
402-
CAN_HARD_LINK.put(store, Boolean.FALSE);
403-
return true;
404-
} finally {
405-
if (link != null) {
406-
Files.delete(link);
407-
}
408-
}
409-
}
410-
411344
/**
412345
* {@inheritDoc}
413346
* <p>

0 commit comments

Comments
 (0)