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:
Edwin Kempin
2015-01-07 10:27:31 +01:00
parent 8f180733d8
commit d0febd3184
2 changed files with 9 additions and 2 deletions

View File

@@ -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);
}