This is an automated email from the ASF dual-hosted git repository.

hyunkun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new d7d4d67  Optimize part of the code in 
AnnotatedBeanDefinitionRegistryUtils.java (#4590)
d7d4d67 is described below

commit d7d4d67e12b0e59fc671a6dde62cfb29c3afa24f
Author: yidadi <1056027...@qq.com>
AuthorDate: Thu Jul 18 22:44:52 2019 +0800

    Optimize part of the code in AnnotatedBeanDefinitionRegistryUtils.java 
(#4590)
    
    * Optimize part of the code
---
 .../config/spring/util/AnnotatedBeanDefinitionRegistryUtils.java   | 4 +---
 .../org/apache/dubbo/remoting/transport/netty4/NettyClient.java    | 7 +------
 .../src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java       | 4 ----
 .../src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java | 4 +---
 4 files changed, 3 insertions(+), 16 deletions(-)

diff --git 
a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotatedBeanDefinitionRegistryUtils.java
 
b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotatedBeanDefinitionRegistryUtils.java
index c46ca8a..3753b61 100644
--- 
a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotatedBeanDefinitionRegistryUtils.java
+++ 
b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotatedBeanDefinitionRegistryUtils.java
@@ -94,8 +94,6 @@ public abstract class AnnotatedBeanDefinitionRegistryUtils {
             return;
         }
 
-        boolean debugEnabled = logger.isDebugEnabled();
-
         // Remove all annotated-classes that have been registered
         Iterator<Class<?>> iterator = new 
ArrayList<>(asList(annotatedClasses)).iterator();
 
@@ -108,7 +106,7 @@ public abstract class AnnotatedBeanDefinitionRegistryUtils {
 
         AnnotatedBeanDefinitionReader reader = new 
AnnotatedBeanDefinitionReader(registry);
 
-        if (debugEnabled) {
+        if (logger.isDebugEnabled()) {
             logger.debug(registry.getClass().getSimpleName() + " will register 
annotated classes : " + asList(annotatedClasses) + " .");
         }
 
diff --git 
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
 
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
index 3c32a9c..64b98d2 100644
--- 
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
+++ 
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
@@ -96,12 +96,7 @@ public class NettyClient extends AbstractClient {
                 //.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, getTimeout())
                 .channel(NioSocketChannel.class);
 
-        if (getConnectTimeout() < 3000) {
-            bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000);
-        } else {
-            bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 
getConnectTimeout());
-        }
-
+        bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Math.max(3000, 
getConnectTimeout()));
         bootstrap.handler(new ChannelInitializer() {
 
             @Override
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java
index f8f6743..adbc7fc 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java
@@ -16,14 +16,10 @@
  */
 package org.apache.dubbo.rpc;
 
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 public class AsyncContextImpl implements AsyncContext {
-    private static final Logger logger = 
LoggerFactory.getLogger(AsyncContextImpl.class);
 
     private final AtomicBoolean started = new AtomicBoolean(false);
     private final AtomicBoolean stopped = new AtomicBoolean(false);
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java
index ae2bc06..f7fd91d 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java
@@ -26,7 +26,6 @@ import org.apache.dubbo.rpc.Filter;
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Result;
-import org.apache.dubbo.rpc.RpcContext;
 import org.apache.dubbo.rpc.RpcException;
 import org.apache.dubbo.rpc.support.AccessLogData;
 
@@ -155,14 +154,13 @@ public class AccessLogFilter implements Filter {
                  iterator.hasNext();
                  iterator.remove()) {
                 writer.write(iterator.next().getLogMessage());
-                writer.write("\r\n");
+                writer.write(System.getProperty("line.separator"));
             }
             writer.flush();
         }
     }
 
     private AccessLogData buildAccessLogData(Invoker<?> invoker, Invocation 
inv) {
-        RpcContext context = RpcContext.getContext();
         AccessLogData logData = AccessLogData.newLogData();
         logData.setServiceName(invoker.getInterface().getName());
         logData.setMethodName(inv.getMethodName());

Reply via email to