diff options
author | Luca Milanesio <luca.milanesio@gmail.com> | 2023-06-08 00:27:42 +0100 |
---|---|---|
committer | Luca Milanesio <luca.milanesio@gmail.com> | 2023-06-08 00:27:49 +0100 |
commit | ff581f51e916995b5b35e95fc928dd80152fe98e (patch) | |
tree | f4ef41506a277167414130facf6afa3caf4eb9b9 /org.eclipse.jgit/src/org/eclipse/jgit | |
parent | 34a81889b8d8a6e84ffaf86deca8eb15bfb250ab (diff) | |
parent | b6237ca8b697f216405042d3f740960502c6fff5 (diff) | |
download | jgit-ff581f51e916995b5b35e95fc928dd80152fe98e.tar.gz jgit-ff581f51e916995b5b35e95fc928dd80152fe98e.zip |
Merge branch 'stable-6.4' into stable-6.5
* stable-6.4:
Revert "RefDirectory: Throw exception if CAS of packed ref list fails"
Change-Id: I7d922a92b7674723cbf6a93fb7c9bc5c0cdb8206
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 065c20b616..e9abb02379 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 @@ -1047,22 +1047,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(); } |