Simplify method signature
Remove the redundant `ClientProtocolException`, this is a subclass of
the `IOException` which is already part of the method signature.
Change-Id: Idf0bf17ca78ae6c3b9c4538914ed608557ef4731
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
index b88db69..13484b1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
@@ -54,7 +54,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
-import org.apache.http.client.ClientProtocolException;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.InvalidObjectIdException;
@@ -504,7 +503,7 @@
private HttpResult initProject(
Project.NameKey project, URIish uri, FetchApiClient fetchClient, HttpResult result)
- throws IOException, ClientProtocolException {
+ throws IOException {
HttpResult initProjectResult = fetchClient.initProject(project, uri);
if (initProjectResult.isSuccessful()) {
result = fetchClient.callFetch(project, FetchOne.ALL_REFS, uri);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchApiClient.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchApiClient.java
index 1991260..1b3dc43 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchApiClient.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchApiClient.java
@@ -22,7 +22,6 @@
import com.googlesource.gerrit.plugins.replication.pull.api.data.RevisionData;
import java.io.IOException;
import java.util.List;
-import org.apache.http.client.ClientProtocolException;
import org.eclipse.jgit.transport.URIish;
public interface FetchApiClient {
@@ -33,10 +32,10 @@
HttpResult callFetch(
Project.NameKey project, String refName, URIish targetUri, long startTimeNanos)
- throws ClientProtocolException, IOException;
+ throws IOException;
default HttpResult callFetch(Project.NameKey project, String refName, URIish targetUri)
- throws ClientProtocolException, IOException {
+ throws IOException {
return callFetch(project, refName, targetUri, MILLISECONDS.toNanos(System.currentTimeMillis()));
}
@@ -53,7 +52,7 @@
boolean isDelete,
RevisionData revisionData,
URIish targetUri)
- throws ClientProtocolException, IOException;
+ throws IOException;
HttpResult callSendObjects(
NameKey project,
@@ -61,5 +60,5 @@
long eventCreatedOn,
List<RevisionData> revisionData,
URIish targetUri)
- throws ClientProtocolException, IOException;
+ throws IOException;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClient.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClient.java
index b606ba8..3d041b1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClient.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClient.java
@@ -48,7 +48,6 @@
import org.apache.http.ParseException;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
@@ -177,7 +176,7 @@
boolean isDelete,
@Nullable RevisionData revisionData,
URIish targetUri)
- throws ClientProtocolException, IOException {
+ throws IOException {
if (!isDelete) {
requireNonNull(
@@ -202,7 +201,7 @@
long eventCreatedOn,
List<RevisionData> revisionData,
URIish targetUri)
- throws ClientProtocolException, IOException {
+ throws IOException {
if (revisionData.size() == 1) {
return callSendObject(
project, refName, eventCreatedOn, false, revisionData.get(0), targetUri);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java
index 9b7e8c1..15e2c1b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java
@@ -59,7 +59,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import org.apache.http.client.ClientProtocolException;
import org.eclipse.jgit.errors.LargeObjectException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.storage.file.FileBasedConfig;
@@ -174,7 +173,7 @@
}
@Test
- public void shouldCallSendObjectWhenMetaRef() throws ClientProtocolException, IOException {
+ public void shouldCallSendObjectWhenMetaRef() throws IOException {
Event event = new TestEvent("refs/changes/01/1/meta");
objectUnderTest.start();
objectUnderTest.onEvent(event);
@@ -183,8 +182,7 @@
}
@Test
- public void shouldIgnoreEventWhenIsNotLocalInstanceId()
- throws ClientProtocolException, IOException {
+ public void shouldIgnoreEventWhenIsNotLocalInstanceId() throws IOException {
Event event = new TestEvent();
event.instanceId = FOREIGN_INSTANCE_ID;
objectUnderTest.start();
@@ -221,7 +219,7 @@
}
@Test
- public void shouldCallSendObjectWhenPatchSetRef() throws ClientProtocolException, IOException {
+ public void shouldCallSendObjectWhenPatchSetRef() throws IOException {
Event event = new TestEvent("refs/changes/01/1/1");
objectUnderTest.start();
objectUnderTest.onEvent(event);
@@ -231,7 +229,7 @@
@Test
public void shouldFallbackToCallFetchWhenIOException()
- throws ClientProtocolException, IOException, LargeObjectException, RefUpdateException {
+ throws IOException, LargeObjectException, RefUpdateException {
Event event = new TestEvent("refs/changes/01/1/meta");
objectUnderTest.start();
@@ -244,7 +242,7 @@
@Test
public void shouldFallbackToCallFetchWhenLargeRef()
- throws ClientProtocolException, IOException, LargeObjectException, RefUpdateException {
+ throws IOException, LargeObjectException, RefUpdateException {
Event event = new TestEvent("refs/changes/01/1/1");
objectUnderTest.start();
@@ -256,8 +254,7 @@
}
@Test
- public void shouldFallbackToCallFetchWhenParentObjectIsMissing()
- throws ClientProtocolException, IOException {
+ public void shouldFallbackToCallFetchWhenParentObjectIsMissing() throws IOException {
Event event = new TestEvent("refs/changes/01/1/1");
objectUnderTest.start();
@@ -273,7 +270,7 @@
@Test
public void shouldFallbackToApplyAllParentObjectsWhenParentObjectIsMissingOnMetaRef()
- throws ClientProtocolException, IOException {
+ throws IOException {
Event event = new TestEvent("refs/changes/01/1/meta");
objectUnderTest.start();
@@ -299,7 +296,7 @@
@Test
public void shouldFallbackToApplyAllParentObjectsWhenParentObjectIsMissingOnAllowedRefs()
- throws ClientProtocolException, IOException {
+ throws IOException {
String refName = "refs/tags/test-tag";
Event event = new TestEvent(refName);
objectUnderTest.start();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java
index cdb238e..5de7e7d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java
@@ -39,7 +39,6 @@
import java.nio.ByteBuffer;
import java.util.Collections;
import org.apache.http.Header;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
@@ -150,8 +149,7 @@
protected abstract void assertAuthentication(HttpRequestBase httpRequest);
@Test
- public void shouldCallFetchEndpoint()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldCallFetchEndpoint() throws IOException, URISyntaxException {
objectUnderTest.callFetch(Project.nameKey("test_repo"), refName, new URIish(api));
@@ -167,8 +165,7 @@
}
@Test
- public void shouldByDefaultCallSyncFetchForAllRefs()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldByDefaultCallSyncFetchForAllRefs() throws IOException, URISyntaxException {
objectUnderTest.callFetch(Project.nameKey("test_repo"), refName, new URIish(api));
@@ -179,8 +176,7 @@
}
@Test
- public void shouldCallAsyncFetchForAllRefs()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldCallAsyncFetchForAllRefs() throws IOException, URISyntaxException {
when(config.getStringList("replication", null, "syncRefs"))
.thenReturn(new String[] {"NO_SYNC_REFS"});
@@ -205,8 +201,7 @@
}
@Test
- public void shouldCallSyncFetchOnlyForMetaRef()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldCallSyncFetchOnlyForMetaRef() throws IOException, URISyntaxException {
String metaRefName = "refs/changes/01/101/meta";
String expectedMetaRefPayload =
"{\"label\":\"Replication\", \"ref_name\": \"" + metaRefName + "\", \"async\":false}";
@@ -237,8 +232,7 @@
}
@Test
- public void shouldCallFetchEndpointWithPayload()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldCallFetchEndpointWithPayload() throws IOException, URISyntaxException {
objectUnderTest.callFetch(Project.nameKey("test_repo"), refName, new URIish(api));
@@ -249,8 +243,7 @@
}
@Test
- public void shouldSetContentTypeHeader()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldSetContentTypeHeader() throws IOException, URISyntaxException {
objectUnderTest.callFetch(Project.nameKey("test_repo"), refName, new URIish(api));
@@ -262,8 +255,7 @@
}
@Test
- public void shouldCallSendObjectEndpoint()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldCallSendObjectEndpoint() throws IOException, URISyntaxException {
objectUnderTest.callSendObject(
Project.nameKey("test_repo"),
@@ -285,8 +277,7 @@
}
@Test
- public void shouldCallSendObjectEndpointWithPayload()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldCallSendObjectEndpointWithPayload() throws IOException, URISyntaxException {
objectUnderTest.callSendObject(
Project.nameKey("test_repo"),
@@ -303,8 +294,7 @@
}
@Test
- public void shouldSetContentTypeHeaderForSendObjectCall()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldSetContentTypeHeaderForSendObjectCall() throws IOException, URISyntaxException {
objectUnderTest.callFetch(Project.nameKey("test_repo"), refName, new URIish(api));
@@ -364,8 +354,7 @@
}
@Test
- public void shouldUseReplicationLabelWhenProvided()
- throws ClientProtocolException, IOException, URISyntaxException {
+ public void shouldUseReplicationLabelWhenProvided() throws IOException, URISyntaxException {
when(config.getString("replication", null, "instanceLabel")).thenReturn(instanceId);
FetchRestApiClient objectUnderTest =
new FetchRestApiClient(
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBasicAuthenticationTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBasicAuthenticationTest.java
index 644afce..2b03d3f 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBasicAuthenticationTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBasicAuthenticationTest.java
@@ -23,7 +23,6 @@
import java.util.Optional;
import org.apache.http.Header;
import org.apache.http.HttpHeaders;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpRequestBase;
import org.eclipse.jgit.transport.CredentialItem;
import org.junit.Before;
@@ -36,7 +35,7 @@
public class FetchRestApiClientWithBasicAuthenticationTest extends FetchRestApiClientBase {
@Before
- public void setup() throws ClientProtocolException, IOException {
+ public void setup() throws IOException {
when(bearerTokenProvider.get()).thenReturn(Optional.empty());
when(credentialProvider.supports(any()))
.thenAnswer(
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBearerTokenTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBearerTokenTest.java
index 90d71ad..a79f4b8 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBearerTokenTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientWithBearerTokenTest.java
@@ -23,7 +23,6 @@
import java.util.Optional;
import org.apache.http.Header;
import org.apache.http.HttpHeaders;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpRequestBase;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -33,7 +32,7 @@
public class FetchRestApiClientWithBearerTokenTest extends FetchRestApiClientBase {
@Before
- public void setup() throws ClientProtocolException, IOException {
+ public void setup() throws IOException {
when(bearerTokenProvider.get()).thenReturn(Optional.of("some-bearer-token"));
when(replicationConfig.getConfig()).thenReturn(config);
when(config.getStringList("replication", null, "syncRefs")).thenReturn(new String[0]);