Prevent posting reviews on change edits
Posting a review triggers a stream event, but this fails with a NullPointerException when the creation date is set for the event since the change edit does not have a creation date. Posting reviews on a change edit and sending a stream event does not make sense since the change edit is not visible to anyone except the author. Change-Id: I8d2de5c0368d2f4211bc756ff9e989350e18df0d Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -37,6 +37,7 @@ import com.google.gerrit.extensions.api.changes.ReviewInput.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.Comment.Side;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.extensions.restapi.Url;
|
||||
@@ -130,8 +131,11 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
||||
|
||||
@Override
|
||||
public Output apply(RevisionResource revision, ReviewInput input)
|
||||
throws AuthException, BadRequestException, UnprocessableEntityException,
|
||||
OrmException, IOException {
|
||||
throws AuthException, BadRequestException, ResourceConflictException,
|
||||
UnprocessableEntityException, OrmException, IOException {
|
||||
if (revision.getEdit().isPresent()) {
|
||||
throw new ResourceConflictException("cannot post review on edit");
|
||||
}
|
||||
if (input.onBehalfOf != null) {
|
||||
revision = onBehalfOf(revision, input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user