diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java b/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java index 166c19288e6..74cf09a142b 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java @@ -130,12 +130,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(Date.class, e); // init decoder map. - Decoder d = new Decoder() { - @Override - public Object decode(Object jv) { - return jv.toString(); - } - }; + Decoder d = Object::toString; GlobalDecoderMap.put(String.class, d); d = new Decoder() { diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/CompletableFutureTaskTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/CompletableFutureTaskTest.java index 27d7da6e8b8..4513721366a 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/CompletableFutureTaskTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/CompletableFutureTaskTest.java @@ -78,12 +78,7 @@ public void testListener() throws InterruptedException { }, executor); final CountDownLatch countDownLatch = new CountDownLatch(1); - completableFuture.thenRunAsync(new Runnable() { - @Override - public void run() { - countDownLatch.countDown(); - } - }); + completableFuture.thenRunAsync(countDownLatch::countDown); countDownLatch.await(); } diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/ExecutionListTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/ExecutionListTest.java index bd1900e6bb0..417b4a49dab 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/ExecutionListTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/concurrent/ExecutionListTest.java @@ -54,12 +54,7 @@ public void testAddRunnableToExecutor() { @Test public void testExecuteRunnableWithDefaultExecutor() throws InterruptedException { final CountDownLatch countDownLatch = new CountDownLatch(1); - this.executionList.add(new Runnable() { - @Override - public void run() { - countDownLatch.countDown(); - } - }, null); + this.executionList.add(countDownLatch::countDown, null); this.executionList.execute(); countDownLatch.await(); diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/InternalThreadLocalTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/InternalThreadLocalTest.java index 631d12152bc..caeda65ea8c 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/InternalThreadLocalTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/InternalThreadLocalTest.java @@ -49,12 +49,7 @@ protected Integer initialValue() throws Exception { }; for (int i = 0; i < THREADS; i++) { - Thread t = new Thread(new Runnable() { - @Override - public void run() { - internalThreadLocal.get(); - } - }); + Thread t = new Thread(internalThreadLocal::get); t.start(); } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index 579acd0d437..07d7d78fe8f 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -206,12 +206,7 @@ public synchronized void export() { } if (delay != null && delay > 0) { - delayExportExecutor.schedule(new Runnable() { - @Override - public void run() { - doExport(); - } - }, delay, TimeUnit.MILLISECONDS); + delayExportExecutor.schedule(this::doExport, delay, TimeUnit.MILLISECONDS); } else { doExport(); } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java index 61360f07749..fc2f86d31ea 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java @@ -245,12 +245,7 @@ public List lookup(URL url) { } } else { final AtomicReference> reference = new AtomicReference>(); - NotifyListener listener = new NotifyListener() { - @Override - public void notify(List urls) { - reference.set(urls); - } - }; + NotifyListener listener = reference::set; subscribe(url, listener); // Subscribe logic guarantees the first notify to return List urls = reference.get(); if (urls != null && !urls.isEmpty()) { diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java index 4f7faeb86f0..784377a6605 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java @@ -114,13 +114,7 @@ public void doClose() { @Override public IZkChildListener createTargetChildListener(String path, final ChildListener listener) { - return new IZkChildListener() { - @Override - public void handleChildChange(String parentPath, List currentChilds) - throws Exception { - listener.childChanged(parentPath, currentChilds); - } - }; + return listener::childChanged; } @Override diff --git a/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java index a9c78c7acf7..8a28cc02c9a 100644 --- a/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java +++ b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java @@ -22,12 +22,9 @@ import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.protocol.AbstractProxyProtocol; -import org.aopalliance.intercept.MethodInvocation; import org.springframework.remoting.RemoteAccessException; import org.springframework.remoting.rmi.RmiProxyFactoryBean; import org.springframework.remoting.rmi.RmiServiceExporter; -import org.springframework.remoting.support.RemoteInvocation; -import org.springframework.remoting.support.RemoteInvocationFactory; import java.io.IOException; import java.net.SocketTimeoutException; @@ -80,12 +77,7 @@ protected T doRefer(final Class serviceType, final URL url) throws RpcExc // RMI needs extra parameter since it uses customized remote invocation object if (url.getParameter(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion()).equals(Version.getProtocolVersion())) { // Check dubbo version on provider, this feature only support - rmiProxyFactoryBean.setRemoteInvocationFactory(new RemoteInvocationFactory() { - @Override - public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { - return new RmiRemoteInvocation(methodInvocation); - } - }); + rmiProxyFactoryBean.setRemoteInvocationFactory(RmiRemoteInvocation::new); } rmiProxyFactoryBean.setServiceUrl(url.toIdentityString()); rmiProxyFactoryBean.setServiceInterface(serviceType);