From 0950e5a3a2ae6601408162604fd22b8e3e1a0c16 Mon Sep 17 00:00:00 2001 From: yiliuTo Date: Mon, 19 Dec 2022 10:44:16 +0800 Subject: [PATCH] rollback the static synchronized method --- .../kafka/AbstractKafkaPropertiesBeanPostProcessor.java | 2 +- .../kafka/AbstractKafkaPropertiesBeanPostProcessorTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessor.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessor.java index bbfb84f8b7d9c..a9ab288fef76e 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessor.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessor.java @@ -217,7 +217,7 @@ private Map convertAzurePropertiesToMap(AzureProperties properti /** * Configure Spring Cloud Azure user-agent for Kafka client. This method is idempotent to avoid configuring UA repeatedly. */ - synchronized void configureKafkaUserAgent() { + static synchronized void configureKafkaUserAgent() { Method dataMethod = ReflectionUtils.findMethod(ApiVersionsRequest.class, "data"); if (dataMethod != null) { ApiVersionsRequest apiVersionsRequest = new ApiVersionsRequest.Builder().build(); diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessorTest.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessorTest.java index 7c1da305524d3..d7dc5a25ed307 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessorTest.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/kafka/AbstractKafkaPropertiesBeanPostProcessorTest.java @@ -113,7 +113,7 @@ void testWhenMultipleBootstrapServersStringConfigured() { @Test void testConfigureKafkaUserAgent() { getApiVersionsRequestData().ifPresent(method -> { - processor.configureKafkaUserAgent(); + AbstractKafkaPropertiesBeanPostProcessor.configureKafkaUserAgent(); ApiVersionsRequest apiVersionsRequest = new ApiVersionsRequest.Builder().build(); ApiVersionsRequestData apiVersionsRequestData = (ApiVersionsRequestData) ReflectionUtils.invokeMethod(method, apiVersionsRequest); assertTrue(apiVersionsRequestData.clientSoftwareName() @@ -126,8 +126,8 @@ void testConfigureKafkaUserAgent() { @Test void testConfigureKafkaUserAgentMultipleTimes() { getApiVersionsRequestData().ifPresent(method -> { - processor.configureKafkaUserAgent(); - processor.configureKafkaUserAgent(); + AbstractKafkaPropertiesBeanPostProcessor.configureKafkaUserAgent(); + AbstractKafkaPropertiesBeanPostProcessor.configureKafkaUserAgent(); ApiVersionsRequest apiVersionsRequest = new ApiVersionsRequest.Builder().build(); ApiVersionsRequestData apiVersionsRequestData = (ApiVersionsRequestData) ReflectionUtils.invokeMethod(method, apiVersionsRequest); assertTrue(apiVersionsRequestData.clientSoftwareName()