diff options
author | Luca Milanesio <luca.milanesio@gmail.com> | 2023-06-08 00:23:54 +0100 |
---|---|---|
committer | Luca Milanesio <luca.milanesio@gmail.com> | 2023-06-08 00:24:00 +0100 |
commit | 42d201f46c6de3374bca6c5ccddc2e7721956696 (patch) | |
tree | 8c53ce4bfbf1bd45452bda2797c9192418fedea2 /org.eclipse.jgit/src/org/eclipse/jgit | |
parent | 4451f466e07dfc5a82fba46c4c411847684171b9 (diff) | |
parent | a22c62cb6dde1d54a258b672288f11b35baa04a7 (diff) | |
download | jgit-42d201f46c6de3374bca6c5ccddc2e7721956696.tar.gz jgit-42d201f46c6de3374bca6c5ccddc2e7721956696.zip |
Merge branch 'stable-6.0' into stable-6.1
* stable-6.0:
Revert "RefDirectory: Throw exception if CAS of packed ref list fails"
Change-Id: Idc0d1f8ab4524868b7e9754799f70acc1d24f2cb
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index c7322b17bb..1db4f748f1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java @@ -1063,22 +1063,7 @@ public class RefDirectory extends RefDatabase { byte[] digest = Constants.newMessageDigest().digest(content); PackedRefList newPackedList = new PackedRefList( refs, lck.getCommitSnapshot(), ObjectId.fromRaw(digest)); - - // This thread holds the file lock, so no other thread or process should - // be able to modify the packed-refs file on disk. If the list changed, - // it means something is very wrong, so throw an exception. - // - // However, we can't use a naive compareAndSet to check whether the - // update was successful, because another thread might _read_ the - // packed refs file that was written out by this thread while holding - // the lock, and update the packedRefs reference to point to that. So - // compare the actual contents instead. - PackedRefList afterUpdate = packedRefs.updateAndGet( - p -> p.id.equals(oldPackedList.id) ? newPackedList : p); - if (!afterUpdate.id.equals(newPackedList.id)) { - throw new ObjectWritingException( - MessageFormat.format(JGitText.get().unableToWrite, name)); - } + packedRefs.compareAndSet(oldPackedList, newPackedList); if (changed) { modCnt.incrementAndGet(); } |