Adapt to removal of change etags in Gerrit core
Etags have been removed in Gerrit core, in particular the
ChangeResource#getEtag method (change Ia92fbad2a) and the
ChangeETagComputation extension point (change Ib49748bfb) have been
removed.
Change-Id: If328225ee452d078be6b515dcc7e64ce095e65ad
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/java/com/google/gerrit/plugins/checks/ChecksETagComputation.java b/java/com/google/gerrit/plugins/checks/ChecksETagComputation.java
deleted file mode 100644
index 3373cee..0000000
--- a/java/com/google/gerrit/plugins/checks/ChecksETagComputation.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.plugins.checks;
-
-import com.google.gerrit.entities.Change;
-import com.google.gerrit.entities.Project;
-import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.server.change.ChangeETagComputation;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.IOException;
-
-/**
- * Ensures that the ETag of a change changes when there was any check update for the change.
- *
- * <p>This prevents callers using ETags from potentially seeing outdated submittability and combined
- * check state information in {@link com.google.gerrit.extensions.common.ChangeInfo} when a check
- * for the change was created or updated.
- */
-@Singleton
-public class ChecksETagComputation implements ChangeETagComputation {
- private final Checks checks;
-
- @Inject
- ChecksETagComputation(Checks checks) {
- this.checks = checks;
- }
-
- @Override
- public String getETag(Project.NameKey projectName, Change.Id changeId) {
- try {
- return checks.getETag(projectName, changeId);
- } catch (IOException e) {
- // The change ETag will be invalidated if the checks can be accessed the next time.
- throw new StorageException(
- String.format(
- "Failed to compute ETag for checks of change %s in project %s",
- changeId, projectName),
- e);
- }
- }
-}
diff --git a/java/com/google/gerrit/plugins/checks/Module.java b/java/com/google/gerrit/plugins/checks/Module.java
index 4787df6..9cfb9b0 100644
--- a/java/com/google/gerrit/plugins/checks/Module.java
+++ b/java/com/google/gerrit/plugins/checks/Module.java
@@ -31,7 +31,6 @@
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.ServerInitiated;
import com.google.gerrit.server.UserInitiated;
-import com.google.gerrit.server.change.ChangeETagComputation;
import com.google.gerrit.server.change.ChangePluginDefinedInfoFactory;
import com.google.gerrit.server.git.validators.CommitValidationListener;
import com.google.gerrit.server.git.validators.MergeValidationListener;
@@ -63,10 +62,6 @@
.to(CheckerRefOperationValidator.class)
.in(SINGLETON);
- DynamicSet.bind(binder(), ChangeETagComputation.class)
- .to(ChecksETagComputation.class)
- .in(SINGLETON);
-
DynamicSet.bind(binder(), ChangePluginDefinedInfoFactory.class)
.to(ChangeCheckAttributeFactory.class);
bind(DynamicOptions.DynamicBean.class)
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/CreateCheckIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/CreateCheckIT.java
index 704a1ca..67107ea 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/CreateCheckIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/CreateCheckIT.java
@@ -367,21 +367,6 @@
assertThat(response.getEntityContent()).isEqualTo("checks are not supported on a change edit");
}
- @Test
- public void creationOfCheckChangesETagOfChange() throws Exception {
- CheckerUuid checkerUuid = checkerOperations.newChecker().repository(project).create();
-
- String oldETag = parseChangeResource(patchSetId.changeId().toString()).getETag();
-
- CheckInput input = new CheckInput();
- input.checkerUuid = checkerUuid.get();
- input.state = CheckState.RUNNING;
- checksApiFactory.revision(patchSetId).create(input).get();
-
- String newETag = parseChangeResource(patchSetId.changeId().toString()).getETag();
- assertThat(newETag).isNotEqualTo(oldETag);
- }
-
// TODO(gerrit-team) More tests, especially for multiple checkers and PS and how commits behave
private Check getCheck(Project.NameKey project, PatchSet.Id patchSetId, CheckerUuid checkerUuid)
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java
index 98d58ce..6258169 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/UpdateCheckIT.java
@@ -418,30 +418,4 @@
assertThat(info.message).isEqualTo("some message");
assertThat(info.url).isEqualTo("https://www.example.com");
}
-
- @Test
- public void updateOfCheckChangesETagOfChange() throws Exception {
- String oldETag = parseChangeResource(patchSetId.changeId().toString()).getETag();
-
- CheckInput input = new CheckInput();
- input.state = CheckState.FAILED;
- checksApiFactory.revision(patchSetId).id(checkKey.checkerUuid()).update(input);
-
- String newETag = parseChangeResource(patchSetId.changeId().toString()).getETag();
- assertThat(newETag).isNotEqualTo(oldETag);
- }
-
- @Test
- public void noOpUpdateOfCheckDoesNotChangeETagOfChange() throws Exception {
- CheckInput input = new CheckInput();
- input.state = CheckState.FAILED;
- checksApiFactory.revision(patchSetId).id(checkKey.checkerUuid()).update(input);
-
- String oldETag = parseChangeResource(patchSetId.changeId().toString()).getETag();
-
- checksApiFactory.revision(patchSetId).id(checkKey.checkerUuid()).update(input);
-
- String newETag = parseChangeResource(patchSetId.changeId().toString()).getETag();
- assertThat(newETag).isEqualTo(oldETag);
- }
}