Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the unit test failure of kafka configuring user agent #32636

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private Map<String, String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down