diff --git a/.github/actions/common/spring/action.yml b/.github/actions/common/spring/action.yml
index 476238da78..277e9baba5 100644
--- a/.github/actions/common/spring/action.yml
+++ b/.github/actions/common/spring/action.yml
@@ -57,11 +57,24 @@ runs:
key: ${{ runner.os }}-agent-${{ github.run_id }}
- name: plugin change check
uses: ./.github/actions/common/plugin-change-check
+ - name: change feign version
+ shell: bash
+ if: matrix.springCloudVersion != '2022.0.0' && matrix.springCloudVersion != '2022.0.1' && matrix.springCloudVersion != '2022.0.2'
+ run: |
+ sed -i 's/org.apache.httpcomponents/org.apache.httpcomponents.client5/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/pom.xml
+ sed -i 's/httpclient/httpclient5/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/pom.xml
+ sed -i 's/org.apache.http.conn/org.apache.hc.client5.http/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/configuration/FeignClientSslConfigurationHighVersion.java.highVersion
- name: change file version
# For build feign client ssl call config, according to springCloud version discriminate high and low config.
- if: matrix.springCloudVersion == '2020.0.0' || matrix.springCloudVersion == '2021.0.0' || matrix.springCloudVersion == '2021.0.3'
shell: bash
run: |
mv sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/configuration/FeignClientSslConfigurationLowVersion.java sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/configuration/FeignClientSslConfigurationLowVersion.java.lowVersion
mv sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/configuration/FeignClientSslConfigurationHighVersion.java.highVersion sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/configuration/FeignClientSslConfigurationHighVersion.java
- ls sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/configuration
\ No newline at end of file
+ ls sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/configuration
+ sed -i 's/qualifier/qualifiers/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/FeignService.java
+ sed -i 's/qualifier/qualifiers/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-api/src/main/java/com/huaweicloud/spring/feign/api/RemovalService.java
+ sed -i 's/javax.servlet.http/jakarta.servlet.http/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign/feign-provider/src/main/java/com/huaweicloud/spring/feign/provider/FeignServiceImpl.java
+ sed -i 's/javax.servlet.http/jakarta.servlet.http/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/src/main/java/com/huaweicloud/spring/rest/provider/RouterController.java
+ sed -i 's/javax.annotation/jakarta.annotation/' sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/BootRegistryHttpClientController.java
+ mv sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java.spring
+ mv sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java.springboot3 sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java
\ No newline at end of file
diff --git a/.github/actions/scenarios/spring/router/spring-router/action.yml b/.github/actions/scenarios/spring/router/spring-router/action.yml
index 20fc90aae2..9baa6ae97c 100644
--- a/.github/actions/scenarios/spring/router/spring-router/action.yml
+++ b/.github/actions/scenarios/spring/router/spring-router/action.yml
@@ -38,7 +38,7 @@ runs:
SERVICE_META_PARAMETERS: Test-Env:env-001
SERVER_PORT: 8013
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider.log 2>&1 &
- name: start second feign provider service
shell: bash
@@ -52,7 +52,7 @@ runs:
SERVICE_META_PARAMETERS: Test-Env:env-002
SERVER_PORT: 8014
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider2.log 2>&1 &
- name: start third feign provider service
shell: bash
@@ -66,7 +66,7 @@ runs:
SERVICE_META_PARAMETERS: Test-Env1:env-002
SERVER_PORT: 8015
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider3.log 2>&1 &
- name: start fourth feign provider service
shell: bash
@@ -79,7 +79,7 @@ runs:
ROUTER_PLUGIN_REQUEST_TAGS: "[Test-Env,Test-Env1]"
SERVER_PORT: 8016
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider4.log 2>&1 &
- name: start feign consumer service
shell: bash
@@ -93,7 +93,7 @@ runs:
SERVER_PORT: 8017
SERMANT_SPRINGBOOT_REGISTRY_LB_MAXRETRY: 0
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-consumer${{ env.tailVersion }}/target/feign-consumer${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-consumer.log 2>&1 &
- name: start resttemplate provider service
shell: bash
@@ -107,7 +107,7 @@ runs:
SERVICE_META_PARAMETERS: Test-Env:env-001
SERVER_PORT: 8018
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider.log 2>&1 &
- name: start second resttemplate provider service
shell: bash
@@ -121,7 +121,7 @@ runs:
SERVICE_META_PARAMETERS: Test-Env:env-002
SERVER_PORT: 8019
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider2.log 2>&1 &
- name: start third resttemplate provider service
shell: bash
@@ -135,7 +135,7 @@ runs:
SERVICE_META_PARAMETERS: Test-Env1:env-002
SERVER_PORT: 8020
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider3.log 2>&1 &
- name: start fourth resttemplate provider service
shell: bash
@@ -148,7 +148,7 @@ runs:
ROUTER_PLUGIN_REQUEST_TAGS: "[Test-Env,Test-Env1]"
SERVER_PORT: 8021
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider4.log 2>&1 &
- name: start resttemplate consumer service
shell: bash
@@ -162,7 +162,7 @@ runs:
SERVER_PORT: 8022
SERMANT_SPRINGBOOT_REGISTRY_LB_MAXRETRY: 0
run: |
- nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
+ nohup java -Dnet.bytebuddy.experimental=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.net.www=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/target/rest-consumer.jar > ${{ env.logDir }}/rest-consumer.log 2>&1 &
- name: waiting for services start
shell: bash
diff --git a/.github/workflows/spring_integration_test_2.yml b/.github/workflows/spring_integration_test_2.yml
index eb5250adb5..a6e8fb7a03 100644
--- a/.github/workflows/spring_integration_test_2.yml
+++ b/.github/workflows/spring_integration_test_2.yml
@@ -87,35 +87,34 @@ jobs:
strategy:
matrix:
include:
- - springBootVersion: "1.5.0.RELEASE"
- springCloudVersion: "Edgware.SR2"
- nacosVersion: "1.5.0.RELEASE"
- - springBootVersion: "2.0.2.RELEASE"
- springCloudVersion: "Finchley.RELEASE"
+ - springBootVersion: "3.0.4"
+ springCloudVersion: "2022.0.0"
+ - springBootVersion: "3.0.8"
+ springCloudVersion: "2022.0.1"
httpClientVersion: "4.1.3"
- nacosVersion: "2.0.0.RELEASE"
- - springBootVersion: "2.1.0.RELEASE"
- springCloudVersion: "Greenwich.RELEASE"
+ - springBootVersion: "3.0.12"
+ springCloudVersion: "2022.0.2"
httpClientVersion: "4.2.6"
- nacosVersion: "2.1.0.RELEASE"
- - springBootVersion: "2.2.0.RELEASE"
- springCloudVersion: "Hoxton.RELEASE"
+ - springBootVersion: "3.1.4"
+ springCloudVersion: "2022.0.3"
httpClientVersion: "4.3.6"
- nacosVersion: "2.2.0.RELEASE"
- - springBootVersion: "2.3.0.RELEASE"
- springCloudVersion: "Hoxton.RELEASE"
+ - springBootVersion: "3.1.8"
+ springCloudVersion: "2022.0.4"
httpClientVersion: "4.4.1"
- nacosVersion: "2.2.8.RELEASE"
- - springBootVersion: "2.4.0"
- springCloudVersion: "2020.0.0"
+ - springBootVersion: "3.1.12"
+ springCloudVersion: "2022.0.5"
httpClientVersion: "4.5.6"
- nacosVersion: "2021.0.1.0"
- - springBootVersion: "2.6.2"
- springCloudVersion: "2021.0.0"
+ - springBootVersion: "3.2.4"
+ springCloudVersion: "2023.0.0"
httpClientVersion: "4.5.10"
- nacosVersion: "2021.1"
- - springBootVersion: "2.7.2"
- springCloudVersion: "2021.0.3"
+ - springBootVersion: "3.2.8"
+ springCloudVersion: "2023.0.1"
+ httpClientVersion: "4.5.13"
+ - springBootVersion: "3.3.0"
+ springCloudVersion: "2023.0.2"
+ httpClientVersion: "4.5.13"
+ - springBootVersion: "3.3.5"
+ springCloudVersion: "2023.0.3"
httpClientVersion: "4.5.13"
fail-fast: false
steps:
@@ -124,7 +123,7 @@ jobs:
fetch-depth: 100
- name: set java version to environment
run: |
- echo "javaVersion=8" >> $GITHUB_ENV
+ echo "javaVersion=21" >> $GITHUB_ENV
- name: common operations
uses: ./.github/actions/common/spring
- name: (spring router) test for springboot=${{ matrix.springBootVersion }} springCloudVersion=${{ matrix.springCloudVersion }}
diff --git a/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/pom.xml b/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/pom.xml
index 2fa1d8314f..c6bb5df9b9 100644
--- a/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/pom.xml
+++ b/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/pom.xml
@@ -53,6 +53,11 @@
httpclient
${httpclient.version}
+
+ org.apache.httpcomponents.client5
+ httpclient5
+ 5.1.1
+
diff --git a/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java b/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java
index 08d09e5260..833062e073 100644
--- a/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java
+++ b/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java
@@ -17,6 +17,8 @@
package com.huaweicloud.spring.rest.consumer;
+import com.huaweicloud.spring.common.flowcontrol.handlers.RestTemplateResponseErrorHandler;
+
import org.apache.http.client.config.RequestConfig;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
@@ -63,7 +65,9 @@ public class FlowcontrolConiguration {
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
- return new RestTemplate();
+ RestTemplate restTemplate = new RestTemplate();
+ restTemplate.setErrorHandler(new RestTemplateResponseErrorHandler());
+ return restTemplate;
}
/**
diff --git a/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java.springboot3 b/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java.springboot3
new file mode 100644
index 0000000000..bdb3494f4b
--- /dev/null
+++ b/sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/src/main/java/com/huaweicloud/spring/rest/consumer/FlowcontrolConiguration.java.springboot3
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
+ *
+ * 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 com.huaweicloud.spring.rest.consumer;
+
+import com.huaweicloud.spring.common.flowcontrol.handlers.RestTemplateResponseErrorHandler;
+
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.ssl.TrustStrategy;
+import org.apache.hc.core5.util.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.net.ssl.SSLContext;
+
+/**
+ * 流控配置类
+ *
+ * @author zhouss
+ * @since 2022-07-28
+ */
+@Configuration
+public class FlowcontrolConiguration {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FlowcontrolConiguration.class);
+ private static final Timeout TIME_OUT = Timeout.ofMinutes(5);
+
+ @Value("${timeout}")
+ private int timeout;
+
+ /**
+ * 注入请求器
+ *
+ * @return RestTemplate
+ */
+ @LoadBalanced
+ @Bean
+ public RestTemplate restTemplate() {
+ RestTemplate restTemplate = new RestTemplate();
+ restTemplate.setErrorHandler(new RestTemplateResponseErrorHandler());
+ return restTemplate;
+ }
+
+ /**
+ * 离群实例摘除的注入请求器
+ *
+ * @return RestTemplate
+ */
+ @LoadBalanced
+ @Bean("removalRestTemplate")
+ public RestTemplate removalRestTemplate() {
+ RestTemplate template = new RestTemplate();
+ SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) template.getRequestFactory();
+ rf.setReadTimeout(timeout);
+ return template;
+ }
+
+ /**
+ * 注入请求器
+ *
+ * @return RestTemplate
+ */
+ @LoadBalanced
+ @Bean("routerRestTemplate")
+ public RestTemplate routerRestTemplate() {
+ return new RestTemplate();
+ }
+
+ /**
+ * 注入请求器
+ *
+ * @return RestTemplate
+ */
+ @LoadBalanced
+ @Bean("gracefulRestTemplate")
+ public RestTemplate gracefulRestTemplate() {
+ return buildRestTemplate();
+ }
+
+ private RestTemplate buildRestTemplate() {
+ RestTemplate restTemplate = null;
+ try {
+ restTemplate = new RestTemplate(buildHttpRequestFactory());
+ } catch (KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) {
+ LOGGER.error("build SSL restTemplate failed!");
+ }
+ return restTemplate;
+ }
+
+ private HttpComponentsClientHttpRequestFactory buildHttpRequestFactory()
+ throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
+ TrustStrategy strategy = (x509Certificates, authType) -> true;
+ SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, strategy).build();
+ RequestConfig requestConfig = RequestConfig.custom()
+ /*.setSocketTimeout(TIME_OUT)*/.setConnectTimeout(TIME_OUT).setConnectionRequestTimeout(TIME_OUT).build();
+ HttpClientBuilder httpClientBuilder = HttpClients.custom();
+ httpClientBuilder.setDefaultRequestConfig(requestConfig);
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
+ Registry socketFactoryRegistry =
+ RegistryBuilder. create()
+ .register("https", factory)
+ .register("http", new PlainConnectionSocketFactory())
+ .build();
+ BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(socketFactoryRegistry);
+ httpClientBuilder.setConnectionManager(connectionManager);
+ CloseableHttpClient httpClient = httpClientBuilder.build();
+ HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
+ requestFactory.setHttpClient(httpClient);
+ return requestFactory;
+ }
+}
diff --git a/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ClientController.java b/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ClientController.java
index 679b5ccd48..dc0fe8763d 100644
--- a/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ClientController.java
+++ b/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ClientController.java
@@ -17,8 +17,6 @@
package com.huaweicloud.spring.common.flowcontrol.consumer;
-import com.huaweicloud.spring.common.flowcontrol.handlers.RestTemplateResponseErrorHandler;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,8 +29,6 @@
import java.util.Locale;
import java.util.UUID;
-import javax.annotation.PostConstruct;
-
/**
* 基于Client端的治理测试
*
@@ -51,14 +47,6 @@ public class ClientController {
@Autowired
private RestTemplate restTemplate;
- /**
- * 初始化
- */
- @PostConstruct
- public void init() {
- restTemplate.setErrorHandler(new RestTemplateResponseErrorHandler());
- }
-
/**
* 实例隔离接口测试
*
diff --git a/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ServerController.java b/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ServerController.java
index 50f61f3867..7d2b026560 100644
--- a/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ServerController.java
+++ b/sermant-integration-tests/spring-test/spring-common/src/main/java/com/huaweicloud/spring/common/flowcontrol/consumer/ServerController.java
@@ -17,8 +17,6 @@
package com.huaweicloud.spring.common.flowcontrol.consumer;
-import com.huaweicloud.spring.common.flowcontrol.handlers.RestTemplateResponseErrorHandler;
-
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
@@ -33,8 +31,6 @@
import java.util.Locale;
-import javax.annotation.PostConstruct;
-
/**
* 流控服务端测试
*
@@ -54,14 +50,6 @@ public class ServerController {
@Autowired
private RestTemplate restTemplate;
- /**
- * 初始化
- */
- @PostConstruct
- public void init() {
- restTemplate.setErrorHandler(new RestTemplateResponseErrorHandler());
- }
-
/**
* 限流测试
*