From a3738ef137caf27d3fc588d3027f46045ba58ef5 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 3 Jun 2018 13:32:51 +0200 Subject: [PATCH 1/2] Ensure index change event is fired when index snapshot changed Ensure that notifyIndexChanged is called every time we call FileSnapshot.save, except the first. Change-Id: I5a4e9826e791f518787366ae7c3a0ef3d416d2c1 Signed-off-by: Matthias Sohn --- .../internal/storage/file/FileRepository.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java index ed5cf2c9e..13ef94b89 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java @@ -56,7 +56,7 @@ import java.util.Locale; import java.util.Objects; import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.locks.ReentrantLock; import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.api.errors.JGitInternalException; @@ -125,7 +125,10 @@ public class FileRepository extends Repository { private final RefDatabase refs; private final ObjectDirectory objectDatabase; - private AtomicReference snapshot = new AtomicReference<>(); + private final ReentrantLock snapshotLock = new ReentrantLock(); + + // protected by snapshotLock + private FileSnapshot snapshot; /** * Construct a representation of a Git repository. @@ -240,8 +243,9 @@ public void onConfigChanged(ConfigChangedEvent event) { Long.valueOf(repositoryFormatVersion))); } - if (!isBare()) - snapshot.getAndSet(FileSnapshot.save(getIndexFile())); + if (!isBare()) { + snapshot = FileSnapshot.save(getIndexFile()); + } } private void loadSystemConfig() throws IOException { @@ -549,17 +553,30 @@ private void detectIndexChanges() { } File indexFile = getIndexFile(); - if (snapshot.get() == null) { - snapshot.getAndSet(FileSnapshot.save(indexFile)); - } else if (snapshot.get().isModified(indexFile)) { - notifyIndexChanged(false); + snapshotLock.lock(); + try { + if (snapshot == null) { + snapshot = FileSnapshot.save(indexFile); + } else if (snapshot.isModified(indexFile)) { + snapshotLock.unlock(); + notifyIndexChanged(false); + } + } finally { + if (snapshotLock.isHeldByCurrentThread()) { + snapshotLock.unlock(); + } } } /** {@inheritDoc} */ @Override public void notifyIndexChanged(boolean internal) { - snapshot.getAndSet(FileSnapshot.save(getIndexFile())); + snapshotLock.lock(); + try { + snapshot = FileSnapshot.save(getIndexFile()); + } finally { + snapshotLock.unlock(); + } fireEvent(new IndexChangedEvent(internal)); } From 5f46661cae6b9e7c38b3b79d624c5b9b0f7243d9 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 7 Jun 2018 14:44:40 +0200 Subject: [PATCH 2/2] Update to latest Photon Orbit R20180606145124 also add missing bundle org.hamcrest Change-Id: I88ad7769b8fda491fe3641ddaf0964ca55ffc0f6 Signed-off-by: Matthias Sohn --- .../org.eclipse.jgit.target/jgit-4.5.target | 5 +++-- .../org.eclipse.jgit.target/jgit-4.5.tpd | 2 +- .../org.eclipse.jgit.target/jgit-4.6.target | 5 +++-- .../org.eclipse.jgit.target/jgit-4.6.tpd | 2 +- .../org.eclipse.jgit.target/jgit-4.7.target | 5 +++-- .../org.eclipse.jgit.target/jgit-4.7.tpd | 2 +- .../org.eclipse.jgit.target/jgit-4.8.target | 5 +++-- .../org.eclipse.jgit.target/jgit-4.8.tpd | 2 +- ...R20180531190352-Photon.tpd => R20180606145124-Photon.tpd} | 5 +++-- 9 files changed, 19 insertions(+), 14 deletions(-) rename org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/{R20180531190352-Photon.tpd => R20180606145124-Photon.tpd} (95%) diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target index bc6d6896e..9fab24550 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target @@ -1,7 +1,7 @@ - + @@ -39,6 +39,7 @@ + @@ -65,7 +66,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd index a893a6a73..c85343c9f 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd @@ -1,7 +1,7 @@ target "jgit-4.5" with source configurePhase include "projects/jetty-9.4.8.tpd" -include "orbit/R20180531190352-Photon.tpd" +include "orbit/R20180606145124-Photon.tpd" location "http://download.eclipse.org/releases/mars/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target index e11b2a8d8..909b3307e 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target @@ -1,7 +1,7 @@ - + @@ -39,6 +39,7 @@ + @@ -65,7 +66,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd index 68884a261..3c2a910f8 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd @@ -1,7 +1,7 @@ target "jgit-4.6" with source configurePhase include "projects/jetty-9.4.8.tpd" -include "orbit/R20180531190352-Photon.tpd" +include "orbit/R20180606145124-Photon.tpd" location "http://download.eclipse.org/releases/neon/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target index b60b57211..8b064bc1c 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target @@ -1,7 +1,7 @@ - + @@ -39,6 +39,7 @@ + @@ -65,7 +66,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd index c3b4cf282..4e543fffe 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd @@ -1,7 +1,7 @@ target "jgit-4.7" with source configurePhase include "projects/jetty-9.4.8.tpd" -include "orbit/R20180531190352-Photon.tpd" +include "orbit/R20180606145124-Photon.tpd" location "http://download.eclipse.org/releases/oxygen/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target index 22f431249..564b49326 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target @@ -1,7 +1,7 @@ - + @@ -39,6 +39,7 @@ + @@ -65,7 +66,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd index c36cda528..efcba7c2c 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd @@ -1,7 +1,7 @@ target "jgit-4.8" with source configurePhase include "projects/jetty-9.4.8.tpd" -include "orbit/R20180531190352-Photon.tpd" +include "orbit/R20180606145124-Photon.tpd" location "http://download.eclipse.org/releases/oxygen/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180531190352-Photon.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd similarity index 95% rename from org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180531190352-Photon.tpd rename to org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd index 4a40d1d4d..8497c2c87 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180531190352-Photon.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd @@ -1,7 +1,7 @@ -target "R20180531190352-Photon" with source configurePhase +target "R20180606145124-Photon" with source configurePhase // see http://download.eclipse.org/tools/orbit/downloads/ -location "http://download.eclipse.org/tools/orbit/downloads/drops/R20180531190352/repository" { +location "http://download.eclipse.org/tools/orbit/downloads/drops/R20180606145124/repository" { org.apache.ant [1.9.6.v201510161327,1.9.6.v201510161327] org.apache.ant.source [1.9.6.v201510161327,1.9.6.v201510161327] org.apache.commons.codec [1.9.0.v20170208-1614,1.9.0.v20170208-1614] @@ -18,6 +18,7 @@ location "http://download.eclipse.org/tools/orbit/downloads/drops/R2018053119035 org.apache.log4j.source [1.2.15.v201012070815,1.2.15.v201012070815] org.kohsuke.args4j [2.33.0.v20160323-2218,2.33.0.v20160323-2218] org.kohsuke.args4j.source [2.33.0.v20160323-2218,2.33.0.v20160323-2218] + org.hamcrest [1.1.0.v20090501071000,1.1.0.v20090501071000] org.hamcrest.core [1.3.0.v20180420-1519,1.3.0.v20180420-1519] org.hamcrest.core.source [1.3.0.v20180420-1519,1.3.0.v20180420-1519] org.hamcrest.library [1.3.0.v20180524-2246,1.3.0.v20180524-2246]