Prevent NPE if ref can't be resolved when executing ReflogCommand
If the specified ref can't be resolved we should throw a RefNotFoundException instead of an NPE. Bug: 455005 Change-Id: I6ec9bf1c0f330eea5eb8277268f62663bdf58f66 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
42b20d4127
commit
a24a99a13d
|
@ -48,6 +48,7 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
import org.eclipse.jgit.api.errors.InvalidRefNameException;
|
import org.eclipse.jgit.api.errors.InvalidRefNameException;
|
||||||
|
import org.eclipse.jgit.api.errors.RefNotFoundException;
|
||||||
import org.eclipse.jgit.internal.JGitText;
|
import org.eclipse.jgit.internal.JGitText;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
import org.eclipse.jgit.lib.ReflogEntry;
|
import org.eclipse.jgit.lib.ReflogEntry;
|
||||||
|
@ -97,6 +98,9 @@ public Collection<ReflogEntry> call() throws GitAPIException,
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ReflogReader reader = repo.getReflogReader(ref);
|
ReflogReader reader = repo.getReflogReader(ref);
|
||||||
|
if (reader == null)
|
||||||
|
throw new RefNotFoundException(MessageFormat.format(
|
||||||
|
JGitText.get().refNotResolved, ref));
|
||||||
return reader.getReverseEntries();
|
return reader.getReverseEntries();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new InvalidRefNameException(MessageFormat.format(
|
throw new InvalidRefNameException(MessageFormat.format(
|
||||||
|
|
Loading…
Reference in New Issue