Replace anonymous classes with lambdas
Change-Id: I860562d8bc039f278f6b982258a08c4a1495edb7
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java
index 5dc7ff3..46b48ae 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java
@@ -43,17 +43,13 @@
}
private static Provider<Registry<ConnectionSocketFactory>> socketFactoryProvider() {
- return new Provider<Registry<ConnectionSocketFactory>>() {
- @Override
- public Registry<ConnectionSocketFactory> get() {
- return RegistryBuilder.<ConnectionSocketFactory>create()
+ return () ->
+ RegistryBuilder.<ConnectionSocketFactory>create()
.register(
"https",
new SSLConnectionSocketFactory(buildSslContext(), NoopHostnameVerifier.INSTANCE))
.register("http", PlainConnectionSocketFactory.INSTANCE)
.build();
- }
- };
}
private static SSLContext buildSslContext() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java
index 57e25a2..1d95639 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java
@@ -32,16 +32,12 @@
}
private static Provider<Registry<ConnectionSocketFactory>> socketFactoryProvider() {
- return new Provider<Registry<ConnectionSocketFactory>>() {
- @Override
- public Registry<ConnectionSocketFactory> get() {
- return RegistryBuilder.<ConnectionSocketFactory>create()
+ return () ->
+ RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", SSLConnectionSocketFactory.getSocketFactory())
// the following registration is added for case when one enables SSL verification
// for HTTP remote
.register("http", PlainConnectionSocketFactory.INSTANCE)
.build();
- }
- };
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java
index 4bcea8d..e5de105 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java
@@ -33,9 +33,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
@RunWith(MockitoJUnitRunner.class)
public class PostTaskTest {
@@ -116,12 +114,9 @@
when(session.post(eq(remote), eq(content))).thenThrow(IOException.class);
when(executor.schedule(task, RETRY_INTERVAL, TimeUnit.MILLISECONDS))
.then(
- new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- task.run();
- return null;
- }
+ invocation -> {
+ task.run();
+ return null;
});
task.run();
verify(executor, times(MAX_TRIES - 1)).schedule(task, RETRY_INTERVAL, TimeUnit.MILLISECONDS);