aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
diff options
context:
space:
mode:
authorMotiejus Jakštys <motiejus@jakstys.lt>2023-12-28 16:33:28 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2024-02-19 23:16:00 +0000
commit67142cacbbf47053b26e626036db97ce07cf1186 (patch)
treeb6b559feffae93e8956a2863691c91a36313912d /org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
parent9dab861f770dc4bdc062a7d0586bffd664bc9f90 (diff)
downloadjgit-67142cacbbf47053b26e626036db97ce07cf1186.tar.gz
jgit-67142cacbbf47053b26e626036db97ce07cf1186.zip
FS.detectSymlinkSupport: fix a race
When multiple JGit clients are instantiated concurrently, they may try to create the same symlink at the same time. When that happens, the second thread will return an error (because the symlink already exists) and that `FS` instance will think that symlinks are not supported, causing havoc. Change-Id: I362b933ff63a1471e3a5d70cc8c35eb2f25cc0dd Signed-off-by: Motiejus Jakštys <motiejus@jakstys.lt>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index ac973a9c1d..a8e1dae10e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -1024,7 +1024,7 @@ public abstract class FS {
File tempFile = null;
try {
tempFile = File.createTempFile("tempsymlinktarget", ""); //$NON-NLS-1$ //$NON-NLS-2$
- File linkName = new File(tempFile.getParentFile(), "tempsymlink"); //$NON-NLS-1$
+ File linkName = new File(tempFile.getPath() + "-tempsymlink"); //$NON-NLS-1$
createSymLink(linkName, tempFile.getPath());
supportSymlinks = Boolean.TRUE;
linkName.delete();