diff options
author | Thomas Wolf | 2019-06-24 06:13:05 +0000 |
---|---|---|
committer | Thomas Wolf | 2019-06-24 06:13:05 +0000 |
commit | 319caf2e4b81c538aa2ee759a516d3157d6a3ec3 (patch) | |
tree | 9cd353ad3b8a98302c0acf31da9abfd9608453e8 /org.eclipse.egit.ui | |
parent | c05bbac1bb51d108c95b16ad2cc2d73560481760 (diff) | |
download | egit-319caf2e4b81c538aa2ee759a516d3157d6a3ec3.tar.gz egit-319caf2e4b81c538aa2ee759a516d3157d6a3ec3.tar.xz egit-319caf2e4b81c538aa2ee759a516d3157d6a3ec3.zip |
Avoid NPE in FetchGerritChangePage
When getting the change refs from the Gerrit server fails the change
list may be null. Therefore add null checks where needed.
Bug: 548534
Change-Id: Ifc4d42f42ab016897430eb71c8831cfd979d47c4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java index c3dee00c2a..5ff929912c 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java @@ -766,14 +766,15 @@ public class FetchGerritChangePage extends WizardPage { ChangeList list = changeRefs.get(uriCombo.getText()); if (list != null && list.isDone()) { try { + Collection<Change> changes = list.get(); if (change.getPatchSetNumber() != null) { - if (!list.get().contains(change)) { + if (changes == null || !changes.contains(change)) { setErrorMessage( UIText.FetchGerritChangePage_UnknownChangeRefMessage); return; } } else { - Change fromGerrit = findHighestPatchSet(list.get(), + Change fromGerrit = findHighestPatchSet(changes, change.getChangeNumber().intValue()); if (fromGerrit == null) { setErrorMessage(NLS.bind( @@ -908,6 +909,9 @@ public class FetchGerritChangePage extends WizardPage { private Change findHighestPatchSet(Collection<Change> changes, int changeNumber) { + if (changes == null) { + return null; + } // We know that the result is sorted by change and // patch set number descending for (Change fromGerrit : changes) { @@ -1055,8 +1059,11 @@ public class FetchGerritChangePage extends WizardPage { if (monitor.isCanceled()) { throw new OperationCanceledException(); } - return findHighestPatchSet(changes, + Change highest = findHighestPatchSet(changes, originalChange.getChangeNumber().intValue()); + if (highest != null) { + return highest; + } } return originalChange; } |