Skip to content

Commit

Permalink
Some clean and deprecated method replaced (#840)
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Patierno <[email protected]>
  • Loading branch information
ppatierno authored Oct 7, 2023
1 parent 7b6d666 commit b328404
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ public void doGetTopic(RoutingContext routingContext) {
if (configEntries.size() > 0) {
ObjectNode configs = JsonUtils.createObjectNode();
configEntries.forEach(configEntry -> configs.put(configEntry.name(), configEntry.value()));
root.put("configs", configs);
root.set("configs", configs);
}
TopicDescription description = topicDescriptions.get(topicName);
if (description != null) {
description.partitions().forEach(partitionInfo -> {
partitionsArray.add(createPartitionMetadata(partitionInfo));
});
}
root.put("partitions", partitionsArray);
root.set("partitions", partitionsArray);
HttpUtils.sendResponse(routingContext, HttpResponseStatus.OK.code(), BridgeContentType.KAFKA_JSON, JsonUtils.jsonToBytes(root));
} else if (ex.getCause() instanceof UnknownTopicOrPartitionException) {
HttpBridgeError error = new HttpBridgeError(
Expand Down Expand Up @@ -339,7 +339,7 @@ private static ObjectNode createPartitionMetadata(TopicPartitionInfo partitionIn
replica.put("in_sync", insyncSet.contains(node.id()));
replicasArray.add(replica);
});
root.put("replicas", replicasArray);
root.set("replicas", replicasArray);
return root;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ private void doListSubscriptions(RoutingContext routingContext) {
}
for (Map.Entry<String, ArrayNode> part: partitions.entrySet()) {
ObjectNode topic = JsonUtils.createObjectNode();
topic.put(part.getKey(), part.getValue());
topic.set(part.getKey(), part.getValue());
partitionsArray.add(topic);
}
ArrayNode topicsArray = JsonUtils.createArrayNode(topics);
root.put("topics", topicsArray);
root.put("partitions", partitionsArray);
root.set("topics", topicsArray);
root.set("partitions", partitionsArray);

HttpUtils.sendResponse(routingContext, HttpResponseStatus.OK.code(), BridgeContentType.KAFKA_JSON, JsonUtils.jsonToBytes(root));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private ObjectNode buildOffsets(List<HttpBridgeResult<?>> results) {
}
offsets.add(offset);
}
jsonResponse.put("offsets", offsets);
jsonResponse.set("offsets", offsets);
return jsonResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public byte[] toMessages(ConsumerRecords<byte[], byte[]> records) {
headers.add(header);
}
if (!headers.isEmpty()) {
jsonObject.put("headers", headers);
jsonObject.set("headers", headers);
}
jsonArray.add(jsonObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public byte[] toMessages(ConsumerRecords<byte[], byte[]> records) {
ObjectNode jsonObject = JsonUtils.createObjectNode();

jsonObject.put("topic", record.topic());
jsonObject.put("key", record.key() != null ?
jsonObject.set("key", record.key() != null ?
JsonUtils.bytesToJson(record.key()) : null);
jsonObject.put("value", record.value() != null ?
jsonObject.set("value", record.value() != null ?
JsonUtils.bytesToJson(record.value()) : null);
jsonObject.put("partition", record.partition());
jsonObject.put("offset", record.offset());
Expand All @@ -109,7 +109,7 @@ public byte[] toMessages(ConsumerRecords<byte[], byte[]> records) {
headers.add(header);
}
if (!headers.isEmpty()) {
jsonObject.put("headers", headers);
jsonObject.set("headers", headers);
}
jsonArray.add(jsonObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private static TextMapPropagator propagator() {
return GlobalOpenTelemetry.getPropagators().getTextMapPropagator();
}

private static final TextMapGetter<RoutingContext> ROUTING_CONTEXT_GETTER = new TextMapGetter<RoutingContext>() {
private static final TextMapGetter<RoutingContext> ROUTING_CONTEXT_GETTER = new TextMapGetter<>() {
@Override
public Iterable<String> keys(RoutingContext rc) {
return rc.request().headers().names();
Expand All @@ -126,7 +126,7 @@ public String get(RoutingContext rc, String key) {
}
};

private static final TextMapGetter<Map<String, String>> MG = new TextMapGetter<Map<String, String>>() {
private static final TextMapGetter<Map<String, String>> MG = new TextMapGetter<>() {
@Override
public Iterable<String> keys(Map<String, String> map) {
return map.keySet();
Expand Down

0 comments on commit b328404

Please sign in to comment.