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

mercyblitz 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 56f1c18  2.7.6 Refactor + Enhancement (#5772)
56f1c18 is described below

commit 56f1c1861b146a37e3d49541781532fa2757f0e8
Author: Mercy Ma <mercybl...@gmail.com>
AuthorDate: Fri Feb 21 19:56:32 2020 +0800

    2.7.6 Refactor + Enhancement (#5772)
    
    * Polish /apache/dubbo#5745 : Increasing the stack size in the start.sh
    
    * Polish /apache/dubbo#5297 : Only one of the multiple registration centers 
using nacos can register
    
    * Polish /apache/dubbo#5442 : 
VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费
    
    * Polish /apache/dubbo#5442 : Merge upstream/master
    
    * Polish /apache/dubbo##5239 : Mock字段注入异常
    
    * Polish /apache/dubbo##5239 : Mock字段注入异常
    
    * Polish /apache/dubbo#5770 : Removing the interinal JDK API from 
FileSystemDynamicConfiguration
    
    * Polish /apache/dubbo#5771 : [Enhancement] Refactor the APT test-cases 
implementation of dubbo-metadata-processor in Java 9+
    
    * Bugfix for the test-cases
---
 .../file/FileSystemDynamicConfiguration.java       | 18 ++---
 .../AbstractAnnotationProcessingTest.java          | 25 ++++---
 .../AnnotationProcessingTestProcessor.java         | 76 ++++++++++++++++++++++
 .../processing/CompilerInvocationInterceptor.java  | 45 +++++++++++++
 .../org/apache/dubbo/metadata/tools/Compiler.java  |  6 +-
 .../apache/dubbo/metadata/tools/TestProcessor.java |  8 ++-
 pom.xml                                            |  2 +-
 7 files changed, 150 insertions(+), 30 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfiguration.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfiguration.java
index 44209f6..2544c05 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfiguration.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfiguration.java
@@ -27,7 +27,6 @@ import org.apache.dubbo.common.function.ThrowableFunction;
 import org.apache.dubbo.common.utils.NamedThreadFactory;
 import org.apache.dubbo.common.utils.StringUtils;
 
-import com.sun.nio.file.SensitivityWatchEventModifier;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -527,20 +526,15 @@ public class FileSystemDynamicConfiguration extends 
AbstractDynamicConfiguration
     }
 
     private static Integer initDelay(WatchEvent.Modifier[] modifiers) {
-        return Stream.of(modifiers)
-                .filter(modifier -> modifier instanceof 
SensitivityWatchEventModifier)
-                .map(SensitivityWatchEventModifier.class::cast)
-                .map(SensitivityWatchEventModifier::sensitivityValueInSeconds)
-                .max(Integer::compareTo)
-                .orElse(null);
+        if (isBasedPoolingWatchService()) {
+            return 2;
+        } else {
+            return null;
+        }
     }
 
     private static WatchEvent.Modifier[] initWatchEventModifiers() {
-        if (isBasedPoolingWatchService()) { // If based on 
PollingWatchService, High sensitivity will be used
-            return of(SensitivityWatchEventModifier.HIGH);
-        } else {
-            return of();
-        }
+        return of();
     }
 
     /**
diff --git 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/AbstractAnnotationProcessingTest.java
 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/AbstractAnnotationProcessingTest.java
index 1a8f9dd..d224f07 100644
--- 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/AbstractAnnotationProcessingTest.java
+++ 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/AbstractAnnotationProcessingTest.java
@@ -17,10 +17,10 @@
 package org.apache.dubbo.metadata.annotation.processing;
 
 import org.apache.dubbo.metadata.annotation.processing.util.TypeUtils;
-import org.apache.dubbo.metadata.tools.Compiler;
-import org.apache.dubbo.metadata.tools.TestProcessor;
 
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
 
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.TypeElement;
@@ -28,7 +28,6 @@ import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
 import java.io.IOException;
 import java.lang.annotation.Annotation;
-import java.util.LinkedHashSet;
 import java.util.Set;
 
 /**
@@ -36,8 +35,11 @@ import java.util.Set;
  *
  * @since 2.7.6
  */
+@ExtendWith(CompilerInvocationInterceptor.class)
 public abstract class AbstractAnnotationProcessingTest {
 
+    static ThreadLocal<AbstractAnnotationProcessingTest> testInstanceHolder = 
new ThreadLocal<>();
+
     protected ProcessingEnvironment processingEnv;
 
     protected Elements elements;
@@ -46,17 +48,12 @@ public abstract class AbstractAnnotationProcessingTest {
 
     @BeforeEach
     public final void init() throws IOException {
-        Set<Class<?>> classesToBeCompiled = new LinkedHashSet<>();
-        classesToBeCompiled.add(getClass());
-        addCompiledClasses(classesToBeCompiled);
-        TestProcessor testProcessor = new TestProcessor();
-        Compiler compiler = new Compiler();
-        compiler.processors(testProcessor);
-        compiler.compile(classesToBeCompiled.toArray(new Class[0]));
-        processingEnv = testProcessor.getProcessingEnvironment();
-        elements = processingEnv.getElementUtils();
-        types = processingEnv.getTypeUtils();
-        beforeEach();
+        testInstanceHolder.set(this);
+    }
+
+    @AfterEach
+    public final void destroy() {
+        testInstanceHolder.remove();
     }
 
     protected abstract void addCompiledClasses(Set<Class<?>> 
classesToBeCompiled);
diff --git 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/AnnotationProcessingTestProcessor.java
 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/AnnotationProcessingTestProcessor.java
new file mode 100644
index 0000000..2b13813
--- /dev/null
+++ 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/AnnotationProcessingTestProcessor.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.metadata.annotation.processing;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.InvocationInterceptor;
+import org.junit.jupiter.api.extension.ReflectiveInvocationContext;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import static javax.lang.model.SourceVersion.latestSupported;
+
+@SupportedAnnotationTypes("*")
+public class AnnotationProcessingTestProcessor extends AbstractProcessor {
+
+    private final AbstractAnnotationProcessingTest 
abstractAnnotationProcessingTest;
+    private final InvocationInterceptor.Invocation<Void> invocation;
+
+    private final ReflectiveInvocationContext<Method> invocationContext;
+
+    private final ExtensionContext extensionContext;
+
+    public AnnotationProcessingTestProcessor(AbstractAnnotationProcessingTest 
abstractAnnotationProcessingTest, InvocationInterceptor.Invocation<Void> 
invocation,
+                                             
ReflectiveInvocationContext<Method> invocationContext,
+                                             ExtensionContext 
extensionContext) {
+        this.abstractAnnotationProcessingTest = 
abstractAnnotationProcessingTest;
+        this.invocation = invocation;
+        this.invocationContext = invocationContext;
+        this.extensionContext = extensionContext;
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, 
RoundEnvironment roundEnv) {
+        if (!roundEnv.processingOver()) {
+            prepare();
+            abstractAnnotationProcessingTest.beforeEach();
+            try {
+                invocation.proceed();
+            } catch (Throwable throwable) {
+                throw new RuntimeException(throwable);
+            }
+        }
+        return false;
+    }
+
+    private void prepare() {
+        abstractAnnotationProcessingTest.processingEnv = super.processingEnv;
+        abstractAnnotationProcessingTest.elements = 
super.processingEnv.getElementUtils();
+        abstractAnnotationProcessingTest.types = 
super.processingEnv.getTypeUtils();
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return latestSupported();
+    }
+}
\ No newline at end of file
diff --git 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/CompilerInvocationInterceptor.java
 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/CompilerInvocationInterceptor.java
new file mode 100644
index 0000000..fe97b4b
--- /dev/null
+++ 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/CompilerInvocationInterceptor.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.metadata.annotation.processing;
+
+import org.apache.dubbo.metadata.tools.Compiler;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.InvocationInterceptor;
+import org.junit.jupiter.api.extension.ReflectiveInvocationContext;
+
+import java.lang.reflect.Method;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static 
org.apache.dubbo.metadata.annotation.processing.AbstractAnnotationProcessingTest.testInstanceHolder;
+
+public class CompilerInvocationInterceptor implements InvocationInterceptor {
+
+    @Override
+    public void interceptTestMethod(Invocation<Void> invocation,
+                                    ReflectiveInvocationContext<Method> 
invocationContext,
+                                    ExtensionContext extensionContext) throws 
Throwable {
+        Set<Class<?>> classesToBeCompiled = new LinkedHashSet<>();
+        AbstractAnnotationProcessingTest abstractAnnotationProcessingTest = 
testInstanceHolder.get();
+        classesToBeCompiled.add(getClass());
+        
abstractAnnotationProcessingTest.addCompiledClasses(classesToBeCompiled);
+        Compiler compiler = new Compiler();
+        compiler.processors(new 
AnnotationProcessingTestProcessor(abstractAnnotationProcessingTest, invocation, 
invocationContext, extensionContext));
+        compiler.compile(classesToBeCompiled.toArray(new Class[0]));
+    }
+}
diff --git 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/Compiler.java
 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/Compiler.java
index a4ee1af..e2f27dd 100644
--- 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/Compiler.java
+++ 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/Compiler.java
@@ -105,7 +105,7 @@ public class Compiler {
 
     public boolean compile(Class<?>... sourceClasses) {
         JavaCompiler.CompilationTask task = javaCompiler.getTask(null, 
this.javaFileManager, null,
-                asList("-parameters"),
+                asList("-parameters", "-Xlint:unchecked", "-nowarn", 
"-Xlint:deprecation"),
 //                null,
                 null, getJavaFileObjects(sourceClasses));
         if (!processors.isEmpty()) {
@@ -113,4 +113,8 @@ public class Compiler {
         }
         return task.call();
     }
+
+    public JavaCompiler getJavaCompiler() {
+        return javaCompiler;
+    }
 }
diff --git 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/TestProcessor.java
 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/TestProcessor.java
index 4eda0b0..cb8ae82 100644
--- 
a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/TestProcessor.java
+++ 
b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/tools/TestProcessor.java
@@ -21,18 +21,18 @@ import javax.annotation.processing.ProcessingEnvironment;
 import javax.annotation.processing.Processor;
 import javax.annotation.processing.RoundEnvironment;
 import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.TypeElement;
 import java.util.Set;
 
+import static javax.lang.model.SourceVersion.latestSupported;
+
 /**
  * {@link Processor} for test
  *
  * @since 2.7.6
  */
 @SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_8)
 public class TestProcessor extends AbstractProcessor {
 
     @Override
@@ -43,4 +43,8 @@ public class TestProcessor extends AbstractProcessor {
     public ProcessingEnvironment getProcessingEnvironment() {
         return super.processingEnv;
     }
+
+    public SourceVersion getSupportedSourceVersion(){
+        return latestSupported();
+    }
 }
diff --git a/pom.xml b/pom.xml
index dc085b3..9b89bd5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,7 @@
 
     <properties>
         <!-- Test libs -->
-        <junit_jupiter_version>5.4.0</junit_jupiter_version>
+        <junit_jupiter_version>5.6.0</junit_jupiter_version>
         <hazelcast_version>3.11.1</hazelcast_version>
         <hamcrest_version>1.3</hamcrest_version>
         <hibernate_validator_version>5.2.4.Final</hibernate_validator_version>

Reply via email to