Adapt to new StorageException class name and package
Change-Id: I82e892afb7c9b41385e4ecde52e039fc932e6377
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandler.java
index 85dab30..278ba4e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandler.java
@@ -19,7 +19,6 @@
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.gerrit.server.util.OneOffRequestContext;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.slf4j.Logger;
@@ -47,9 +46,8 @@
* Dispatch an event in the local node, event will not be forwarded to the other node.
*
* @param event The event to dispatch
- * @throws OrmException If an error occur while retrieving the change the event belongs to.
*/
- public void dispatch(Event event) throws OrmException, PermissionBackendException {
+ public void dispatch(Event event) throws PermissionBackendException {
try (ManualRequestContext ctx = oneOffCtx.open()) {
Context.setForwardedEvent(true);
log.debug("dispatching event {}", event.getType());
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java
index 29bfa44..31256b7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java
@@ -20,7 +20,6 @@
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.AccountIndexEvent;
-import java.io.IOException;
import java.util.Optional;
/**
@@ -41,7 +40,7 @@
}
@Override
- protected void doIndex(Account.Id id, Optional<AccountIndexEvent> event) throws IOException {
+ protected void doIndex(Account.Id id, Optional<AccountIndexEvent> event) {
indexer.index(id);
log.debug("Account {} successfully indexed", id);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java
index 2d25c51..118c9df 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java
@@ -18,10 +18,8 @@
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.index.change.ChangeIndexer;
import com.google.gerrit.server.notedb.ChangeNotes;
-import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.gerrit.server.util.OneOffRequestContext;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
@@ -30,7 +28,6 @@
import com.googlesource.gerrit.plugins.multisite.index.ChangeChecker;
import com.googlesource.gerrit.plugins.multisite.index.ChangeCheckerImpl;
import com.googlesource.gerrit.plugins.multisite.index.ForwardedIndexExecutor;
-import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -70,69 +67,45 @@
}
@Override
- protected void doIndex(String id, Optional<ChangeIndexEvent> indexEvent)
- throws IOException, OrmException {
+ protected void doIndex(String id, Optional<ChangeIndexEvent> indexEvent) {
doIndex(id, indexEvent, 0);
}
- private void doIndex(String id, Optional<ChangeIndexEvent> indexEvent, int retryCount)
- throws IOException, OrmException {
- try {
- ChangeChecker checker = changeCheckerFactory.create(id);
- Optional<ChangeNotes> changeNotes = checker.getChangeNotes();
- if (changeNotes.isPresent()) {
- ChangeNotes notes = changeNotes.get();
- reindex(notes);
+ private void doIndex(String id, Optional<ChangeIndexEvent> indexEvent, int retryCount) {
+ ChangeChecker checker = changeCheckerFactory.create(id);
+ Optional<ChangeNotes> changeNotes = checker.getChangeNotes();
+ if (changeNotes.isPresent()) {
+ ChangeNotes notes = changeNotes.get();
+ reindex(notes);
- if (checker.isChangeUpToDate(indexEvent)) {
- if (retryCount > 0) {
- log.warn("Change {} has been eventually indexed after {} attempt(s)", id, retryCount);
- } else {
- log.debug("Change {} successfully indexed", id);
- }
+ if (checker.isChangeUpToDate(indexEvent)) {
+ if (retryCount > 0) {
+ log.warn("Change {} has been eventually indexed after {} attempt(s)", id, retryCount);
} else {
- log.warn(
- "Change {} seems too old compared to the event timestamp (event={} >> change-Ts={})",
- id,
- indexEvent,
- checker);
- rescheduleIndex(id, indexEvent, retryCount + 1);
+ log.debug("Change {} successfully indexed", id);
}
} else {
log.warn(
- "Change {} not present yet in local Git repository (event={}) after {} attempt(s)",
+ "Change {} seems too old compared to the event timestamp (event={} >> change-Ts={})",
id,
indexEvent,
- retryCount);
- if (!rescheduleIndex(id, indexEvent, retryCount + 1)) {
- log.error(
- "Change {} could not be found in the local Git repository (event={})",
- id,
- indexEvent);
- }
+ checker);
+ rescheduleIndex(id, indexEvent, retryCount + 1);
}
- } catch (Exception e) {
- if (isCausedByNoSuchChangeException(e)) {
- indexer.delete(parseChangeId(id));
- log.warn("Error trying to index Change {}. Deleted from index", id, e);
- return;
+ } else {
+ log.warn(
+ "Change {} not present yet in local Git repository (event={}) after {} attempt(s)",
+ id,
+ indexEvent,
+ retryCount);
+ if (!rescheduleIndex(id, indexEvent, retryCount + 1)) {
+ log.error(
+ "Change {} could not be found in the local Git repository (event={})", id, indexEvent);
}
-
- throw e;
}
}
- private static boolean isCausedByNoSuchChangeException(Throwable throwable) {
- while (throwable != null) {
- if (throwable instanceof NoSuchChangeException) {
- return true;
- }
- throwable = throwable.getCause();
- }
- return false;
- }
-
- private void reindex(ChangeNotes notes) throws IOException, OrmException {
+ private void reindex(ChangeNotes notes) {
try (ManualRequestContext ctx = oneOffCtx.open()) {
notes.reload();
indexer.index(notes.getChange());
@@ -169,7 +142,7 @@
}
@Override
- protected void doDelete(String id, Optional<ChangeIndexEvent> indexEvent) throws IOException {
+ protected void doDelete(String id, Optional<ChangeIndexEvent> indexEvent) {
indexer.delete(parseChangeId(id));
log.debug("Change {} successfully deleted from index", id);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
index 76ce260..368dffe 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
@@ -16,12 +16,10 @@
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.index.group.GroupIndexer;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.GroupIndexEvent;
-import java.io.IOException;
import java.util.Optional;
/**
@@ -41,8 +39,7 @@
}
@Override
- protected void doIndex(String uuid, Optional<GroupIndexEvent> event)
- throws IOException, OrmException {
+ protected void doIndex(String uuid, Optional<GroupIndexEvent> event) {
indexer.index(new AccountGroup.UUID(uuid));
log.debug("Group {} successfully indexed", uuid);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java
index ff2e111..e5f7e10 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java
@@ -22,7 +22,6 @@
import com.googlesource.gerrit.plugins.multisite.forwarder.events.ProjectIndexEvent;
import com.googlesource.gerrit.plugins.multisite.index.ForwardedIndexExecutor;
import com.googlesource.gerrit.plugins.multisite.index.ProjectChecker;
-import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -58,15 +57,14 @@
}
@Override
- protected void doIndex(String projectName, Optional<ProjectIndexEvent> event) throws IOException {
+ protected void doIndex(String projectName, Optional<ProjectIndexEvent> event) {
if (!attemptIndex(projectName, event)) {
log.warn("First Attempt failed, scheduling again after {} msecs", retryInterval);
rescheduleIndex(projectName, event, 1);
}
}
- public boolean attemptIndex(String projectName, Optional<ProjectIndexEvent> event)
- throws IOException {
+ public boolean attemptIndex(String projectName, Optional<ProjectIndexEvent> event) {
log.debug("Attempt to index project {}, event: [{}]", projectName, event);
final Project.NameKey projectNameKey = new Project.NameKey(projectName);
if (projectChecker.isProjectUpToDate(projectNameKey)) {
@@ -97,17 +95,13 @@
indexExecutor.schedule(
() -> {
Context.setForwardedEvent(true);
- try {
- if (!attemptIndex(projectName, event)) {
- log.warn(
- "Attempt {} to index project {} failed, scheduling again after {} msecs",
- retryCount,
- projectName,
- retryInterval);
- rescheduleIndex(projectName, event, retryCount + 1);
- }
- } catch (IOException e) {
- log.warn("Project {} could not be indexed", projectName, e);
+ if (!attemptIndex(projectName, event)) {
+ log.warn(
+ "Attempt {} to index project {} failed, scheduling again after {} msecs",
+ retryCount,
+ projectName,
+ retryInterval);
+ rescheduleIndex(projectName, event, retryCount + 1);
}
},
retryInterval,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandler.java
index 67662f6..de6b836 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandler.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.multisite.forwarder;
import com.google.common.util.concurrent.Striped;
-import com.google.gwtorm.server.OrmException;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.locks.Lock;
@@ -43,9 +42,9 @@
private final Striped<Lock> idLocks;
- protected abstract void doIndex(T id, Optional<E> indexEvent) throws IOException, OrmException;
+ protected abstract void doIndex(T id, Optional<E> indexEvent);
- protected abstract void doDelete(T id, Optional<E> indexEvent) throws IOException;
+ protected abstract void doDelete(T id, Optional<E> indexEvent);
protected ForwardedIndexingHandler(int lockStripes) {
idLocks = Striped.lock(lockStripes);
@@ -58,9 +57,8 @@
* @param operation The operation to do; index or delete
* @param event The index event details.
* @throws IOException If an error occur while indexing.
- * @throws OrmException If an error occur while retrieving a change related to the item to index
*/
- public void index(T id, Operation operation, Optional<E> event) throws IOException, OrmException {
+ public void index(T id, Operation operation, Optional<E> event) throws IOException {
log.debug("{} {} {}", operation, id, event);
try {
Context.setForwardedEvent(true);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java
index 1b0fea8..3646b3a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.multisite.index;
import com.google.gerrit.server.notedb.ChangeNotes;
-import com.google.gwtorm.server.OrmException;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.ChangeIndexEvent;
import java.io.IOException;
import java.util.Optional;
@@ -27,9 +26,8 @@
* Return the Change nodes read from ReviewDb or NoteDb.
*
* @return notes of the Change
- * @throws OrmException if ReviewDb or NoteDb cannot be opened
*/
- public Optional<ChangeNotes> getChangeNotes() throws OrmException;
+ public Optional<ChangeNotes> getChangeNotes();
/**
* Create a new index event POJO associated with the current Change.
@@ -40,21 +38,17 @@
* index
* @return new IndexEvent
* @throws IOException if the current Change cannot read
- * @throws OrmException if ReviewDb cannot be opened
*/
public Optional<ChangeIndexEvent> newIndexEvent(String projectName, int changeId, boolean deleted)
- throws IOException, OrmException;
+ throws IOException;
/**
* Check if the local Change is aligned with the indexEvent received.
*
* @param indexEvent indexing event
* @return true if the local Change is up-to-date, false otherwise.
- * @throws IOException if an I/O error occurred while reading the local Change
- * @throws OrmException if the local ReviewDb cannot be opened
*/
- public boolean isChangeUpToDate(Optional<ChangeIndexEvent> indexEvent)
- throws IOException, OrmException;
+ public boolean isChangeUpToDate(Optional<ChangeIndexEvent> indexEvent);
/**
* Return the last computed up-to-date Change time-stamp.
@@ -63,7 +57,6 @@
*
* @return the Change timestamp epoch in seconds
* @throws IOException if an I/O error occurred while reading the local Change
- * @throws OrmException if the local ReviewDb cannot be opened
*/
- public Optional<Long> getComputedChangeTs() throws IOException, OrmException;
+ public Optional<Long> getComputedChangeTs() throws IOException;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
index d96a8b2..92d622d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
@@ -14,6 +14,7 @@
package com.googlesource.gerrit.plugins.multisite.index;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Comment;
import com.google.gerrit.server.CommentsUtil;
@@ -22,7 +23,6 @@
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.gerrit.server.util.OneOffRequestContext;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.ChangeIndexEvent;
@@ -65,7 +65,7 @@
@Override
public Optional<ChangeIndexEvent> newIndexEvent(String projectName, int changeId, boolean deleted)
- throws IOException, OrmException {
+ throws IOException {
return getComputedChangeTs()
.map(
ts -> {
@@ -77,7 +77,7 @@
}
@Override
- public Optional<ChangeNotes> getChangeNotes() throws OrmException {
+ public Optional<ChangeNotes> getChangeNotes() {
try (ManualRequestContext ctx = oneOffReqCtx.open()) {
this.changeNotes = Optional.ofNullable(changeFinder.findOne(changeId));
return changeNotes;
@@ -85,8 +85,7 @@
}
@Override
- public boolean isChangeUpToDate(Optional<ChangeIndexEvent> indexEvent)
- throws IOException, OrmException {
+ public boolean isChangeUpToDate(Optional<ChangeIndexEvent> indexEvent) {
getComputedChangeTs();
if (!computedChangeTs.isPresent()) {
log.warn("Unable to compute last updated ts for change {}", changeId);
@@ -107,7 +106,7 @@
}
@Override
- public Optional<Long> getComputedChangeTs() throws IOException, OrmException {
+ public Optional<Long> getComputedChangeTs() {
if (!computedChangeTs.isPresent()) {
computedChangeTs = computeLastChangeTs();
}
@@ -116,17 +115,12 @@
@Override
public String toString() {
- try {
- return "change-id="
- + changeId
- + "@"
- + getComputedChangeTs().map(ChangeIndexEvent::format)
- + "/"
- + getBranchTargetSha();
- } catch (IOException | OrmException e) {
- log.error("Unable to render change {}", changeId, e);
- return "change-id=" + changeId;
- }
+ return "change-id="
+ + changeId
+ + "@"
+ + getComputedChangeTs().map(ChangeIndexEvent::format)
+ + "/"
+ + getBranchTargetSha();
}
private String getBranchTargetSha() {
@@ -146,7 +140,7 @@
}
}
- private Optional<Long> computeLastChangeTs() throws OrmException {
+ private Optional<Long> computeLastChangeTs() {
return getChangeNotes().map(notes -> getTsFromChangeAndDraftComments(notes));
}
@@ -158,7 +152,7 @@
Timestamp commentTs = comment.writtenOn;
changeTs = commentTs.after(changeTs) ? commentTs : changeTs;
}
- } catch (OrmException e) {
+ } catch (StorageException e) {
log.warn("Unable to access draft comments for change {}", change, e);
}
return changeTs.getTime() / 1000;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/AbstractKafkaSubcriber.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/AbstractKafkaSubcriber.java
index 25200ad..2dba261 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/AbstractKafkaSubcriber.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/AbstractKafkaSubcriber.java
@@ -15,12 +15,12 @@
package com.googlesource.gerrit.plugins.multisite.kafka.consumer;
import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.gerrit.server.util.OneOffRequestContext;
import com.google.gson.Gson;
-import com.google.gwtorm.server.OrmException;
import com.googlesource.gerrit.plugins.multisite.Configuration;
import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
@@ -126,7 +126,7 @@
} catch (IOException e) {
logger.atSevere().withCause(e).log(
"Malformed event '%s': [Exception: %s]", event.getHeader().getEventType());
- } catch (PermissionBackendException | OrmException e) {
+ } catch (PermissionBackendException | StorageException e) {
logger.atSevere().withCause(e).log(
"Cannot handle message %s: [Exception: %s]", event.getHeader().getEventType());
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/ForwardedEventRouter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/ForwardedEventRouter.java
index 616b40a..f7de8cc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/ForwardedEventRouter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/ForwardedEventRouter.java
@@ -15,11 +15,10 @@
package com.googlesource.gerrit.plugins.multisite.kafka.router;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gwtorm.server.OrmException;
import com.googlesource.gerrit.plugins.multisite.forwarder.CacheNotFoundException;
import java.io.IOException;
public interface ForwardedEventRouter<EventType> {
void route(EventType sourceEvent)
- throws IOException, OrmException, PermissionBackendException, CacheNotFoundException;
+ throws IOException, PermissionBackendException, CacheNotFoundException;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java
index e859f40..818777c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java
@@ -18,7 +18,6 @@
import static com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexingHandler.Operation.INDEX;
import com.google.gerrit.reviewdb.client.Account;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexAccountHandler;
@@ -54,7 +53,7 @@
}
@Override
- public void route(IndexEvent sourceEvent) throws IOException, OrmException {
+ public void route(IndexEvent sourceEvent) throws IOException {
if (sourceEvent instanceof ChangeIndexEvent) {
ChangeIndexEvent changeIndexEvent = (ChangeIndexEvent) sourceEvent;
ForwardedIndexingHandler.Operation operation = changeIndexEvent.deleted ? DELETE : INDEX;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/StreamEventRouter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/StreamEventRouter.java
index ed65662..39d96bc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/StreamEventRouter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/StreamEventRouter.java
@@ -16,7 +16,6 @@
import com.google.gerrit.server.events.Event;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedEventHandler;
@@ -31,7 +30,7 @@
}
@Override
- public void route(Event sourceEvent) throws OrmException, PermissionBackendException {
+ public void route(Event sourceEvent) throws PermissionBackendException {
streamEventHandler.dispatch(sourceEvent);
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java
index 3b01c61..5c36ada 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java
@@ -19,11 +19,11 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.server.events.Event;
import com.google.gerrit.server.events.EventDispatcher;
import com.google.gerrit.server.events.ProjectCreatedEvent;
import com.google.gerrit.server.util.OneOffRequestContext;
-import com.google.gwtorm.server.OrmException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -81,7 +81,7 @@
(Answer<Void>)
invocation -> {
assertThat(Context.isForwardedEvent()).isTrue();
- throw new OrmException("someMessage");
+ throw new StorageException("someMessage");
})
.when(dispatcherMock)
.postEvent(event);
@@ -89,8 +89,8 @@
assertThat(Context.isForwardedEvent()).isFalse();
try {
handler.dispatch(event);
- fail("should have throw an OrmException");
- } catch (OrmException e) {
+ fail("should have throw an StorageException");
+ } catch (StorageException e) {
assertThat(e.getMessage()).isEqualTo("someMessage");
}
assertThat(Context.isForwardedEvent()).isFalse();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
index d6c3576..0a910c5 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
@@ -24,6 +24,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.git.GitRepositoryManager;
@@ -32,7 +33,6 @@
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.gerrit.server.util.OneOffRequestContext;
import com.google.gerrit.server.util.time.TimeUtil;
-import com.google.gwtorm.server.OrmException;
import com.googlesource.gerrit.plugins.multisite.Configuration;
import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexingHandler.Operation;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.ChangeIndexEvent;
@@ -58,8 +58,8 @@
private static String TEST_CHANGE_ID = TEST_PROJECT + "~" + TEST_CHANGE_NUMBER;
private static final boolean CHANGE_EXISTS = true;
private static final boolean CHANGE_DOES_NOT_EXIST = false;
- private static final boolean DO_NOT_THROW_IO_EXCEPTION = false;
- private static final boolean THROW_IO_EXCEPTION = true;
+ private static final boolean DO_NOT_THROW_STORAGE_EXCEPTION = false;
+ private static final boolean THROW_STORAGE_EXCEPTION = true;
private static final boolean CHANGE_UP_TO_DATE = true;
private static final boolean CHANGE_OUTDATED = false;
@@ -123,9 +123,9 @@
}
@Test
- public void indexerThrowsIOExceptionTryingToIndexChange() throws Exception {
- setupChangeAccessRelatedMocks(CHANGE_EXISTS, THROW_IO_EXCEPTION, CHANGE_UP_TO_DATE);
- exception.expect(IOException.class);
+ public void indexerThrowsStorageExceptionTryingToIndexChange() throws Exception {
+ setupChangeAccessRelatedMocks(CHANGE_EXISTS, THROW_STORAGE_EXCEPTION, CHANGE_UP_TO_DATE);
+ exception.expect(StorageException.class);
handler.index(TEST_CHANGE_ID, Operation.INDEX, Optional.empty());
}
@@ -176,17 +176,17 @@
private void setupChangeAccessRelatedMocks(boolean changeExist, boolean changeUpToDate)
throws Exception {
- setupChangeAccessRelatedMocks(changeExist, DO_NOT_THROW_IO_EXCEPTION, changeUpToDate);
+ setupChangeAccessRelatedMocks(changeExist, DO_NOT_THROW_STORAGE_EXCEPTION, changeUpToDate);
}
private void setupChangeAccessRelatedMocks(
- boolean changeExists, boolean ioException, boolean changeIsUpToDate)
- throws IOException, OrmException {
+ boolean changeExists, boolean storageException, boolean changeIsUpToDate)
+ throws StorageException {
if (changeExists) {
when(changeCheckerFactoryMock.create(TEST_CHANGE_ID)).thenReturn(changeCheckerPresentMock);
when(changeCheckerPresentMock.getChangeNotes()).thenReturn(Optional.of(changeNotes));
- if (ioException) {
- doThrow(new IOException("io-error")).when(indexerMock).index(any(Change.class));
+ if (storageException) {
+ doThrow(new StorageException("io-error")).when(indexerMock).index(any(Change.class));
}
}