NPE when deleting draft patch set when previous draft already deleted
If a change has 3 patch sets, all of which are drafts, and draft patch set 2 is deleted, attempting to delete draft patch set 3 (the current patch set) will result in NPE. The reason is that on deleting a draft patch set which is the current patch set, the current patch set is set to the previous patch set whose ID is calculated by subtracting 1 from the deleted patch set ID. This does not work if the previous patch set has already been deleted. Instead, set the current patch set to the highest patch set ID that is available. Bug: Issue 2128 Change-Id: I235d4d943a5525e8223218a97f4702e26f09a69e
This commit is contained in:
@@ -112,9 +112,7 @@ public class DeleteDraftPatchSet implements Callable<ReviewResult> {
|
||||
}
|
||||
if (change.currentPatchSetId().equals(patchSetId)) {
|
||||
try {
|
||||
PatchSet.Id id =
|
||||
new PatchSet.Id(patchSetId.getParentKey(), patchSetId.get() - 1);
|
||||
change.setCurrentPatchSet(patchSetInfoFactory.get(db, id));
|
||||
change.setCurrentPatchSet(patchSetInfoFactory.get(db, highestId));
|
||||
} catch (PatchSetInfoNotAvailableException e) {
|
||||
throw new NoSuchChangeException(changeId);
|
||||
}
|
||||
|
Reference in New Issue
Block a user