summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPhilipp Thun2011-04-06 16:29:34 (EDT)
committer Matthias Sohn2011-04-06 16:29:34 (EDT)
commitdfb50da14addc638080c8b72d8fe91d82d5f287d (patch)
tree288e63da7f36f20939f0f1fe45e6237bea0583d0
parent4c89add514a32ffaebb668222f8bf0bc62f3e245 (diff)
downloadegit-dfb50da14addc638080c8b72d8fe91d82d5f287d.zip
egit-dfb50da14addc638080c8b72d8fe91d82d5f287d.tar.gz
egit-dfb50da14addc638080c8b72d8fe91d82d5f287d.tar.bz2
Fix NPE in history viewrefs/changes/85/2985/2
This change fixes a possible NPE caused by memory inconsistencies. See bug 340831 for more details. Bug: 340831 Change-Id: I72a0e842876332fb602319bc03fcd3cd6a2cffe6 Signed-off-by: Philipp Thun <philipp.thun@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java6
2 files changed, 11 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java
index bcc0462..6e1a372 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java
@@ -390,8 +390,12 @@ class CommitGraphTable {
private void initCommitsMap() {
commitsMap = new HashMap<String, PlotCommit>();
- for (PlotCommit commit : allCommits)
- commitsMap.put(commit.getId().name(), commit);
+ // ensure that filling (GenerateHistoryJob) and reading (here)
+ // the commit list is thread safe
+ synchronized (allCommits) {
+ for (PlotCommit commit : allCommits)
+ commitsMap.put(commit.getId().name(), commit);
+ }
}
private void createColumns(final Table rawTable, final TableLayout layout) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java
index b0eaac0..a4af857 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java
@@ -64,7 +64,11 @@ class GenerateHistoryJob extends Job {
GitTraceLocation.getTrace().trace(
GitTraceLocation.HISTORYVIEW.getLocation(),
"Filling commit list"); //$NON-NLS-1$
- allCommits.fillTo(oldsz + BATCH_SIZE - 1);
+ // ensure that filling (here) and reading (CommitGraphTable)
+ // the commit list is thread safe
+ synchronized (allCommits) {
+ allCommits.fillTo(oldsz + BATCH_SIZE - 1);
+ }
if (monitor.isCanceled()) {
page.setErrorMessage(NLS.bind(
UIText.GenerateHistoryJob_CancelMessage, page