Merge branch 'stable-2.13'
* stable-2.13: Fix NPE when requesting invalid Change-Id to index Change-Id: Id909cd3585a5631bb0ae7947e6e4cb94117fc3a9
This commit is contained in:
@@ -96,8 +96,8 @@ public class ChangeArgumentParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<ChangeControl> changeFromNotesFactory(String id, CurrentUser currentUser)
|
private List<ChangeControl> changeFromNotesFactory(String id, CurrentUser currentUser)
|
||||||
throws OrmException {
|
throws OrmException, UnloggedFailure {
|
||||||
return changeNotesFactory.create(db, Arrays.asList(Change.Id.parse(id)))
|
return changeNotesFactory.create(db, parseId(id))
|
||||||
.stream()
|
.stream()
|
||||||
.map(changeNote -> controlForChange(changeNote, currentUser))
|
.map(changeNote -> controlForChange(changeNote, currentUser))
|
||||||
.filter(changeControl -> changeControl.isPresent())
|
.filter(changeControl -> changeControl.isPresent())
|
||||||
@@ -105,7 +105,16 @@ public class ChangeArgumentParser {
|
|||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ChangeControl> controlForChange(ChangeNotes change, CurrentUser user) {
|
private List<Change.Id> parseId(String id) throws UnloggedFailure {
|
||||||
|
try {
|
||||||
|
return Arrays.asList(new Change.Id(Integer.parseInt(id)));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new UnloggedFailure(2, "Invalid change ID " + id, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Optional<ChangeControl> controlForChange(ChangeNotes change,
|
||||||
|
CurrentUser user) {
|
||||||
try {
|
try {
|
||||||
return Optional.of(changeControlFactory.controlFor(change, user));
|
return Optional.of(changeControlFactory.controlFor(change, user));
|
||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user