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

songxiaosheng pushed a commit to branch 3.2.0
in repository https://gitbox.apache.org/repos/asf/dubbo-spi-extensions.git


The following commit(s) were added to refs/heads/3.2.0 by this push:
     new 28b5586  Adapt to 3.2.x (#263)
28b5586 is described below

commit 28b5586d7957d9737254d916f21c6afb9cb9192c
Author: TomlongTK <[email protected]>
AuthorDate: Fri Dec 22 21:55:43 2023 +0800

    Adapt to 3.2.x (#263)
    
    Co-authored-by: xiaosheng <[email protected]>
---
 dubbo-common-extensions/pom.xml                    |  2 +-
 .../org/apache/dubbo/common/utils/TestAClass.java  | 34 ++++++++++++++++++
 .../org/apache/dubbo/common/utils/TestBClass.java  | 37 +++++++++++++++++++
 .../org/apache/dubbo/common/utils/UtilsTest.java   | 39 ++++++++++++++++++++
 dubbo-cross-thread-extensions/README.md            |  2 +-
 dubbo-cross-thread-extensions/pom.xml              |  3 ++
 .../interceptor/RunnableOrCallableActivation.java  | 41 ++++++++--------------
 .../dubbo/crossthread/DubboCrossThreadTest.java    | 35 ++++++++----------
 dubbo-filter-extensions/dubbo-filter-seata/pom.xml |  3 +-
 .../SeataTransactionPropagationProviderFilter.java |  8 +++--
 ...taTransactionPropagationConsumerFilterTest.java |  4 +--
 ...taTransactionPropagationProviderFilterTest.java |  5 ++-
 12 files changed, 156 insertions(+), 57 deletions(-)

diff --git a/dubbo-common-extensions/pom.xml b/dubbo-common-extensions/pom.xml
index 1af71ba..9daaf5c 100644
--- a/dubbo-common-extensions/pom.xml
+++ b/dubbo-common-extensions/pom.xml
@@ -27,6 +27,6 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>dubbo-common-extensions</artifactId>
-    <version>${revision}</version>
+    <version>3.2.0-SNAPSHOT</version>
 
 </project>
diff --git 
a/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/TestAClass.java
 
b/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/TestAClass.java
new file mode 100644
index 0000000..905b582
--- /dev/null
+++ 
b/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/TestAClass.java
@@ -0,0 +1,34 @@
+/*
+ * 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.common.utils;
+
+public class TestAClass {
+
+    private String name;
+
+    public TestAClass(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git 
a/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/TestBClass.java
 
b/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/TestBClass.java
new file mode 100644
index 0000000..fc83787
--- /dev/null
+++ 
b/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/TestBClass.java
@@ -0,0 +1,37 @@
+/*
+ * 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.common.utils;
+
+public class TestBClass {
+
+    private String name;
+
+    public TestBClass() {
+    }
+
+    public TestBClass(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git 
a/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/UtilsTest.java
 
b/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/UtilsTest.java
new file mode 100644
index 0000000..35825b9
--- /dev/null
+++ 
b/dubbo-common-extensions/src/test/java/org/apache/dubbo/common/utils/UtilsTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.common.utils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.dubbo.common.utils.Utils.checkZeroArgConstructor;
+import static org.apache.dubbo.common.utils.Utils.isJdk;
+
+class UtilsTest {
+
+    @Test
+    void testCheckZeroArgConstructor() {
+        Assertions.assertFalse(checkZeroArgConstructor(TestAClass.class));
+        Assertions.assertTrue(checkZeroArgConstructor(TestBClass.class));
+    }
+
+    @Test
+    void testIsJdk() {
+        Assertions.assertFalse(isJdk(TestAClass.class));
+        Assertions.assertFalse(isJdk(TestBClass.class));
+        Assertions.assertTrue(isJdk(String.class));
+    }
+}
diff --git a/dubbo-cross-thread-extensions/README.md 
b/dubbo-cross-thread-extensions/README.md
index 98ceb2a..4be849a 100644
--- a/dubbo-cross-thread-extensions/README.md
+++ b/dubbo-cross-thread-extensions/README.md
@@ -85,7 +85,7 @@ public class SpringBootDemoApplication {
 }
 ```
 
-## run with wkywalking and ttl
+## run with skywalking and ttl
 jvm arguments:
 ```
 -javaagent:transmittable-thread-local-2.14.2.jar
diff --git a/dubbo-cross-thread-extensions/pom.xml 
b/dubbo-cross-thread-extensions/pom.xml
index 0d3b659..f1fc142 100644
--- a/dubbo-cross-thread-extensions/pom.xml
+++ b/dubbo-cross-thread-extensions/pom.xml
@@ -24,6 +24,7 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>dubbo-cross-thread-extensions</artifactId>
+    <version>3.2.0-SNAPSHOT</version>
     <packaging>jar</packaging>
 
     <properties>
@@ -35,11 +36,13 @@
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-rpc-api</artifactId>
+            <version>3.2.7</version>
             <optional>true</optional>
         </dependency>
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-common</artifactId>
+            <version>3.2.7</version>
             <optional>true</optional>
         </dependency>
         <dependency>
diff --git 
a/dubbo-cross-thread-extensions/src/main/java/org/apache/dubbo/crossthread/interceptor/RunnableOrCallableActivation.java
 
b/dubbo-cross-thread-extensions/src/main/java/org/apache/dubbo/crossthread/interceptor/RunnableOrCallableActivation.java
index c1fec87..b270a3f 100644
--- 
a/dubbo-cross-thread-extensions/src/main/java/org/apache/dubbo/crossthread/interceptor/RunnableOrCallableActivation.java
+++ 
b/dubbo-cross-thread-extensions/src/main/java/org/apache/dubbo/crossthread/interceptor/RunnableOrCallableActivation.java
@@ -18,16 +18,12 @@ package org.apache.dubbo.crossthread.interceptor;
 
 import org.apache.dubbo.crossthread.toolkit.DubboCrossThread;
 
+import java.lang.instrument.Instrumentation;
+
 import net.bytebuddy.agent.builder.AgentBuilder;
 import net.bytebuddy.asm.Advice;
 import net.bytebuddy.description.modifier.Visibility;
-import net.bytebuddy.description.type.TypeDescription;
-import net.bytebuddy.dynamic.DynamicType;
 import net.bytebuddy.matcher.ElementMatchers;
-import net.bytebuddy.utility.JavaModule;
-
-import java.lang.instrument.Instrumentation;
-import java.security.ProtectionDomain;
 
 import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
 import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
@@ -46,26 +42,19 @@ public class RunnableOrCallableActivation {
             .with(AgentBuilder.TypeStrategy.Default.REBASE)
             .with(AgentBuilder.RedefinitionStrategy.REDEFINITION)
             .type(isAnnotatedWith(DubboCrossThread.class))
-            .transform(new AgentBuilder.Transformer() {
-                @Override
-                public DynamicType.Builder<?> transform(DynamicType.Builder<?> 
builder, TypeDescription typeDescription,
-                                                        ClassLoader 
classLoader, JavaModule module,
-                                                        ProtectionDomain 
protectionDomain) {
-                    return builder
-                        .defineField(FIELD_NAME_DUBBO_TAG, String.class, 
Visibility.PUBLIC)
-                        
.visit(Advice.to(RunnableOrCallableMethodInterceptor.class).on(
-                            ElementMatchers.isMethod().and(
-                                
ElementMatchers.named(RUN_METHOD_NAME).and(takesArguments(0))
-                                    
.or(ElementMatchers.named(CALL_METHOD_NAME).and(takesArguments(0)))
-                                    
.or(ElementMatchers.named(APPLY_METHOD_NAME).and(takesArguments(0)))
-                                    
.or(ElementMatchers.named(ACCEPT_METHOD_NAME).and(takesArguments(0)))
-                            )
-                        ))
-                        
.visit(Advice.to(RunnableOrCallableConstructInterceptor.class).on(
-                            ElementMatchers.isConstructor()
-                        ));
-                }
-            })
+            .transform((builder, typeDescription, classLoader, module, 
protectionDomain) -> builder
+                .defineField(FIELD_NAME_DUBBO_TAG, String.class, 
Visibility.PUBLIC)
+                .visit(Advice.to(RunnableOrCallableMethodInterceptor.class).on(
+                    ElementMatchers.isMethod().and(
+                        
ElementMatchers.named(RUN_METHOD_NAME).and(takesArguments(0))
+                            
.or(ElementMatchers.named(CALL_METHOD_NAME).and(takesArguments(0)))
+                            
.or(ElementMatchers.named(APPLY_METHOD_NAME).and(takesArguments(0)))
+                            
.or(ElementMatchers.named(ACCEPT_METHOD_NAME).and(takesArguments(0)))
+                    )
+                ))
+                
.visit(Advice.to(RunnableOrCallableConstructInterceptor.class).on(
+                    ElementMatchers.isConstructor()
+                )))
             .installOn(instrumentation);
     }
 }
diff --git 
a/dubbo-cross-thread-extensions/src/test/java/org/apache/dubbo/crossthread/DubboCrossThreadTest.java
 
b/dubbo-cross-thread-extensions/src/test/java/org/apache/dubbo/crossthread/DubboCrossThreadTest.java
index ca43052..e1433ed 100644
--- 
a/dubbo-cross-thread-extensions/src/test/java/org/apache/dubbo/crossthread/DubboCrossThreadTest.java
+++ 
b/dubbo-cross-thread-extensions/src/test/java/org/apache/dubbo/crossthread/DubboCrossThreadTest.java
@@ -16,6 +16,12 @@
  */
 package org.apache.dubbo.crossthread;
 
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.crossthread.interceptor.RunnableOrCallableActivation;
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.crossthread.toolkit.CallableWrapper;
+import org.apache.dubbo.crossthread.toolkit.RunnableWrapper;
+
 import java.lang.instrument.Instrumentation;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
@@ -27,28 +33,18 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import net.bytebuddy.agent.ByteBuddyAgent;
-import org.apache.dubbo.common.constants.CommonConstants;
-import org.apache.dubbo.crossthread.interceptor.RunnableOrCallableActivation;
-import org.apache.dubbo.rpc.RpcContext;
-import org.apache.dubbo.crossthread.toolkit.CallableWrapper;
-import org.apache.dubbo.crossthread.toolkit.RunnableWrapper;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-public class DubboCrossThreadTest {
+class DubboCrossThreadTest {
     @Test
-    public void crossThreadCallableTest() throws ExecutionException, 
InterruptedException, TimeoutException {
+    void crossThreadCallableTest() throws ExecutionException, 
InterruptedException, TimeoutException {
         Instrumentation instrumentation = ByteBuddyAgent.install();
         RunnableOrCallableActivation.install(instrumentation);
         String tag = "beta";
         
RpcContext.getClientAttachment().setAttachment(CommonConstants.TAG_KEY, tag);
-        Callable<String> callable = CallableWrapper.of(new Callable<String>() {
-            @Override
-            public String call() throws Exception {
-                return 
RpcContext.getClientAttachment().getAttachment(CommonConstants.TAG_KEY);
-            }
-        });
+        Callable<String> callable = CallableWrapper.of(() -> 
RpcContext.getClientAttachment().getAttachment(CommonConstants.TAG_KEY));
         ExecutorService threadPool = Executors.newSingleThreadExecutor();
         Future<String> submit = threadPool.submit(callable);
         assertEquals(tag, submit.get(1, TimeUnit.SECONDS));
@@ -58,19 +54,16 @@ public class DubboCrossThreadTest {
     private volatile String tagCrossThread = null;
 
     @Test
-    public void crossThreadRunnableTest() throws ExecutionException, 
InterruptedException {
+    void crossThreadRunnableTest() throws InterruptedException {
         Instrumentation instrumentation = ByteBuddyAgent.install();
         RunnableOrCallableActivation.install(instrumentation);
         String tag = "beta";
         
RpcContext.getClientAttachment().setAttachment(CommonConstants.TAG_KEY, tag);
         final CountDownLatch latch = new CountDownLatch(1);
-        Runnable runnable = RunnableWrapper.of(new Runnable() {
-            @Override
-            public void run() {
-                String tag = 
RpcContext.getClientAttachment().getAttachment(CommonConstants.TAG_KEY);
-                tagCrossThread = tag;
-                latch.countDown();
-            }
+        Runnable runnable = RunnableWrapper.of(() -> {
+            String tag1 = 
RpcContext.getClientAttachment().getAttachment(CommonConstants.TAG_KEY);
+            tagCrossThread = tag1;
+            latch.countDown();
         });
         ExecutorService threadPool = Executors.newSingleThreadExecutor();
         threadPool.submit(runnable);
diff --git a/dubbo-filter-extensions/dubbo-filter-seata/pom.xml 
b/dubbo-filter-extensions/dubbo-filter-seata/pom.xml
index 71380f1..1763f57 100644
--- a/dubbo-filter-extensions/dubbo-filter-seata/pom.xml
+++ b/dubbo-filter-extensions/dubbo-filter-seata/pom.xml
@@ -28,7 +28,7 @@
 
     <artifactId>dubbo-filter-seata</artifactId>
     <name>${project.artifactId}</name>
-    <version>1.0.2-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>
@@ -39,6 +39,7 @@
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo</artifactId>
+            <version>3.2.7</version>
             <optional>true</optional>
         </dependency>
     </dependencies>
diff --git 
a/dubbo-filter-extensions/dubbo-filter-seata/src/main/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilter.java
 
b/dubbo-filter-extensions/dubbo-filter-seata/src/main/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilter.java
index e678b11..baff10e 100644
--- 
a/dubbo-filter-extensions/dubbo-filter-seata/src/main/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilter.java
+++ 
b/dubbo-filter-extensions/dubbo-filter-seata/src/main/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilter.java
@@ -37,15 +37,19 @@ import io.seata.core.model.BranchType;
 public class SeataTransactionPropagationProviderFilter implements Filter {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(SeataTransactionPropagationProviderFilter.class);
 
+    private static final String LOWER_KEY_XID = 
RootContext.KEY_XID.toLowerCase();
+
+    private static final String LOWER_KEY_BRANCH_TYPE = 
RootContext.KEY_BRANCH_TYPE.toLowerCase();
+
     @Override
     public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
         String rpcXid = invocation.getAttachment(RootContext.KEY_XID);
         if (rpcXid == null) {
-            rpcXid = 
invocation.getAttachment(RootContext.KEY_XID.toLowerCase());
+            rpcXid = invocation.getAttachment(LOWER_KEY_XID);
         }
         String rpcBranchType = 
invocation.getAttachment(RootContext.KEY_BRANCH_TYPE);
         if (rpcBranchType == null) {
-            rpcBranchType = 
invocation.getAttachment(RootContext.KEY_BRANCH_TYPE.toLowerCase());
+            rpcBranchType = invocation.getAttachment(LOWER_KEY_BRANCH_TYPE);
         }
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("Server side xid in RpcContext[" + rpcXid + "]");
diff --git 
a/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationConsumerFilterTest.java
 
b/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationConsumerFilterTest.java
index 423e094..93261be 100644
--- 
a/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationConsumerFilterTest.java
+++ 
b/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationConsumerFilterTest.java
@@ -29,9 +29,9 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
-public class SeataTransactionPropagationConsumerFilterTest {
+class SeataTransactionPropagationConsumerFilterTest {
     @Test
-    public void test() {
+    void test() {
         ApplicationModel applicationModel = 
FrameworkModel.defaultModel().newApplication();
         ModuleModel moduleModel = applicationModel.newModule();
 
diff --git 
a/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilterTest.java
 
b/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilterTest.java
index a5e0f76..88d05c5 100644
--- 
a/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilterTest.java
+++ 
b/dubbo-filter-extensions/dubbo-filter-seata/src/test/java/org/apache/dubbo/seata/SeataTransactionPropagationProviderFilterTest.java
@@ -35,7 +35,7 @@ import org.mockito.Mockito;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Function;
 
-public class SeataTransactionPropagationProviderFilterTest {
+class SeataTransactionPropagationProviderFilterTest {
     private final AtomicReference<Function<Invocation, Result>> invokeFunction 
= new AtomicReference<>();
 
     private Invoker invoker = new Invoker() {
@@ -65,9 +65,8 @@ public class SeataTransactionPropagationProviderFilterTest {
         }
     };
 
-
     @Test
-    public void test() {
+    void test() {
         ApplicationModel applicationModel = 
FrameworkModel.defaultModel().newApplication();
         ModuleModel moduleModel = applicationModel.newModule();
 

Reply via email to