Skip to content

Commit

Permalink
feature: seata client support jdk17 (apache#4877)
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored Oct 24, 2022
1 parent f56b02c commit 83ac9f3
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
4 changes: 2 additions & 2 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
Expand Down
1 change: 1 addition & 0 deletions changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Add changes here for all PR submitted to the develop branch.
- [[#4863](https://github.com/seata/seata/pull/4863)] support oracle and postgresql multi primary key
- [[#4649](https://github.com/seata/seata/pull/4649)] seata-server support multiple registry
- [[#4479](https://github.com/seata/seata/pull/4479)] TCC mode supports tcc annotation marked on both interface and implementation class
- [[#4877](https://github.com/seata/seata/pull/4877)] seata client support jdk17
- [[#4468](https://github.com/seata/seata/pull/4968)] support kryo 5.3.0


Expand Down
2 changes: 2 additions & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
- [[#4863](https://github.com/seata/seata/pull/4863)] support oracle and postgresql multi primary key
- [[#4649](https://github.com/seata/seata/pull/4649)] seata-server支持多注册中心
- [[#4479](https://github.com/seata/seata/pull/4479)] TCC注解支持添加在实现类及其方法上也生效
- [[#4877](https://github.com/seata/seata/pull/4877)] seata client支持jdk17
- [[#4468](https://github.com/seata/seata/pull/4968)] 支持kryo 5.3.0



### bugfix:
- [[#4780](https://github.com/seata/seata/pull/4780)] 修复超时回滚成功后无法发送TimeoutRollbacked事件
- [[#4954](https://github.com/seata/seata/pull/4954)] 修复output表达式错误时,保存执行结果空指针异常
Expand Down
4 changes: 2 additions & 2 deletions config/seata-config-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<artifactId>snakeyaml</artifactId>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
import io.seata.common.util.CollectionUtils;
import io.seata.common.util.DurationUtil;
import io.seata.common.util.StringUtils;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.InvocationHandlerAdapter;
import net.bytebuddy.matcher.ElementMatchers;

/**
* @author funkye
Expand Down Expand Up @@ -100,19 +101,22 @@ public void onChangeEvent(ConfigurationChangeEvent event) {
}
}

public Configuration proxy(Configuration originalConfiguration) {
return (Configuration)Enhancer.create(Configuration.class,
(MethodInterceptor)(proxy, method, args, methodProxy) -> {
if (method.getName().startsWith(METHOD_PREFIX)
&& !method.getName().equalsIgnoreCase(METHOD_LATEST_CONFIG)) {
public Configuration proxy(Configuration originalConfiguration) throws Exception {
return new ByteBuddy().subclass(Configuration.class).method(ElementMatchers.any())
.intercept(InvocationHandlerAdapter.of((proxy, method, args) -> {
String methodName = method.getName();
if (methodName.startsWith(METHOD_PREFIX) && !method.getName().equalsIgnoreCase(METHOD_LATEST_CONFIG)) {
String rawDataId = (String)args[0];
ObjectWrapper wrapper = CONFIG_CACHE.get(rawDataId);
ObjectWrapper.ConfigType type = ObjectWrapper.getTypeByName(method.getName().substring(METHOD_PREFIX.length()));
ObjectWrapper.ConfigType type =
ObjectWrapper.getTypeByName(method.getName().substring(METHOD_PREFIX.length()));
Object defaultValue = null;
if (args.length > 1 && method.getParameterTypes()[1].getSimpleName().equalsIgnoreCase(type.name())) {
if (args.length > 1
&& method.getParameterTypes()[1].getSimpleName().equalsIgnoreCase(type.name())) {
defaultValue = args[1];
}
if (null == wrapper || (null != defaultValue && !Objects.equals(defaultValue, wrapper.lastDefaultValue))) {
if (null == wrapper
|| (null != defaultValue && !Objects.equals(defaultValue, wrapper.lastDefaultValue))) {
Object result = method.invoke(originalConfiguration, args);
// The wrapper.data only exists in the cache when it is not null.
if (result != null) {
Expand All @@ -123,7 +127,8 @@ public Configuration proxy(Configuration originalConfiguration) {
return wrapper == null ? null : wrapper.convertData(type);
}
return method.invoke(originalConfiguration, args);
});
})).make().load(originalConfiguration.getClass().getClassLoader()).getLoaded().getDeclaredConstructor()
.newInstance();
}

private static class ConfigurationCacheInstance {
Expand Down Expand Up @@ -244,7 +249,8 @@ public String getCode() {
}

public static ConfigType fromCode(String code) {
return CODE_TO_VALUE.get(code.toUpperCase());
ConfigType configType = CODE_TO_VALUE.get(code.toUpperCase());
return configType == null ? ConfigType.STRING : configType;
}

public static ConfigType fromName(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.seata.config;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -46,7 +47,7 @@ void addConfigListener() throws InterruptedException {
countDownLatch.countDown();
});
System.setProperty("service.disableGlobalTransaction", String.valueOf(!value));
countDownLatch.await();
countDownLatch.await(5, TimeUnit.SECONDS);
System.setProperty("file.listener.enabled", "false");
System.setProperty("service.disableGlobalTransaction", String.valueOf(value));
Thread.sleep(2000);
Expand Down
8 changes: 4 additions & 4 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
<dubbo-seata.version>1.0.0</dubbo-seata.version>
<brpc.version>2.5.9</brpc.version>
<hsf.version>1.8.3</hsf.version>
<bytebuddy.version>1.12.13</bytebuddy.version>
<dubbo.alibaba.version>2.6.5</dubbo.alibaba.version>
<sofa.rpc.version>5.5.3</sofa.rpc.version>
<fastjson.version>1.2.83</fastjson.version>
<protostuff.version>1.5.9</protostuff.version>
<config.version>1.2.1</config.version>
<commons-logging.version>1.2</commons-logging.version>
<commons-lang.version>2.6</commons-lang.version>
<cglib.version>3.1</cglib.version>
<aopalliance.version>1.0</aopalliance.version>
<zkclient.version>0.11</zkclient.version>
<apache-zookeeper.version>3.5.9</apache-zookeeper.version>
Expand Down Expand Up @@ -247,9 +247,9 @@
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${bytebuddy.version}</version>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
Expand Down
4 changes: 0 additions & 4 deletions spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
<artifactId>seata-serializer-all</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency>

<!-- spring -->
<dependency>
Expand Down

0 comments on commit 83ac9f3

Please sign in to comment.