Skip to content

Commit

Permalink
Merge branch '2.x' into feature_support_spring_acturator_2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored Nov 27, 2023
2 parents 34e0ee7 + 7894473 commit 6070ca4
Show file tree
Hide file tree
Showing 41 changed files with 620 additions and 231 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:
# https://docs.github.com/cn/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context
run: |
if [ "${{ matrix.java }}" == "8" ]; then
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=false -Dlicense.skip=false -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=false -Dlicense.skip=false -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
else
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
fi
# job 2
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
# step 4
- name: "Test with Maven"
run: |
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dspring-boot-for-server.version=2.5.14 -Dspring-framework-for-server.version=5.3.20 -Dkotlin-maven-plugin.version=1.7.22 -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dkotlin-maven-plugin.version=1.7.22 -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
# job 3
arm64-test:
Expand Down Expand Up @@ -125,4 +125,4 @@ jobs:
# step 5
- name: "test-arm64"
run: |
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Build Status](https://github.com/seata/seata/workflows/build/badge.svg?branch=develop)](https://github.com/seata/seata/actions)
[![codecov](https://codecov.io/gh/seata/seata/branch/develop/graph/badge.svg)](https://codecov.io/gh/seata/seata)
[![license](https://img.shields.io/github/license/seata/seata.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![maven](https://img.shields.io/maven-central/v/io.seata/seata-parent?versionSuffix=1.8.0)](https://search.maven.org/search?q=io.seata)
[![maven](https://img.shields.io/maven-central/v/io.seata/seata-parent?versionSuffix=2.0.0)](https://search.maven.org/search?q=io.seata)
[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/seata/seata.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/seata/seata/context:java)


Expand Down Expand Up @@ -87,7 +87,7 @@ For more details about principle and design, please go to [Seata wiki page](http
Depending on the scenario, choose one of the two dependencies: `io.seata:seata-all` or `io.seata:seata-spring-boot-starter`.
```xml
<properties>
<seata.version>1.8.0</seata.version>
<seata.version>2.0.0</seata.version>
</properties>

<dependencies>
Expand Down
11 changes: 10 additions & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<properties>
<!-- seata version -->
<revision>2.0.0-SNAPSHOT</revision>
<revision>2.1.0-SNAPSHOT</revision>

<!-- Compiler settings properties -->
<java.version>1.8</java.version>
Expand Down Expand Up @@ -125,6 +125,7 @@
<license.skip>true</license.skip>
<maven.test.skip>false</maven.test.skip>
<maven.surefire.argLine></maven.surefire.argLine>
<maven.surefire.excludes></maven.surefire.excludes>
<gpg.keyname>37F181C60AACE24BD5C1D3925583F79497E8E293</gpg.keyname>
<gpg.arg1/>
<gpg.arg2/>
Expand Down Expand Up @@ -405,5 +406,13 @@
</maven.surefire.argLine>
</properties>
</profile>

<!-- profile: args-for-client-test -->
<profile>
<id>args-for-client-test</id>
<properties>
<maven.surefire.excludes>io/seata/server/**/*.java,io/seata/console/**/*.java</maven.surefire.excludes>
</properties>
</profile>
</profiles>
</project>
3 changes: 3 additions & 0 deletions changes/en-us/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ The version is updated as follows:
- [[#6018](https://github.com/seata/seata/pull/6018)] fix incorrect metric report
- [[#6024](https://github.com/seata/seata/pull/6024)] fix the white screen after click the "View Global Lock" button on the transaction info page in the console
- [[#6015](https://github.com/seata/seata/pull/6015)] fix can't integrate dubbo with spring
- [[#6049](https://github.com/seata/seata/pull/6049)] fix registry type for raft under the network interruption did not carry out the sleep 1s
- [[#6050](https://github.com/seata/seata/pull/6050)] change RaftServer#destroy to wait all shutdown procedures done

### optimize:
- [[#6033](https://github.com/seata/seata/pull/6033)] optimize the isReference judgment logic in HSFRemotingParser, remove unnecessary judgment about FactoryBean
Expand Down Expand Up @@ -153,6 +155,7 @@ The version is updated as follows:
- [[#5951](https://github.com/seata/seata/pull/5951)] remove un support config in jdk17
- [[#5959](https://github.com/seata/seata/pull/5959)] modify code style and remove unused import
- [[#6002](https://github.com/seata/seata/pull/6002)] remove fst serialization
- [[#6045](https://github.com/seata/seata/pull/6045)] optimize derivative product check base on mysql


### security:
Expand Down
28 changes: 28 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Add changes here for all PR submitted to the 2.x branch.

<!-- Please add the `changes` to the following location(feature/bugfix/optimize/test) based on the type of PR -->

### feature:
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] A brief and accurate description of PR

### bugfix:
- [[#6075](https://github.com/seata/seata/pull/6075)] fix missing table alias for on update column of image SQL

### optimize:
- [[#6031](https://github.com/seata/seata/pull/6031)] add a check for the existence of the undolog table

### security:
- [[#6069](https://github.com/seata/seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities

### test:
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] A brief and accurate description of PR

Thanks to these contributors for their code commits. Please report an unintended omission.

<!-- Please make sure your Github ID is in the list below -->
- [slievrly](https://github.com/slievrly)
- [ptyin](https://github.com/ptyin)
- [laywin](https://github.com/laywin)
- [imcmai](https://github.com/imcmai)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
3 changes: 3 additions & 0 deletions changes/zh-cn/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#6018](https://github.com/seata/seata/pull/6018)] 修复错误的 metric 上报
- [[#6024](https://github.com/seata/seata/pull/6024)] 修复控制台点击事务信息页面中的"查看全局锁"按钮之后白屏的问题
- [[#6015](https://github.com/seata/seata/pull/6015)] 修复在spring环境下无法集成dubbo
- [[#6049](https://github.com/seata/seata/pull/6049)] 修复客户端在raft注册中心类型下,网络中断时,watch线程未暂停一秒等待重试的问题
- [[#6050](https://github.com/seata/seata/pull/6050)] 修改 RaftServer#destroy 为等待所有关闭流程结束


### optimize:
Expand Down Expand Up @@ -154,6 +156,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#5951](https://github.com/seata/seata/pull/5951)] 删除在 jdk17 中不支持的配置项
- [[#5959](https://github.com/seata/seata/pull/5959)] 修正代码风格问题及去除无用的类引用
- [[#6002](https://github.com/seata/seata/pull/6002)] 移除fst序列化模块
- [[#6045](https://github.com/seata/seata/pull/6045)] 优化MySQL衍生数据库判断逻辑


### security:
Expand Down
29 changes: 29 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
所有提交到 2.x 分支的 PR 请在此处登记。

<!-- 请根据PR的类型添加 `变更记录` 到以下对应位置(feature/bugfix/optimize/test) 下 -->

### feature:
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 准确简要的PR描述

### bugfix:
- [[#6075](https://github.com/seata/seata/pull/6075)] 修复镜像SQL对于on update列没有添加表别名的问题

### optimize:
- [[#6031](https://github.com/seata/seata/pull/6031)] 添加undo_log表的存在性校验

### security:
- [[#6069](https://github.com/seata/seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞

### test:
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 准确简要的PR描述

非常感谢以下 contributors 的代码贡献。若有无意遗漏,请报告。

<!-- 请确保您的 GitHub ID 在以下列表中 -->
- [slievrly](https://github.com/slievrly)
- [ptyin](https://github.com/ptyin)
- [laywin](https://github.com/laywin)
- [imcmai](https://github.com/imcmai)


同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
5 changes: 5 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
127 changes: 127 additions & 0 deletions common/src/main/java/io/seata/common/util/HttpClientUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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 io.seata.common.util;


import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* @author funkye
*/
public class HttpClientUtil {

private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientUtil.class);

private static final Map<Integer/*timeout*/, CloseableHttpClient> HTTP_CLIENT_MAP = new ConcurrentHashMap<>();

private static final PoolingHttpClientConnectionManager POOLING_HTTP_CLIENT_CONNECTION_MANAGER =
new PoolingHttpClientConnectionManager();

static {
POOLING_HTTP_CLIENT_CONNECTION_MANAGER.setMaxTotal(10);
POOLING_HTTP_CLIENT_CONNECTION_MANAGER.setDefaultMaxPerRoute(10);
Runtime.getRuntime().addShutdownHook(new Thread(() -> HTTP_CLIENT_MAP.values().parallelStream().forEach(client -> {
try {
client.close();
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
})));
}

// post request
public static CloseableHttpResponse doPost(String url, Map<String, String> params, Map<String, String> header,
int timeout) throws IOException {
try {
URIBuilder builder = new URIBuilder(url);
URI uri = builder.build();
HttpPost httpPost = new HttpPost(uri);
if (header != null) {
header.forEach(httpPost::addHeader);
}
List<NameValuePair> nameValuePairs = new ArrayList<>();
params.forEach((k, v) -> {
nameValuePairs.add(new BasicNameValuePair(k, v));
});
String requestBody = URLEncodedUtils.format(nameValuePairs, StandardCharsets.UTF_8);

StringEntity stringEntity = new StringEntity(requestBody, ContentType.APPLICATION_FORM_URLENCODED);
httpPost.setEntity(stringEntity);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
CloseableHttpClient client = HTTP_CLIENT_MAP.computeIfAbsent(timeout,
k -> HttpClients.custom().setConnectionManager(POOLING_HTTP_CLIENT_CONNECTION_MANAGER)
.setDefaultRequestConfig(RequestConfig.custom().setConnectionRequestTimeout(timeout)
.setSocketTimeout(timeout).setConnectTimeout(timeout).build())
.build());
return client.execute(httpPost);
} catch (URISyntaxException | ClientProtocolException e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}

// get request
public static CloseableHttpResponse doGet(String url, Map<String, String> param, Map<String, String> header,
int timeout) throws IOException {
try {
URIBuilder builder = new URIBuilder(url);
if (param != null) {
for (String key : param.keySet()) {
builder.addParameter(key, param.get(key));
}
}
URI uri = builder.build();
HttpGet httpGet = new HttpGet(uri);
if (header != null) {
header.forEach(httpGet::addHeader);
}
CloseableHttpClient client = HTTP_CLIENT_MAP.computeIfAbsent(timeout,
k -> HttpClients.custom().setConnectionManager(POOLING_HTTP_CLIENT_CONNECTION_MANAGER)
.setDefaultRequestConfig(RequestConfig.custom().setConnectionRequestTimeout(timeout)
.setSocketTimeout(timeout).setConnectTimeout(timeout).build())
.build());
return client.execute(httpGet);
} catch (URISyntaxException | ClientProtocolException e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.internal.util.reflection.FieldSetter;

import java.lang.reflect.Field;
import java.util.concurrent.CompletableFuture;
Expand All @@ -44,7 +43,8 @@ void testGet() throws NoSuchFieldException, IllegalAccessException, ExecutionExc
// mock field
origin = Mockito.spy(origin);
// set mocked field to object
FieldSetter.setField(configFuture, originField, origin);
originField.setAccessible(true);
originField.set(configFuture, origin);

Mockito.doThrow(ExecutionException.class).when(origin).get(Mockito.anyLong(), Mockito.any());
Assertions.assertThrows(ShouldNeverHappenException.class, configFuture::get);
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/io/seata/core/constants/DBType.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,4 @@ public static DBType valueof(String dbType) {
}
throw new IllegalArgumentException("unknown dbtype:" + dbType);
}

}
9 changes: 7 additions & 2 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<nacos-client.version>1.4.2</nacos-client.version>
<etcd-client-v3.version>0.5.0</etcd-client-v3.version>
<testcontainers.version>1.11.2</testcontainers.version>
<guava.version>30.1-jre</guava.version>
<guava.version>32.0.0-jre</guava.version>
<javax-inject.version>1</javax-inject.version>
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
Expand Down Expand Up @@ -118,7 +118,7 @@
<kotlin-coroutines.version>1.4.3</kotlin-coroutines.version>

<!-- # for test -->
<mockito.version>2.23.4</mockito.version>
<mockito.version>4.5.1</mockito.version>
<assertj-core.version>3.12.2</assertj-core.version>
<jetty-version>9.4.38.v20210224</jetty-version>
<janino-version>3.1.7</janino-version>
Expand Down Expand Up @@ -701,6 +701,11 @@
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Loading

0 comments on commit 6070ca4

Please sign in to comment.