diff options
author | Luca Milanesio <luca.milanesio@gmail.com> | 2023-06-08 00:26:54 +0100 |
---|---|---|
committer | Luca Milanesio <luca.milanesio@gmail.com> | 2023-06-08 00:27:00 +0100 |
commit | b6237ca8b697f216405042d3f740960502c6fff5 (patch) | |
tree | 580034f8e0dfdb99f24d838d88a894ddbb8fd85c | |
parent | f87c456e8ac1fa341f1c3a618798738245bf8adb (diff) | |
parent | 880f1234b264e41c9422a1b2e1929864bd5714ed (diff) | |
download | jgit-b6237ca8b697f216405042d3f740960502c6fff5.tar.gz jgit-b6237ca8b697f216405042d3f740960502c6fff5.zip |
Merge branch 'stable-6.3' into stable-6.4
* stable-6.3:
Revert "RefDirectory: Throw exception if CAS of packed ref list fails"
Change-Id: I33049e70595f097a66e8f4a63b3d8d1c147e878e
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
-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 aa910d845c..d72f935555 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 @@ -1052,22 +1052,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(); } |