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

huxing 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 b4afeb9  follow up for pr#4339, remove the space (#4591)
b4afeb9 is described below

commit b4afeb982b943ca8c6bbd261302a9e161c2e98a9
Author: Ian Luo <[email protected]>
AuthorDate: Thu Jul 18 09:44:03 2019 +0800

    follow up for pr#4339, remove the space (#4591)
---
 .../extension/AdaptiveClassCodeGenerator.java      | 84 +++++++++++-----------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java
index 239f862..610534f 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java
@@ -31,56 +31,56 @@ import org.apache.dubbo.common.utils.StringUtils;
  * Code generator for Adaptive class
  */
 public class AdaptiveClassCodeGenerator {
-    
+
     private static final Logger logger = 
LoggerFactory.getLogger(AdaptiveClassCodeGenerator.class);
 
     private static final String CLASSNAME_INVOCATION = 
"org.apache.dubbo.rpc.Invocation";
-    
+
     private static final String CODE_PACKAGE = "package %s;\n";
-    
+
     private static final String CODE_IMPORTS = "import %s;\n";
-    
+
     private static final String CODE_CLASS_DECLARATION = "public class 
%s$Adaptive implements %s {\n";
-    
+
     private static final String CODE_METHOD_DECLARATION = "public %s %s(%s) %s 
{\n%s}\n";
-    
+
     private static final String CODE_METHOD_ARGUMENT = "%s arg%d";
-    
+
     private static final String CODE_METHOD_THROWS = "throws %s";
-    
+
     private static final String CODE_UNSUPPORTED = "throw new 
UnsupportedOperationException(\"The method %s of interface %s is not adaptive 
method!\");\n";
-    
+
     private static final String CODE_URL_NULL_CHECK = "if (arg%d == null) 
throw new IllegalArgumentException(\"url == null\");\n%s url = arg%d;\n";
-    
+
     private static final String CODE_EXT_NAME_ASSIGNMENT = "String extName = 
%s;\n";
-    
+
     private static final String CODE_EXT_NAME_NULL_CHECK = "if(extName == 
null) "
                     + "throw new IllegalStateException(\"Failed to get 
extension (%s) name from url (\" + url.toString() + \") use keys(%s)\");\n";
-    
+
     private static final String CODE_INVOCATION_ARGUMENT_NULL_CHECK = "if 
(arg%d == null) throw new IllegalArgumentException(\"invocation == null\"); "
                     + "String methodName = arg%d.getMethodName();\n";
-    
-    
+
+
     private static final String CODE_EXTENSION_ASSIGNMENT = "%s extension = 
(%<s)%s.getExtensionLoader(%s.class).getExtension(extName);\n";
 
-    private static final String CODE_EXTENSION_METHOD_INVOKE_ARGUMENT = "arg%d 
";
+    private static final String CODE_EXTENSION_METHOD_INVOKE_ARGUMENT = 
"arg%d";
 
     private final Class<?> type;
-    
+
     private String defaultExtName;
-    
+
     public AdaptiveClassCodeGenerator(Class<?> type, String defaultExtName) {
         this.type = type;
         this.defaultExtName = defaultExtName;
     }
-    
+
     /**
      * test if given type has at least one method annotated with 
<code>SPI</code>
      */
     private boolean hasAdaptiveMethod() {
         return Arrays.stream(type.getMethods()).anyMatch(m -> 
m.isAnnotationPresent(Adaptive.class));
     }
-    
+
     /**
      * generate and return class code
      */
@@ -94,13 +94,13 @@ public class AdaptiveClassCodeGenerator {
         code.append(generatePackageInfo());
         code.append(generateImports());
         code.append(generateClassDeclaration());
-        
+
         Method[] methods = type.getMethods();
         for (Method method : methods) {
             code.append(generateMethod(method));
         }
         code.append("}");
-        
+
         if (logger.isDebugEnabled()) {
             logger.debug(code.toString());
         }
@@ -127,18 +127,18 @@ public class AdaptiveClassCodeGenerator {
     private String generateClassDeclaration() {
         return String.format(CODE_CLASS_DECLARATION, type.getSimpleName(), 
type.getCanonicalName());
     }
-    
+
     /**
-     * generate method not annotated with Adaptive with throwing unsupported 
exception 
+     * generate method not annotated with Adaptive with throwing unsupported 
exception
      */
     private String generateUnsupported(Method method) {
         return String.format(CODE_UNSUPPORTED, method, type.getName());
     }
-    
+
     /**
      * get index of parameter with type URL
      */
-    private int getUrlTypeIndex(Method method) {            
+    private int getUrlTypeIndex(Method method) {
         int urlTypeIndex = -1;
         Class<?>[] pts = method.getParameterTypes();
         for (int i = 0; i < pts.length; ++i) {
@@ -149,7 +149,7 @@ public class AdaptiveClassCodeGenerator {
         }
         return urlTypeIndex;
     }
-    
+
     /**
      * generate method declaration
      */
@@ -171,9 +171,9 @@ public class AdaptiveClassCodeGenerator {
                         .mapToObj(i -> String.format(CODE_METHOD_ARGUMENT, 
pts[i].getCanonicalName(), i))
                         .collect(Collectors.joining(", "));
     }
-    
+
     /**
-     * generate method throws 
+     * generate method throws
      */
     private String generateMethodThrows(Method method) {
         Class<?>[] ets = method.getExceptionTypes();
@@ -184,14 +184,14 @@ public class AdaptiveClassCodeGenerator {
             return "";
         }
     }
-    
+
     /**
-     * generate method URL argument null check 
+     * generate method URL argument null check
      */
     private String generateUrlNullCheck(int index) {
         return String.format(CODE_URL_NULL_CHECK, index, URL.class.getName(), 
index);
     }
-    
+
     /**
      * generate method content
      */
@@ -202,7 +202,7 @@ public class AdaptiveClassCodeGenerator {
             return generateUnsupported(method);
         } else {
             int urlTypeIndex = getUrlTypeIndex(method);
-            
+
             // found parameter in URL type
             if (urlTypeIndex != -1) {
                 // Null Point check
@@ -215,19 +215,19 @@ public class AdaptiveClassCodeGenerator {
             String[] value = getMethodAdaptiveValue(adaptiveAnnotation);
 
             boolean hasInvocation = hasInvocationArgument(method);
-            
+
             code.append(generateInvocationArgumentNullCheck(method));
-            
+
             code.append(generateExtNameAssignment(value, hasInvocation));
             // check extName == null?
             code.append(generateExtNameNullCheck(value));
-            
+
             code.append(generateExtensionAssignment());
 
             // return statement
             code.append(generateReturnAndInvocation(method));
         }
-        
+
         return code.toString();
     }
 
@@ -279,7 +279,7 @@ public class AdaptiveClassCodeGenerator {
                 }
             }
         }
-        
+
         return String.format(CODE_EXT_NAME_ASSIGNMENT, getNameCode);
     }
 
@@ -302,7 +302,7 @@ public class AdaptiveClassCodeGenerator {
 
         return returnStatement + String.format("extension.%s(%s);\n", 
method.getName(), args);
     }
-    
+
     /**
      * test if method has argument of type <code>Invocation</code>
      */
@@ -310,7 +310,7 @@ public class AdaptiveClassCodeGenerator {
         Class<?>[] pts = method.getParameterTypes();
         return Arrays.stream(pts).anyMatch(p -> 
CLASSNAME_INVOCATION.equals(p.getName()));
     }
-    
+
     /**
      * generate code to test argument of type <code>Invocation</code> is null
      */
@@ -343,7 +343,7 @@ public class AdaptiveClassCodeGenerator {
      */
     private String generateUrlAssignmentIndirectly(Method method) {
         Class<?>[] pts = method.getParameterTypes();
-        
+
         // find URL getter method
         for (int i = 0; i < pts.length; ++i) {
             for (Method m : pts[i].getMethods()) {
@@ -357,7 +357,7 @@ public class AdaptiveClassCodeGenerator {
                 }
             }
         }
-        
+
         // getter method not found, throw
         throw new IllegalStateException("Failed to create adaptive class for 
interface " + type.getName()
                         + ": not found url parameter or url attribute in 
parameters of method " + method.getName());
@@ -380,5 +380,5 @@ public class AdaptiveClassCodeGenerator {
         code.append(String.format("%s url = arg%d.%s();\n", 
URL.class.getName(), index, method));
         return code.toString();
     }
-    
+
 }

Reply via email to