diff --git a/CHANGELOG.md b/CHANGELOG.md index d76a5b158..613166087 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Change Log --- -- [fix: fix log feign response stream close bug.](https://github.com/Tencent/spring-cloud-tencent/pull/897) \ No newline at end of file +- [fix: fix log feign response stream close bug.](https://github.com/Tencent/spring-cloud-tencent/pull/897) +- [fix:remove the secondary report.](https://github.com/Tencent/spring-cloud-tencent/pull/899) \ No newline at end of file diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/ExceptionPolarisReporter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/ExceptionPolarisReporter.java index f0498fac6..a1496fa11 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/ExceptionPolarisReporter.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/ExceptionPolarisReporter.java @@ -46,7 +46,7 @@ public class ExceptionPolarisReporter implements EnhancedFeignPlugin { private final ConsumerAPI consumerAPI; public ExceptionPolarisReporter(RpcEnhancementReporterProperties reporterProperties, - ConsumerAPI consumerAPI) { + ConsumerAPI consumerAPI) { this.reporterProperties = reporterProperties; this.consumerAPI = consumerAPI; } @@ -75,12 +75,10 @@ public class ExceptionPolarisReporter implements EnhancedFeignPlugin { if (exception instanceof SocketTimeoutException) { retStatus = RetStatus.RetTimeout; } - LOG.debug("Will report result of {}. Request=[{} {}]. Response=[{}].", retStatus.name(), request.httpMethod().name(), request.url(), response.status()); + LOG.debug("Will report result of {}. Request=[{} {}]. Response=[{}].", retStatus.name(), request.httpMethod() + .name(), request.url(), response.status()); ServiceCallResult resultRequest = ReporterUtils.createServiceCallResult(request, retStatus); consumerAPI.updateServiceCallResult(resultRequest); - // update result without method for service circuit break. - resultRequest.setMethod(""); - consumerAPI.updateServiceCallResult(resultRequest); } } diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/SuccessPolarisReporter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/SuccessPolarisReporter.java index 933619766..cc009d1b8 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/SuccessPolarisReporter.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/plugin/reporter/SuccessPolarisReporter.java @@ -72,12 +72,10 @@ public class SuccessPolarisReporter extends AbstractPolarisReporterAdapter imple if (apply(HttpStatus.resolve(response.status()))) { retStatus = RetStatus.RetFail; } - LOG.debug("Will report result of {}. Request=[{} {}]. Response=[{}].", retStatus.name(), request.httpMethod().name(), request.url(), response.status()); + LOG.debug("Will report result of {}. Request=[{} {}]. Response=[{}].", retStatus.name(), request.httpMethod() + .name(), request.url(), response.status()); ServiceCallResult resultRequest = ReporterUtils.createServiceCallResult(request, retStatus); consumerAPI.updateServiceCallResult(resultRequest); - // update result without method for service circuit break. - resultRequest.setMethod(""); - consumerAPI.updateServiceCallResult(resultRequest); } } diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporter.java index df1ec9907..b8f842e77 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporter.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporter.java @@ -153,9 +153,6 @@ public class EnhancedRestTemplateReporter extends AbstractPolarisReporterAdapter LOGGER.debug("Will report result of {}. URL=[{}]. Response=[{}].", resultRequest.getRetStatus().name(), url, response); consumerAPI.updateServiceCallResult(resultRequest); - // update result without method for service circuit break. - resultRequest.setMethod(""); - consumerAPI.updateServiceCallResult(resultRequest); } catch (Exception e) { LOGGER.error("RestTemplate response reporter execute failed of {} url {}", response, url, e); diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporterTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporterTest.java index 003f8ea7b..a431fbdb4 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporterTest.java +++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateReporterTest.java @@ -146,7 +146,7 @@ public class EnhancedRestTemplateReporterTest { URI uri = mock(URI.class); enhancedRestTemplateReporter.handleError(uri, HttpMethod.GET, response); - verify(consumerAPI, times(2)).updateServiceCallResult(any()); + verify(consumerAPI, times(1)).updateServiceCallResult(any()); verify(delegate).handleError(uri, HttpMethod.GET, response); } @@ -161,7 +161,7 @@ public class EnhancedRestTemplateReporterTest { URI uri = mock(URI.class); enhancedRestTemplateReporter.handleError(uri, HttpMethod.GET, response); - verify(consumerAPI, times(2)).updateServiceCallResult(any()); + verify(consumerAPI, times(1)).updateServiceCallResult(any()); verify(delegate, times(0)).handleError(uri, HttpMethod.GET, response); }