diff options
| author | Philipp Thun | 2011-04-06 20:29:34 +0000 |
|---|---|---|
| committer | Matthias Sohn | 2011-04-06 20:29:34 +0000 |
| commit | dfb50da14addc638080c8b72d8fe91d82d5f287d (patch) | |
| tree | 288e63da7f36f20939f0f1fe45e6237bea0583d0 | |
| parent | 4c89add514a32ffaebb668222f8bf0bc62f3e245 (diff) | |
| download | egit-dfb50da14addc638080c8b72d8fe91d82d5f287d.tar.gz egit-dfb50da14addc638080c8b72d8fe91d82d5f287d.tar.xz egit-dfb50da14addc638080c8b72d8fe91d82d5f287d.zip | |
Fix NPE in history view
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.java | 8 | ||||
| -rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java | 6 |
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 bcc0462515..6e1a372782 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 b0eaac0416..a4af857d8b 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 |
