gzoldou 2 days ago committed by GitHub
commit 67b17916e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3,6 +3,7 @@ name: Junit Test
on:
push:
branches:
- 2025
- 2024
- 2023
- 2022
@ -15,6 +16,7 @@ on:
- '**.md'
pull_request:
branches:
- 2025
- 2024
- 2023
- 2022
@ -41,7 +43,9 @@ jobs:
branch_name=${{ github.base_ref }}
fi
echo $branch_name
if [[ "$branch_name" == "2024" ]]; then
if [[ "$branch_name" == "2025" ]]; then
echo "jdks=[17,21,25]" >> $GITHUB_OUTPUT
elif [[ "$branch_name" == "2024" ]]; then
echo "jdks=[17,21]" >> $GITHUB_OUTPUT
elif [[ "$branch_name" == "2023" ]]; then
echo "jdks=[17,21]" >> $GITHUB_OUTPUT

@ -3,6 +3,7 @@ name: License checker
on:
push:
branches:
- 2025
- 2024
- 2023
- 2022
@ -15,6 +16,7 @@ on:
- '**.md'
pull_request:
branches:
- 2025
- 2024
- 2023
- 2022

@ -3,6 +3,7 @@ name: Snapshot
on:
push:
branches:
- 2025
- 2024
- 2023
- 2022
@ -41,7 +42,9 @@ jobs:
id: set-jdk
run: |
shopt -s nocasematch
if [[ "${{ github.ref_name }}" == "2024" ]]; then
if [[ "${{ github.ref_name }}" == "2025" ]]; then
echo "jdk=17" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_name }}" == "2024" ]]; then
echo "jdk=17" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_name }}" == "2023" ]]; then
echo "jdk=17" >> $GITHUB_OUTPUT

@ -6,3 +6,4 @@
- [feat: Support Polaris config env value and add related tests](https://github.com/Tencent/spring-cloud-tencent/pull/1797)
- [refactor: modify the initialization of ApplicationContextAwareUtils.](https://github.com/Tencent/spring-cloud-tencent/pull/1798)
- [feat: support enable/disable cloud location provider via configuration.](https://github.com/Tencent/spring-cloud-tencent/pull/1799)
- [feat: Upgrade to Spring Cloud 2025.1.1.](https://github.com/Tencent/spring-cloud-tencent/pull/1801)

@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>4.2.4</version>
<version>5.0.1</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -90,22 +90,22 @@
<properties>
<!-- Project revision -->
<revision>2.1.2.0-2024.0.3-SNAPSHOT</revision>
<revision>2.1.2.0-2025.1.1-SNAPSHOT</revision>
<!-- Spring Framework -->
<spring.framework.version>6.2.15</spring.framework.version>
<spring.framework.version>7.0.3</spring.framework.version>
<!-- Spring Boot -->
<spring.boot.version>3.4.12</spring.boot.version>
<spring.boot.version>4.0.2</spring.boot.version>
<!-- Spring Cloud -->
<spring.cloud.version>2024.0.3</spring.cloud.version>
<spring.cloud.version>2025.1.1</spring.cloud.version>
<!-- Test -->
<system-stubs-jupiter.version>2.0.2</system-stubs-jupiter.version>
<!-- Maven Plugin Versions -->
<jacoco.version>0.8.12</jacoco.version>
<jacoco.version>0.8.14</jacoco.version>
<maven-clean-plugin.version>3.4.0</maven-clean-plugin.version>
<central.publishing.maven.plugin.version>0.8.0</central.publishing.maven.plugin.version>
@ -193,6 +193,12 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>

@ -23,7 +23,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
<optional>true</optional>
</dependency>

@ -44,7 +44,7 @@ public final class CustomTransitiveMetadataResolver {
Map<String, String> result = new HashMap<>();
HttpHeaders headers = exchange.getRequest().getHeaders();
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
for (Map.Entry<String, List<String>> entry : headers.headerSet()) {
String key = entry.getKey();
if (StringUtils.isBlank(key)) {
continue;

@ -84,7 +84,7 @@ public final class TransHeadersTransfer {
if (transHeaders != null) {
String[] transHeaderArray = transHeaders.split(",");
HttpHeaders headers = serverHttpRequest.getHeaders();
Set<String> headerKeys = headers.keySet();
Set<String> headerKeys = headers.headerNames();
for (String httpHeader : headerKeys) {
for (String transHeader : transHeaderArray) {
if (transHeader.equals(httpHeader)) {

@ -149,7 +149,7 @@ public final class SnapshotHttpServletRequest implements HttpServletRequest {
@Override
public Enumeration<String> getHeaderNames() {
return Collections.enumeration(headers.keySet());
return Collections.enumeration(headers.headerNames());
}
@Override

@ -45,7 +45,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = MOCK,
classes = DecodeTransferMetadataServletFilterTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml", "spring.main.web-application-type = reactive"})
properties = {"spring.config.location = classpath:application-test.yml", "spring.main.web-application-type = reactive",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class DecodeTransferMetadataReactiveFilterTest {
@Autowired

@ -46,7 +46,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
classes = DecodeTransferMetadataServletFilterTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = servlet",
"spring.cloud.gateway.enabled = false"})
"spring.cloud.gateway.enabled = false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class DecodeTransferMetadataServletFilterTest {
@Autowired

@ -49,7 +49,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
classes = EncodeTransferMedataFeignInterceptorTest.TestApplication.class,
properties = {"server.port=48081", "spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = servlet",
"spring.cloud.gateway.enabled = false"})
"spring.cloud.gateway.enabled = false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class EncodeTransferMedataFeignInterceptorTest {
@Autowired

@ -44,7 +44,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
@SpringBootTest(webEnvironment = RANDOM_PORT,
classes = EncodeTransferMedataWebClientFilterTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = reactive"})
"spring.main.web-application-type = reactive",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class EncodeTransferMedataWebClientFilterTest {
@Autowired

@ -52,7 +52,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
@SpringBootTest(webEnvironment = RANDOM_PORT,
classes = EnhancedRestTemplateInterceptorTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = reactive"})
"spring.main.web-application-type = reactive",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class EnhancedRestTemplateInterceptorTest {
@Autowired

@ -42,7 +42,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = RANDOM_PORT,
classes = DecodeTransferMetadataServletFilterTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml"})
properties = {"spring.config.location = classpath:application-test.yml",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class TransHeadersTransferTest {
@AfterAll
static void afterAll() {

@ -40,7 +40,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
<optional>true</optional>
</dependency>

@ -40,7 +40,7 @@ public class PolarisResultToErrorCode implements ResultToErrorCode {
public int onError(Throwable e) {
if (checkClassExist("org.springframework.web.client.RestClientResponseException")
&& e instanceof RestClientResponseException) {
return ((RestClientResponseException) e).getRawStatusCode();
return ((RestClientResponseException) e).getStatusCode().value();
}
else if (checkClassExist("feign.FeignException")
&& e instanceof FeignException) {
@ -48,10 +48,10 @@ public class PolarisResultToErrorCode implements ResultToErrorCode {
}
else if (checkClassExist("org.springframework.web.reactive.function.client.WebClientResponseException")
&& e instanceof WebClientResponseException) {
return ((WebClientResponseException) e).getRawStatusCode();
return ((WebClientResponseException) e).getStatusCode().value();
}
else if (e instanceof CircuitBreakerStatusCodeException) {
return ((CircuitBreakerStatusCodeException) e).getRawStatusCode();
return ((CircuitBreakerStatusCodeException) e).getStatusCode().value();
}
return -1;
}

@ -80,7 +80,7 @@ public class ExceptionCircuitBreakerReporter implements EnhancedPlugin {
EnhancedRequestContext request = context.getRequest();
ServiceInstance serviceInstance = Optional.ofNullable(context.getTargetServiceInstance())
.orElse(new DefaultServiceInstance());
.orElse(new DefaultServiceInstance(null, null, null, 0, false));
ResourceStat resourceStat = PolarisEnhancedPluginUtils.createInstanceResourceStat(
serviceInstance.getServiceId(),

@ -84,7 +84,7 @@ public class SuccessCircuitBreakerReporter implements EnhancedPlugin {
EnhancedRequestContext request = context.getRequest();
EnhancedResponseContext response = context.getResponse();
ServiceInstance serviceInstance = Optional.ofNullable(context.getTargetServiceInstance())
.orElse(new DefaultServiceInstance());
.orElse(new DefaultServiceInstance(null, null, null, 0, false));
ResourceStat resourceStat = PolarisEnhancedPluginUtils.createInstanceResourceStat(
serviceInstance.getServiceId(),

@ -44,7 +44,7 @@ public class PolarisCircuitBreakerHttpResponseTest {
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThat(response.getHeaders()).isNotNull();
assertThat(response.getHeaders()).isEmpty();
assertThat(response.getHeaders().isEmpty()).isTrue();
assertThat(response.getBody()).isNull();
}
@ -55,7 +55,7 @@ public class PolarisCircuitBreakerHttpResponseTest {
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThat(response.getHeaders()).isNotNull();
assertThat(response.getHeaders()).isEmpty();
assertThat(response.getHeaders().isEmpty()).isTrue();
assertThat(response.getBody()).isNotNull();
}
@ -71,8 +71,8 @@ public class PolarisCircuitBreakerHttpResponseTest {
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThat(response.getHeaders()).isNotNull();
assertThat(response.getHeaders().size()).isEqualTo(2);
assertThat(response.getHeaders()).containsKey("Content-Type");
assertThat(response.getHeaders()).containsKey("Authorization");
assertThat(response.getHeaders().containsHeader("Content-Type")).isTrue();
assertThat(response.getHeaders().containsHeader("Authorization")).isTrue();
assertThat(response.getBody()).isNotNull();
}
@ -87,7 +87,7 @@ public class PolarisCircuitBreakerHttpResponseTest {
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThat(response.getFallbackInfo()).isEqualTo(fallbackInfo);
assertThat(response.getHeaders()).isNotNull();
assertThat(response.getHeaders()).containsKey("Content-Type");
assertThat(response.getHeaders().containsHeader("Content-Type")).isTrue();
assertThat(response.getBody()).isNotNull();
}

@ -125,7 +125,7 @@ public class CircuitBreakerPluginTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(200)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);
@ -157,7 +157,7 @@ public class CircuitBreakerPluginTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(200)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);

@ -122,7 +122,7 @@ public class ExceptionCircuitBreakerReporterTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(200)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);
@ -162,7 +162,7 @@ public class ExceptionCircuitBreakerReporterTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(300)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);
@ -197,7 +197,7 @@ public class ExceptionCircuitBreakerReporterTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(300)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);

@ -137,7 +137,7 @@ public class SuccessCircuitBreakerReporterTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(200)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);
@ -176,7 +176,7 @@ public class SuccessCircuitBreakerReporterTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(300)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);
@ -210,7 +210,7 @@ public class SuccessCircuitBreakerReporterTest {
EnhancedResponseContext response = EnhancedResponseContext.builder()
.httpStatus(300)
.build();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);

@ -35,8 +35,8 @@ import com.tencent.polaris.client.api.SDKContext;
import com.tencent.polaris.factory.config.ConfigurationImpl;
import org.apache.commons.logging.Log;
import org.springframework.boot.BootstrapRegistry;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.bootstrap.BootstrapRegistry;
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
import org.springframework.boot.context.config.ConfigDataLocation;
import org.springframework.boot.context.config.ConfigDataLocationNotFoundException;
import org.springframework.boot.context.config.ConfigDataLocationResolver;

@ -8,6 +8,6 @@ org.springframework.boot.context.config.ConfigDataLoader=\
com.tencent.cloud.polaris.config.configdata.PolarisConfigDataLoader
org.springframework.boot.diagnostics.FailureAnalyzer=\
com.tencent.cloud.polaris.config.configdata.PolarisImportExceptionFailureAnalyzer
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.boot.EnvironmentPostProcessor=\
com.tencent.cloud.polaris.config.configdata.PolarisConfigDataMissingEnvironmentPostProcessor

@ -211,7 +211,7 @@ public class SpringValueProcessorTest {
}
@Component
private static class ValueTest {
private static final class ValueTest {
private static String name;
@Value("${timeout:1000}")
private int timeout;

@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.util.GzipUtil;
import com.tencent.cloud.polaris.PolarisDiscoveryProperties;
@ -46,6 +45,7 @@ import org.springdoc.api.AbstractOpenApiResourceUtil;
import org.springdoc.core.providers.ObjectMapperProvider;
import org.springdoc.webflux.api.OpenApiWebFluxUtil;
import org.springdoc.webmvc.api.OpenApiWebMvcUtil;
import tools.jackson.databind.json.JsonMapper;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
@ -115,8 +115,9 @@ public class PolarisContractReporter implements ApplicationListener<ApplicationR
jsonValue = springdocObjectMapperProvider.jsonMapper().writeValueAsString(openAPI);
}
else {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JsonMapper mapper = JsonMapper.builder()
.changeDefaultPropertyInclusion(incl -> incl.withValueInclusion(JsonInclude.Include.NON_NULL))
.build();
jsonValue = mapper.writeValueAsString(openAPI);
}
String serviceApiMeta = GzipUtil.compressBase64Encode(jsonValue, "utf-8");
@ -159,8 +160,9 @@ public class PolarisContractReporter implements ApplicationListener<ApplicationR
jsonValue = springdocObjectMapperProvider.jsonMapper().writeValueAsString(o.getValue());
}
else {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JsonMapper mapper = JsonMapper.builder()
.changeDefaultPropertyInclusion(incl -> incl.withValueInclusion(JsonInclude.Include.NON_NULL))
.build();
jsonValue = mapper.writeValueAsString(o.getValue());
}
interfaceDescriptor.setContent(GzipUtil.compressBase64Encode(jsonValue, "utf-8"));

@ -20,7 +20,6 @@ package com.tencent.cloud.polaris.contract.tsf;
import java.util.concurrent.atomic.AtomicBoolean;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tencent.cloud.common.util.GzipUtil;
import io.swagger.v3.oas.models.OpenAPI;
import org.slf4j.Logger;
@ -30,6 +29,7 @@ import org.springdoc.api.AbstractOpenApiResourceUtil;
import org.springdoc.core.providers.ObjectMapperProvider;
import org.springdoc.webflux.api.OpenApiWebFluxUtil;
import org.springdoc.webmvc.api.OpenApiWebMvcUtil;
import tools.jackson.databind.json.JsonMapper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.SmartLifecycle;
@ -89,8 +89,9 @@ public class TsfApiMetadataGrapher implements SmartLifecycle {
jsonValue = springdocObjectMapperProvider.jsonMapper().writeValueAsString(openAPI);
}
else {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JsonMapper mapper = JsonMapper.builder()
.changeDefaultPropertyInclusion(incl -> incl.withValueInclusion(JsonInclude.Include.NON_NULL))
.build();
jsonValue = mapper.writeValueAsString(openAPI);
}
if (openAPI != null && !StringUtils.isEmpty(jsonValue)) {

@ -53,7 +53,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<artifactId>spring-boot-starter-actuator</artifactId>
<optional>true</optional>
</dependency>

@ -47,7 +47,7 @@ public class PolarisReactiveDiscoveryClientConfiguration {
}
@Bean
@ConditionalOnClass(name = "org.springframework.boot.actuate.health.ReactiveHealthIndicator")
@ConditionalOnClass(name = "org.springframework.boot.health.contributor.ReactiveHealthIndicator")
@ConditionalOnDiscoveryHealthIndicatorEnabled
public ReactiveDiscoveryClientHealthIndicator polarisReactiveDiscoveryClientHealthIndicator(
PolarisReactiveDiscoveryClient client, DiscoveryClientHealthIndicatorProperties properties) {

@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.util.StringUtils;
/**
@ -49,13 +50,14 @@ public class PolarisAutoServiceRegistration extends AbstractAutoServiceRegistrat
private final AssemblyAPI assemblyAPI;
public PolarisAutoServiceRegistration(
ApplicationContext context,
ServiceRegistry<PolarisRegistration> serviceRegistry,
AutoServiceRegistrationProperties autoServiceRegistrationProperties,
PolarisRegistration registration,
PolarisDiscoveryProperties polarisDiscoveryProperties,
AssemblyAPI assemblyAPI
) {
super(serviceRegistry, autoServiceRegistrationProperties);
super(context, serviceRegistry, autoServiceRegistrationProperties);
this.registration = registration;
this.polarisDiscoveryProperties = polarisDiscoveryProperties;
this.assemblyAPI = assemblyAPI;

@ -31,9 +31,9 @@ import com.tencent.polaris.api.utils.CollectionUtils;
import com.tencent.polaris.api.utils.StringUtils;
import com.tencent.polaris.client.api.SDKContext;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.boot.web.server.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.lang.Nullable;
/**
@ -180,7 +180,7 @@ public class PolarisRegistration implements Registration {
@Override
public URI getUri() {
return DefaultServiceInstance.getUri(this);
return ServiceInstance.createUri(this);
}
@Override

@ -34,11 +34,12 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.boot.web.server.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
import org.springframework.cloud.client.serviceregistry.ServiceRegistryAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -81,13 +82,14 @@ public class PolarisServiceRegistryAutoConfiguration {
@Bean
public PolarisAutoServiceRegistration polarisAutoServiceRegistration(
ApplicationContext context,
PolarisServiceRegistry registry,
AutoServiceRegistrationProperties autoServiceRegistrationProperties,
PolarisRegistration registration,
PolarisDiscoveryProperties polarisDiscoveryProperties,
PolarisSDKContextManager polarisSDKContextManager
) {
return new PolarisAutoServiceRegistration(registry, autoServiceRegistrationProperties, registration,
return new PolarisAutoServiceRegistration(context, registry, autoServiceRegistrationProperties, registration,
polarisDiscoveryProperties, polarisSDKContextManager.getAssemblyAPI());
}

@ -30,6 +30,7 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationP
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.mock.env.MockEnvironment;
import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
import static org.assertj.core.api.Assertions.assertThat;
@ -73,12 +74,15 @@ public class PolarisAutoServiceRegistrationTest {
doNothing().when(serviceRegistry).register(nullable(PolarisRegistration.class));
doNothing().when(serviceRegistry).deregister(nullable(PolarisRegistration.class));
// Use MockEnvironment to simulate real Spring environment
MockEnvironment mockEnvironment = new MockEnvironment();
mockEnvironment.setProperty("spring.application.name", "application");
doReturn(mockEnvironment).when(applicationContext).getEnvironment();
polarisAutoServiceRegistration =
new PolarisAutoServiceRegistration(serviceRegistry, autoServiceRegistrationProperties, registration,
new PolarisAutoServiceRegistration(applicationContext, serviceRegistry, autoServiceRegistrationProperties, registration,
polarisDiscoveryProperties, null);
doReturn(environment).when(applicationContext).getEnvironment();
polarisAutoServiceRegistration.setApplicationContext(applicationContext);
}
@Test

@ -36,9 +36,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.boot.web.server.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
import static com.tencent.polaris.test.common.Consts.HOST;
import static com.tencent.polaris.test.common.Consts.PORT;

@ -38,11 +38,11 @@ import shade.polaris.com.google.protobuf.StringValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.client.HttpClientErrorException.TooManyRequests;
import org.springframework.web.client.RestClientException;
@ -77,7 +77,7 @@ public class CalleeControllerTests {
@Autowired
private RestTemplate restTemplate;
@MockBean
@MockitoBean
private LimitAPI limitAPI;
@BeforeAll

@ -50,7 +50,6 @@ import shade.polaris.com.google.protobuf.util.JsonFormat;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
@ -182,8 +181,7 @@ public class QuotaCheckReactiveFilterTest {
ServerWebExchange testApp3Exchange = MockServerWebExchange.from(request);
quotaCheckReactiveFilter.filter(testApp3Exchange, webFilterChain);
ServerHttpResponse response = testApp3Exchange.getResponse();
assertThat(response.getRawStatusCode()).isEqualTo(419);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE);
assertThat(response.getStatusCode().value()).isEqualTo(419);
assertThat(response.getHeaders()
.get(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME)).isEqualTo(Collections.singletonList("MOCK_RULE"));
@ -227,7 +225,7 @@ public class QuotaCheckReactiveFilterTest {
MetadataContext.LOCAL_SERVICE = "TestApp3";
quotaCheckWithRateLimiterLimitedFallbackReactiveFilter.filter(exchange, webFilterChain);
ServerHttpResponse response = exchange.getResponse();
assertThat(response.getRawStatusCode()).isEqualTo(polarisRateLimiterLimitedFallback.rejectHttpCode());
assertThat(response.getStatusCode().value()).isEqualTo(polarisRateLimiterLimitedFallback.rejectHttpCode());
assertThat(response.getHeaders().getContentType()).isEqualTo(polarisRateLimiterLimitedFallback.mediaType());
// Exception

@ -36,7 +36,7 @@
<!-- spring cloud gateway dependencies start -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-server</artifactId>
<artifactId>spring-cloud-gateway-server-webflux</artifactId>
<optional>true</optional>
</dependency>
@ -50,7 +50,7 @@
<!-- spring cloud gateway mvc dependencies start -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-server-mvc</artifactId>
<artifactId>spring-cloud-gateway-server-webmvc</artifactId>
<optional>true</optional>
</dependency>
<!-- spring cloud gateway mvc dependencies end -->

@ -48,7 +48,8 @@ import static org.mockito.Mockito.mock;
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = RouterLabelFeignInterceptorTest.TestApplication.class,
properties = {"spring.cloud.polaris.namespace=test", "spring.application.name=test", "spring.cloud.gateway.enabled=false"})
properties = {"spring.cloud.polaris.namespace=test", "spring.application.name=test", "spring.cloud.gateway.enabled=false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class RouterLabelFeignInterceptorTest {
@Test

@ -55,7 +55,8 @@ import static org.mockito.Mockito.when;
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = RouterLabelRestTemplateInterceptorTest.TestApplication.class,
properties = {"spring.cloud.polaris.namespace=test", "spring.application.name=test", "spring.cloud.gateway.enabled=false"})
properties = {"spring.cloud.polaris.namespace=test", "spring.application.name=test", "spring.cloud.gateway.enabled=false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class RouterLabelRestTemplateInterceptorTest {
@Mock

@ -47,7 +47,8 @@ import static org.springframework.cloud.gateway.server.mvc.filter.FormFilter.FOR
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = RouterLabelMvcFilterTest.TestApplication.class,
properties = {"spring.cloud.polaris.namespace=test", "spring.application.name=test", "spring.main.web-application-type=servlet", "spring.cloud.gateway.enabled=false"})
properties = {"spring.cloud.polaris.namespace=test", "spring.application.name=test", "spring.main.web-application-type=servlet", "spring.cloud.gateway.enabled=false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class RouterLabelMvcFilterTest {
@Test

@ -65,7 +65,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
<optional>true</optional>
</dependency>
@ -87,6 +87,11 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-web-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>

@ -26,7 +26,6 @@ import com.tencent.polaris.api.pojo.Instance;
import com.tencent.polaris.api.utils.CollectionUtils;
import com.tencent.polaris.api.utils.StringUtils;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
/**
@ -94,7 +93,7 @@ public class PolarisServiceInstance implements ServiceInstance {
@Override
public URI getUri() {
return DefaultServiceInstance.getUri(this);
return ServiceInstance.createUri(this);
}
@Override

@ -22,14 +22,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.jackson.core.JacksonException;
import tools.jackson.core.type.TypeReference;
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.databind.JavaType;
import tools.jackson.databind.ObjectWriter;
import tools.jackson.databind.json.JsonMapper;
import org.springframework.util.StringUtils;
@ -43,12 +43,12 @@ public final class JacksonUtils {
/**
* Object Mapper.
*/
public static final ObjectMapper OM = new ObjectMapper();
public static final JsonMapper OM = new JsonMapper();
private static final Logger LOG = LoggerFactory.getLogger(JacksonUtils.class);
static {
OM.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
OM.rebuild().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
private JacksonUtils() {
@ -81,7 +81,7 @@ public final class JacksonUtils {
return OM.writeValueAsString(object);
}
}
catch (JsonProcessingException e) {
catch (JacksonException e) {
LOG.error("Object to Json failed. {}", object, e);
throw new RuntimeException("Object to Json failed.", e);
}
@ -91,7 +91,7 @@ public final class JacksonUtils {
try {
return OM.readValue(jsonStr, type);
}
catch (JsonProcessingException e) {
catch (JacksonException e) {
LOG.error("Json to object failed. {}", type, e);
throw new RuntimeException("Json to object failed.", e);
}
@ -101,7 +101,7 @@ public final class JacksonUtils {
try {
return OM.readValue(jsonStr, typeReference);
}
catch (JsonProcessingException e) {
catch (JacksonException e) {
LOG.error("Json to object failed. {}", typeReference, e);
throw new RuntimeException("Json to object failed.", e);
}
@ -138,7 +138,7 @@ public final class JacksonUtils {
}
return new HashMap<>();
}
catch (JsonProcessingException e) {
catch (JacksonException e) {
LOG.error(
"Json to map failed. check if the format of the json string[{}] is correct.", jsonStr, e);
throw new RuntimeException("Json to map failed.", e);

@ -40,7 +40,7 @@ public class Tag implements Serializable {
public Tag(String key, String value, ControlFlag... flags) {
this.key = key;
this.value = value;
this.flags = new HashSet<>(Arrays.asList(flags));
this.flags = flags != null ? new HashSet<>(Arrays.asList(flags)) : new HashSet<>();
}
public Tag() {

@ -35,7 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = PolarisAsyncPropertiesTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml"})
properties = {"spring.config.location = classpath:application-test.yml",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class PolarisAsyncPropertiesTest {
@Autowired

@ -37,7 +37,8 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = MetadataContextHolderTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = reactive"})
"spring.main.web-application-type = reactive",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class MetadataContextHolderTest {
@Test

@ -39,7 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = MetadataContextTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = reactive"})
"spring.main.web-application-type = reactive",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class MetadataContextTest {
private MetadataContext metadataContext;

@ -35,7 +35,10 @@ import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = MetadataLocalPropertiesTest.TestApplication.class,
properties = {"spring.config.location = classpath:application-test.yml"})
properties = {"spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = servlet",
"spring.cloud.gateway.enabled = false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class MetadataLocalPropertiesTest {
@Autowired

@ -26,6 +26,7 @@ import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ResolvableType;
import static org.assertj.core.api.Assertions.assertThat;
@ -115,6 +116,11 @@ public class BeanFactoryUtilsTest {
return null;
}
@Override
public <T> ObjectProvider<T> getBeanProvider(ParameterizedTypeReference<T> requiredType) {
return null;
}
@Override
public boolean containsBean(String s) {
return false;

@ -21,10 +21,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import tools.jackson.core.type.TypeReference;
import org.springframework.tsf.core.entity.Tag;
import org.springframework.util.StringUtils;

@ -42,7 +42,8 @@ import static org.assertj.core.api.Assertions.assertThat;
properties = {
"spring.application.name=test",
"spring.cloud.polaris.discovery.register=false",
"spring.cloud.gateway.enabled=false"
"spring.cloud.gateway.enabled=false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"
})
public class OkHttpUtilTest {

@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<version>4.2.4</version>
<version>5.0.1</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -71,7 +71,7 @@
<properties>
<!-- Project revision -->
<revision>2.1.2.0-2024.0.3-SNAPSHOT</revision>
<revision>2.1.2.0-2025.1.1-SNAPSHOT</revision>
<!-- Polaris SDK version -->
<polaris.version>2.1.2.0-SNAPSHOT</polaris.version>

@ -25,7 +25,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
</dependency>
</dependencies>

@ -21,7 +21,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway-mvc</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webmvc</artifactId>
</dependency>
</dependencies>

@ -21,7 +21,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
</dependency>
</dependencies>
</project>

@ -35,8 +35,8 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.restclient.RestTemplateBuilder;
import org.springframework.boot.ssl.SslBundles;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.openfeign.EnableFeignClients;

@ -21,7 +21,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
</dependency>
<dependency>

@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
@Tag(description = "swagger 测试", name = "swaggerValue1")
public class SwaggerApiController {
@RequestMapping(value = "/swagger/findMessages", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/swagger/findMessages", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(method = "POST",
summary = "根据任务ID查询任务列表",
description = "根据任务ID查询任务列表Note")
@ -85,7 +85,7 @@ public class SwaggerApiController {
@Operation(summary = "获取消息详情", method = "GET", description = "获取消息内容Note")
@ApiResponses({@ApiResponse(responseCode = "200", description = "abcdef", content = @Content(schema = @Schema(implementation = MessageModel.class)))})
@RequestMapping(value = "/swagger/getMessageDetail", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/swagger/getMessageDetail", produces = MediaType.APPLICATION_JSON_VALUE)
public MessageModel getMessageDetail(@RequestParam(name = "id")
@Parameter(description = "消息ID", name = "id") String msgId) {
MessageModel messageModel = new MessageModel();
@ -109,7 +109,7 @@ public class SwaggerApiController {
@Operation(summary = "获取投递箱详情", method = "GET", description = "")
@ApiResponses({@ApiResponse(responseCode = "200", description = "获取投递箱成功", content = @Content(schema = @Schema(implementation = MessageBox.class)))})
@RequestMapping(value = "/swagger/getMessageBox", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/swagger/getMessageBox", produces = MediaType.APPLICATION_JSON_VALUE)
public MessageBox getMessageBox(@RequestParam @Parameter(required = true, description = "投递箱ID") String boxId,
@RequestParam @Parameter(name = "sizeLimit", example = "10", description = "投递箱最大投递数") int maxSizeLimit) {
return new MessageBox();
@ -117,7 +117,7 @@ public class SwaggerApiController {
@Operation(summary = "获取投递箱详情V2", method = "POST", description = "")
@ApiResponses({@ApiResponse(responseCode = "200", description = "获取投递箱成功", content = @Content(schema = @Schema(implementation = MessageBox.class)))})
@RequestMapping(value = "/swagger/v2/getMessageBox", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/swagger/v2/getMessageBox", produces = MediaType.APPLICATION_JSON_VALUE)
public MessageBox getMessageBoxV2(@RequestBody
@Parameter(required = true, name = "messageBox", example = "投递箱信息") MessageBox messageBox) {
return new MessageBox();
@ -125,7 +125,7 @@ public class SwaggerApiController {
@Operation(summary = "获取投递箱详情V3", method = "POST", description = "")
@ApiResponses({@ApiResponse(responseCode = "200", description = "获取投递箱成功", content = @Content(schema = @Schema(implementation = Map.class)))})
@RequestMapping(value = "/swagger/v3/getMessageBox", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/swagger/v3/getMessageBox", produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> queryMessageBoxV3(@RequestBody
@Parameter(required = true, name = "messageBox", example = "投递箱信息") MessageBox messageBox) {

@ -16,7 +16,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<artifactId>spring-boot-starter-aspectj</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>

@ -32,7 +32,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-server</artifactId>
<artifactId>spring-cloud-gateway-server-webflux</artifactId>
<optional>true</optional>
</dependency>

@ -529,7 +529,7 @@ public class ContextGatewayFilter implements GatewayFilter, Ordered {
private Map<String, String> copyRequestHeader(ServerHttpRequest request) {
Map<String, String> headerMap = new LinkedHashMap<>();
HttpHeaders headers = request.getHeaders();
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
for (Map.Entry<String, List<String>> entry : headers.headerSet()) {
if (!entry.getValue().isEmpty()) {
headerMap.put(entry.getKey(), entry.getValue().get(0));
}

@ -18,11 +18,11 @@
package com.tencent.tsf.gateway.core.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tencent.cloud.common.util.JacksonUtils;
import com.tencent.polaris.api.utils.StringUtils;
import com.tencent.tsf.gateway.core.exception.TsfGatewayError;
import com.tencent.tsf.gateway.core.exception.TsfGatewayException;
import tools.jackson.core.type.TypeReference;
public class RequestTransformerPlugin extends PluginInfo {

@ -25,7 +25,6 @@ import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tencent.cloud.common.util.JacksonUtils;
import com.tencent.cloud.plugin.gateway.context.Position;
import com.tencent.polaris.api.utils.CollectionUtils;
@ -50,6 +49,7 @@ import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import shade.polaris.com.google.common.base.Joiner;
import tools.jackson.core.type.TypeReference;
import org.springframework.tsf.core.TsfContext;
import org.springframework.tsf.core.entity.Tag;

@ -20,11 +20,11 @@ package com.tencent.tsf.gateway.core.model;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tencent.cloud.common.util.JacksonUtils;
import com.tencent.cloud.plugin.gateway.context.Position;
import com.tencent.tsf.gateway.core.exception.TsfGatewayException;
import org.junit.jupiter.api.Test;
import tools.jackson.core.type.TypeReference;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;

@ -22,7 +22,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<artifactId>spring-boot-starter-aspectj</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>

@ -25,8 +25,8 @@ import com.tencent.cloud.polaris.context.config.extend.tsf.TsfTlsProperties;
import com.tencent.polaris.api.utils.ClassUtils;
import com.tencent.polaris.api.utils.StringUtils;
import org.springframework.boot.EnvironmentPostProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;

@ -1,2 +1,2 @@
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.boot.EnvironmentPostProcessor=\
com.tencent.cloud.plugin.tsf.tls.TlsEnvironmentPostProcessor

@ -22,7 +22,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<artifactId>spring-boot-starter-aspectj</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>

@ -28,13 +28,13 @@
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<groupId>tools.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<optional>true</optional>
</dependency>

@ -26,7 +26,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
import com.tencent.cloud.common.util.JacksonUtils;
import com.tencent.cloud.common.util.MetadataContextUtils;
@ -36,6 +35,7 @@ import com.tencent.polaris.metadata.core.MetadataType;
import com.tencent.tsf.unit.core.model.UnitRouteInfo.GrayMatchRouteUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.jackson.core.type.TypeReference;
public final class TencentUnitContext {

@ -20,7 +20,6 @@ package com.tencent.tsf.unit.core.mapping.impl;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tencent.polaris.api.utils.StringUtils;
import com.tencent.tsf.unit.core.TencentUnitManager;
import com.tencent.tsf.unit.core.exception.ErrorCode;
@ -33,6 +32,7 @@ import shade.polaris.okhttp3.HttpUrl;
import shade.polaris.okhttp3.OkHttpClient;
import shade.polaris.okhttp3.Request;
import shade.polaris.okhttp3.Response;
import tools.jackson.databind.json.JsonMapper;
public class CustomerMappingService implements IMappingService {
@ -74,8 +74,8 @@ public class CustomerMappingService implements IMappingService {
throw new TencentUnitException(ErrorCode.MAPPING_RESPONSE_EMPTY_BODY_ERROR, msg);
}
ObjectMapper objectMapper = new ObjectMapper();
MappingEntity entity = objectMapper.readValue(response.body().string(), MappingEntity.class);
JsonMapper JsonMapper = new JsonMapper();
MappingEntity entity = JsonMapper.readValue(response.body().string(), MappingEntity.class);
response.body().close();
return entity;
}

@ -21,16 +21,15 @@ import com.ecwid.consul.v1.ConsulClient;
import com.ecwid.consul.v1.QueryParams;
import com.ecwid.consul.v1.Response;
import com.ecwid.consul.v1.kv.model.GetValue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.tencent.cloud.common.util.GzipUtil;
import com.tencent.tsf.unit.core.Env;
import com.tencent.tsf.unit.core.TencentUnitManager;
import com.tencent.tsf.unit.core.model.UnitArch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.dataformat.yaml.YAMLMapper;
public final class TencentUnitArchKVLoader {
@ -91,11 +90,11 @@ public final class TencentUnitArchKVLoader {
}
}
public static void loadUnitArch(String content) throws JsonProcessingException {
public static void loadUnitArch(String content) throws JacksonException {
LOGGER.info("[unit] unit arch config old raw content:\n{}", rawContent);
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
YAMLMapper mapper = new YAMLMapper();
mapper.rebuild().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
TencentUnitManager.setUnitArch(mapper.readValue(content, UnitArch.class));
rawContent = content;

@ -21,16 +21,15 @@ import com.ecwid.consul.v1.ConsulClient;
import com.ecwid.consul.v1.QueryParams;
import com.ecwid.consul.v1.Response;
import com.ecwid.consul.v1.kv.model.GetValue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.tencent.cloud.common.util.GzipUtil;
import com.tencent.tsf.unit.core.Env;
import com.tencent.tsf.unit.core.TencentUnitManager;
import com.tencent.tsf.unit.core.model.UnitGray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.dataformat.yaml.YAMLMapper;
public final class TencentUnitGrayKVLoader {
@ -89,11 +88,11 @@ public final class TencentUnitGrayKVLoader {
}
}
public static void loadUnitGray(String content) throws JsonProcessingException {
public static void loadUnitGray(String content) throws JacksonException {
LOGGER.info("[unit] unit gray old raw content:\n{}", rawContent);
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
YAMLMapper mapper = new YAMLMapper();
mapper.rebuild().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
TencentUnitManager.setUnitGray(mapper.readValue(content, UnitGray.class));
rawContent = content;

@ -21,16 +21,15 @@ import com.ecwid.consul.v1.ConsulClient;
import com.ecwid.consul.v1.QueryParams;
import com.ecwid.consul.v1.Response;
import com.ecwid.consul.v1.kv.model.GetValue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.tencent.cloud.common.util.GzipUtil;
import com.tencent.tsf.unit.core.Env;
import com.tencent.tsf.unit.core.TencentUnitManager;
import com.tencent.tsf.unit.core.model.UnitRouteInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.dataformat.yaml.YAMLMapper;
public final class TencentUnitRouteRuleKVLoader {
@ -89,11 +88,11 @@ public final class TencentUnitRouteRuleKVLoader {
}
}
public static void loadUnitRouteRule(String content) throws JsonProcessingException {
public static void loadUnitRouteRule(String content) throws JacksonException {
LOGGER.info("[unit] unit route rule old raw content:\n{}", rawContent);
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
YAMLMapper mapper = new YAMLMapper();
mapper.rebuild().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
TencentUnitManager.setUnitRouteRule(mapper.readValue(content, UnitRouteInfo.class));
rawContent = content;

@ -23,9 +23,9 @@ import java.util.Map;
import com.tencent.polaris.api.utils.StringUtils;
import org.apache.commons.logging.Log;
import org.springframework.boot.EnvironmentPostProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.logging.DeferredLogFactory;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;

@ -26,9 +26,9 @@ import com.tencent.polaris.api.utils.StringUtils;
import com.tencent.polaris.plugins.router.lane.BaseLaneMode;
import org.apache.commons.logging.Log;
import org.springframework.boot.EnvironmentPostProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.logging.DeferredLogFactory;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;

@ -24,9 +24,9 @@ import com.tencent.cloud.common.tsf.TsfContextUtils;
import com.tencent.polaris.api.utils.StringUtils;
import org.apache.commons.logging.Log;
import org.springframework.boot.EnvironmentPostProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.logging.DeferredLogFactory;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;

@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.logging.LoggingApplicationListener;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.server.context.WebServerInitializedEvent;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ConfigurableApplicationContext;

@ -3,7 +3,7 @@ org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.context.ApplicationListener=\
com.tencent.cloud.polaris.context.logging.PolarisLoggingApplicationListener,\
com.tencent.cloud.polaris.context.listener.FailedEventApplicationListener
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.boot.EnvironmentPostProcessor=\
com.tencent.cloud.polaris.context.config.PolarisContextEnvironmentPostProcessor,\
com.tencent.cloud.polaris.context.config.extend.tsf.TsfCoreEnvironmentPostProcessor,\
com.tencent.cloud.polaris.context.config.extend.tsf.TsfLastEnvironmentPostProcessor

@ -23,7 +23,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<artifactId>spring-boot-starter-aspectj</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
@ -55,7 +55,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-server</artifactId>
<artifactId>spring-cloud-gateway-server-webflux</artifactId>
<optional>true</optional>
</dependency>

@ -69,7 +69,7 @@ public class EnhancedReactiveFilter implements WebFilter, Ordered {
enhancedPluginContext.setDelay(System.currentTimeMillis() - startMillis);
EnhancedResponseContext enhancedResponseContext = EnhancedResponseContext.builder()
.httpStatus(exchange.getResponse().getRawStatusCode())
.httpStatus(exchange.getResponse().getStatusCode().value())
.httpHeaders(exchange.getResponse().getHeaders())
.build();
enhancedPluginContext.setResponse(enhancedResponseContext);

@ -46,6 +46,7 @@ import org.springframework.cloud.gateway.route.Route;
import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;
@ -177,7 +178,7 @@ public class EnhancedGatewayGlobalFilter implements GlobalFilter, Ordered {
enhancedPluginContext.setDelay(System.currentTimeMillis() - startTime);
EnhancedResponseContext enhancedResponseContext = EnhancedResponseContext.builder()
.httpStatus(exchange.getResponse().getRawStatusCode())
.httpStatus(Optional.ofNullable(exchange.getResponse().getStatusCode()).map(HttpStatusCode::value).orElse(null))
.httpHeaders(exchange.getResponse().getHeaders())
.build();
enhancedPluginContext.setResponse(enhancedResponseContext);
@ -222,7 +223,7 @@ public class EnhancedGatewayGlobalFilter implements GlobalFilter, Ordered {
if (uri != null) {
if (route != null && route.getUri().getScheme()
.contains("lb") && StringUtils.isNotEmpty(serviceId)) {
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(serviceId);
serviceInstance.setHost(uri.getHost());
serviceInstance.setPort(uri.getPort());

@ -67,7 +67,7 @@ public class DefaultEnhancedPluginRunner implements EnhancedPluginRunner {
localServiceInstance = registration;
}
else {
DefaultServiceInstance defaultServiceInstance = new DefaultServiceInstance();
DefaultServiceInstance defaultServiceInstance = new DefaultServiceInstance(null, null, null, 0, false);
defaultServiceInstance.setServiceId(MetadataContext.LOCAL_SERVICE);
defaultServiceInstance.setHost(sdkContext.getConfig().getGlobal().getAPI().getBindIP());
localServiceInstance = defaultServiceInstance;

@ -121,7 +121,7 @@ public class EnhancedPluginContext {
this.targetServiceInstance = targetServiceInstance;
}
else if (Objects.nonNull(url)) {
DefaultServiceInstance defaultServiceInstance = new DefaultServiceInstance();
DefaultServiceInstance defaultServiceInstance = new DefaultServiceInstance(null, null, null, 0, false);
defaultServiceInstance.setUri(url);
if (defaultServiceInstance.isSecure()) {
defaultServiceInstance.setPort(443);
@ -132,7 +132,7 @@ public class EnhancedPluginContext {
this.targetServiceInstance = defaultServiceInstance;
}
else {
this.targetServiceInstance = new DefaultServiceInstance();
this.targetServiceInstance = new DefaultServiceInstance(null, null, null, 0, false);
LOGGER.warn("TargetServiceInstance is empty.");
}
}

@ -29,9 +29,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tencent.cloud.common.constant.HeaderConstant;
import com.tencent.cloud.common.constant.MetadataConstant;
import com.tencent.cloud.common.constant.RouterConstant;
@ -50,6 +47,9 @@ import com.tencent.polaris.api.utils.CollectionUtils;
import com.tencent.polaris.api.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.jackson.core.JacksonException;
import tools.jackson.core.type.TypeReference;
import tools.jackson.databind.json.JsonMapper;
import org.springframework.beans.BeansException;
import org.springframework.http.HttpHeaders;
@ -204,7 +204,7 @@ public final class PolarisEnhancedPluginUtils {
}
static RetStatus getRetStatusFromRequest(HttpHeaders headers, RetStatus defaultVal) {
if (headers != null && headers.containsKey(HeaderConstant.INTERNAL_CALLEE_RET_STATUS)) {
if (headers != null && headers.containsHeader(HeaderConstant.INTERNAL_CALLEE_RET_STATUS)) {
List<String> values = headers.get(HeaderConstant.INTERNAL_CALLEE_RET_STATUS);
if (CollectionUtils.isNotEmpty(values)) {
String retStatusVal = com.tencent.polaris.api.utils.StringUtils.defaultString(values.get(0));
@ -220,7 +220,7 @@ public final class PolarisEnhancedPluginUtils {
}
static String getActiveRuleNameFromRequest(HttpHeaders headers) {
if (headers != null && headers.containsKey(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME)) {
if (headers != null && headers.containsHeader(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME)) {
Collection<String> values = headers.get(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME);
if (CollectionUtils.isNotEmpty(values)) {
String decodedActiveRuleName = "";
@ -285,9 +285,9 @@ public final class PolarisEnhancedPluginUtils {
LOG.error("unsupported charset exception " + UTF_8, e);
}
try {
return new ObjectMapper().readValue(label, new TypeReference<HashMap<String, String>>() { });
return new JsonMapper().readValue(label, new TypeReference<HashMap<String, String>>() { });
}
catch (JsonProcessingException e) {
catch (JacksonException e) {
LOG.error("parse label map exception", e);
}
}

@ -72,8 +72,8 @@ public class ExceptionPolarisReporter implements EnhancedPlugin {
}
EnhancedRequestContext request = context.getRequest();
ServiceInstance callerServiceInstance = Optional.ofNullable(context.getLocalServiceInstance()).orElse(new DefaultServiceInstance());
ServiceInstance calleeServiceInstance = Optional.ofNullable(context.getTargetServiceInstance()).orElse(new DefaultServiceInstance());
ServiceInstance callerServiceInstance = Optional.ofNullable(context.getLocalServiceInstance()).orElse(new DefaultServiceInstance(null, null, null, 0, false));
ServiceInstance calleeServiceInstance = Optional.ofNullable(context.getTargetServiceInstance()).orElse(new DefaultServiceInstance(null, null, null, 0, false));
ServiceCallResult resultRequest = PolarisEnhancedPluginUtils.createServiceCallResult(
callerServiceInstance.getHost(),

@ -73,8 +73,8 @@ public class SuccessPolarisReporter implements EnhancedPlugin {
EnhancedRequestContext request = context.getRequest();
EnhancedResponseContext response = context.getResponse();
ServiceInstance callerServiceInstance = Optional.ofNullable(context.getLocalServiceInstance()).orElse(new DefaultServiceInstance());
ServiceInstance calleeServiceInstance = Optional.ofNullable(context.getTargetServiceInstance()).orElse(new DefaultServiceInstance());
ServiceInstance callerServiceInstance = Optional.ofNullable(context.getLocalServiceInstance()).orElse(new DefaultServiceInstance(null, null, null, 0, false));
ServiceInstance calleeServiceInstance = Optional.ofNullable(context.getTargetServiceInstance()).orElse(new DefaultServiceInstance(null, null, null, 0, false));
ServiceCallResult resultRequest = PolarisEnhancedPluginUtils.createServiceCallResult(
callerServiceInstance.getHost(),

@ -49,7 +49,8 @@ public class RpcEnhancementAutoConfigurationTest {
RpcEnhancementAutoConfiguration.class,
PolarisRestTemplateAutoConfigurationTester.class,
FeignLoadBalancerAutoConfiguration.class))
.withPropertyValues("spring.cloud.polaris.circuitbreaker.enabled=true", "spring.application.name=test", "spring.cloud.gateway.enabled=false");
.withPropertyValues("spring.cloud.polaris.circuitbreaker.enabled=true", "spring.application.name=test", "spring.cloud.gateway.enabled=false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration");
@Test
public void testDefaultInitialization() {

@ -38,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
"spring.application.name=test",
"spring.cloud.gateway.enabled=false",
"spring.cloud.tencent.rpc-enhancement=true",
"spring.cloud.tencent.rpc-enhancement.ignore-body=false"
"spring.cloud.tencent.rpc-enhancement.ignore-body=false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"
})
@ActiveProfiles("test")
public class RpcEnhancementPropertiesTest {

@ -41,7 +41,8 @@ import static org.springframework.http.HttpStatus.Series.SERVER_ERROR;
@SpringBootTest(classes = RpcEnhancementReporterPropertiesTest.TestApplication.class, properties = {
"spring.application.name=test",
"spring.cloud.gateway.enabled=false",
"spring.cloud.tencent.rpc-enhancement.reporter=true"
"spring.cloud.tencent.rpc-enhancement.reporter=true",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"
})
@ActiveProfiles("test")
public class RpcEnhancementReporterPropertiesTest {

@ -59,7 +59,8 @@ import static org.mockito.Mockito.mock;
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = EnhancedFeignClientTest.TestApplication.class,
properties = {"spring.cloud.polaris.namespace=Test", "spring.cloud.polaris.service=TestApp", "spring.cloud.gateway.enabled=false"})
properties = {"spring.cloud.polaris.namespace=Test", "spring.cloud.polaris.service=TestApp", "spring.cloud.gateway.enabled=false",
"spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration"})
public class EnhancedFeignClientTest {
@Autowired

@ -170,7 +170,7 @@ public class EnhancedWebClientExchangeFilterFunctionTest {
StepVerifier.create(responseMono)
.expectNextMatches(response -> {
assertThat(response.statusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE);
assertThat(response.headers().asHttpHeaders().containsKey("header-key")).isTrue();
assertThat(response.headers().asHttpHeaders().containsHeader("header-key")).isTrue();
return true;
})
.verifyComplete();

@ -121,7 +121,7 @@ public class EnhancedPluginContextTest {
EnhancedPluginContext enhancedPluginContext = new EnhancedPluginContext();
enhancedPluginContext.setRequest(requestContext);
enhancedPluginContext.setResponse(responseContext);
enhancedPluginContext.setTargetServiceInstance(new DefaultServiceInstance(), null);
enhancedPluginContext.setTargetServiceInstance(new DefaultServiceInstance(null, null, null, 0, false), null);
enhancedPluginContext.setThrowable(mock(Exception.class));
enhancedPluginContext.setDelay(0);
assertThat(enhancedPluginContext.getRequest()).isNotNull();
@ -161,7 +161,7 @@ public class EnhancedPluginContextTest {
EnhancedPluginContext enhancedPluginContext = new EnhancedPluginContext();
// targetServiceInstance != null
DefaultServiceInstance testDefaultServiceInstance = new DefaultServiceInstance();
DefaultServiceInstance testDefaultServiceInstance = new DefaultServiceInstance(null, null, null, 1, false);
testDefaultServiceInstance.setPort(1);
enhancedPluginContext.setTargetServiceInstance(testDefaultServiceInstance, null);
assertThat(enhancedPluginContext.getTargetServiceInstance().getPort()).isEqualTo(1);

@ -119,7 +119,7 @@ public class ExceptionPolarisReporterTest {
.httpStatus(200)
.build();
response.toString();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);

@ -117,7 +117,7 @@ public class SuccessPolarisReporterTest {
.httpStatus(200)
.build();
response.toString();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance();
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(null, null, null, 0, false);
serviceInstance.setServiceId(SERVICE_PROVIDER);
pluginContext.setRequest(request);

@ -45,7 +45,8 @@ public class StatConfigModifierTest {
.withPropertyValues("spring.cloud.polaris.stat.port=20000")
.withPropertyValues("spring.cloud.polaris.stat.path=/xxx")
.withPropertyValues("spring.application.name=test")
.withPropertyValues("spring.cloud.gateway.enabled=false");
.withPropertyValues("spring.cloud.gateway.enabled=false")
.withPropertyValues("spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration");
private final ApplicationContextRunner pushContextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(TestApplication.class))
@ -58,14 +59,16 @@ public class StatConfigModifierTest {
.withPropertyValues("spring.cloud.polaris.stat.pushgateway.namespace=test-namespace")
.withPropertyValues("spring.cloud.polaris.stat.pushgateway.service=test-service")
.withPropertyValues("spring.application.name=test")
.withPropertyValues("spring.cloud.gateway.enabled=false");
.withPropertyValues("spring.cloud.gateway.enabled=false")
.withPropertyValues("spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration");
private final ApplicationContextRunner disabledContextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(TestApplication.class))
.withPropertyValues("spring.cloud.polaris.enabled=true")
.withPropertyValues("spring.cloud.polaris.stat.enabled=false")
.withPropertyValues("spring.application.name=test")
.withPropertyValues("spring.cloud.gateway.enabled=false");
.withPropertyValues("spring.cloud.gateway.enabled=false")
.withPropertyValues("spring.autoconfigure.exclude=org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration,org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration");
@BeforeEach
void setUp() {

Loading…
Cancel
Save