Do not throw NotImplementedException from PublishChangeEdit and RebaseChangeEdit

Trying to list/parse members of the PublishChangeEdit and
RebaseChangeEdit REST collections returns '501 Not Implemented', but
usually we return '404 Not Found' for non-existing views. Make the
behaviour of PublishChangeEdit and RebaseChangeEdit consistent and throw
a ResourceNotFoundException instead.

Returning '501 Not Implemented' is bad since all 5xx responses are
counted into error statistics and failing when a non-implemented view is
invoked is not an error, but working as intended.

Change-Id: I6fcd80905cc280b434d75a5a6e6c312aa34b235a
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-06-27 14:51:39 +02:00
parent e702472194
commit 62912f79de
2 changed files with 12 additions and 10 deletions

View File

@@ -19,8 +19,8 @@ import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.AcceptsPost;
import com.google.gerrit.extensions.restapi.ChildCollection;
import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestView;
@@ -62,13 +62,14 @@ public class PublishChangeEdit
}
@Override
public RestView<ChangeResource> list() {
throw new NotImplementedException();
public RestView<ChangeResource> list() throws ResourceNotFoundException {
throw new ResourceNotFoundException();
}
@Override
public ChangeEditResource.Publish parse(ChangeResource parent, IdString id) {
throw new NotImplementedException();
public ChangeEditResource.Publish parse(ChangeResource parent, IdString id)
throws ResourceNotFoundException {
throw new ResourceNotFoundException();
}
@Override

View File

@@ -20,8 +20,8 @@ import com.google.gerrit.extensions.restapi.AcceptsPost;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ChildCollection;
import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView;
@@ -59,13 +59,14 @@ public class RebaseChangeEdit
}
@Override
public RestView<ChangeResource> list() {
throw new NotImplementedException();
public RestView<ChangeResource> list() throws ResourceNotFoundException {
throw new ResourceNotFoundException();
}
@Override
public ChangeEditResource.Rebase parse(ChangeResource parent, IdString id) {
throw new NotImplementedException();
public ChangeEditResource.Rebase parse(ChangeResource parent, IdString id)
throws ResourceNotFoundException {
throw new ResourceNotFoundException();
}
@Override