Skip to content

Commit

Permalink
HOTFIX: Fix compile error in TopicAdminTest (apache#8866)
Browse files Browse the repository at this point in the history
Commit 9a4f00f changed the constructor of DescribeConfigsResponse.

The build failed with the following error: 
```
/home/chia7712/kafka/connect/runtime/src/test/java/org/apache/kafka/connect/util/TopicAdminTest.java:582: error: incompatible types: int cannot be converted to Struct
        return new DescribeConfigsResponse(1000, configs);
                                           ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
```

Reviewers: Boyang Chan <[email protected]>, Tom Bentley <[email protected]>, Konstantine Karantasis <[email protected]>
  • Loading branch information
chia7712 authored Jun 13, 2020
1 parent 03ed08d commit 88fe466
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.kafka.common.errors.UnsupportedVersionException;
import org.apache.kafka.common.message.CreateTopicsResponseData;
import org.apache.kafka.common.message.CreateTopicsResponseData.CreatableTopicResult;
import org.apache.kafka.common.message.DescribeConfigsResponseData;
import org.apache.kafka.common.message.MetadataResponseData;
import org.apache.kafka.common.protocol.Errors;
import org.apache.kafka.common.requests.ApiError;
Expand All @@ -46,13 +47,14 @@
import org.apache.kafka.connect.errors.ConnectException;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.apache.kafka.common.message.MetadataResponseData.MetadataResponseTopic;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -567,19 +569,20 @@ private DescribeConfigsResponse describeConfigsResponseWithTopicAuthorizationExc
}

private DescribeConfigsResponse describeConfigsResponse(ApiError error, NewTopic... topics) {
if (error == null) error = new ApiError(Errors.NONE, "");
Map<ConfigResource, DescribeConfigsResponse.Config> configs = new HashMap<>();
for (NewTopic topic : topics) {
ConfigResource resource = new ConfigResource(ConfigResource.Type.TOPIC, topic.name());
DescribeConfigsResponse.ConfigSource source = DescribeConfigsResponse.ConfigSource.TOPIC_CONFIG;
Collection<DescribeConfigsResponse.ConfigEntry> entries = new ArrayList<>();
topic.configs().forEach((k, v) -> new DescribeConfigsResponse.ConfigEntry(
k, v, source, false, false, Collections.emptySet()
));
DescribeConfigsResponse.Config config = new DescribeConfigsResponse.Config(error, entries);
configs.put(resource, config);
}
return new DescribeConfigsResponse(1000, configs);
List<DescribeConfigsResponseData.DescribeConfigsResult> results = Stream.of(topics)
.map(topic -> new DescribeConfigsResponseData.DescribeConfigsResult()
.setErrorCode(error.error().code())
.setErrorMessage(error.message())
.setResourceType(ConfigResource.Type.TOPIC.id())
.setResourceName(topic.name())
.setConfigs(topic.configs().entrySet()
.stream()
.map(e -> new DescribeConfigsResponseData.DescribeConfigsResourceResult()
.setName(e.getKey())
.setValue(e.getValue()))
.collect(Collectors.toList())))
.collect(Collectors.toList());
return new DescribeConfigsResponse(new DescribeConfigsResponseData().setThrottleTimeMs(1000).setResults(results));
}

}

0 comments on commit 88fe466

Please sign in to comment.