Skip to content

Commit

Permalink
Revert spotbugs changes
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Valeri <[email protected]>
  • Loading branch information
fvaleri committed Feb 13, 2025
1 parent c22ccc9 commit 328afba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
23 changes: 9 additions & 14 deletions src/main/java/io/strimzi/kafka/bridge/http/HttpBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,15 @@ public void process(RoutingContext routingContext) {
}
};

final HttpOpenApiOperation OPENAPIV2 = new NotSupportedApi(HttpOpenApiOperations.OPENAPIV2);
final HttpOpenApiOperation OPENAPIV2 = new HttpOpenApiOperation(HttpOpenApiOperations.OPENAPIV2) {

@Override
public void process(RoutingContext routingContext) {
HttpBridgeError error = new HttpBridgeError(HttpResponseStatus.GONE.code(), "OpenAPI v2 Swagger not supported");
HttpUtils.sendResponse(routingContext, HttpResponseStatus.GONE.code(),
BridgeContentType.KAFKA_JSON, JsonUtils.jsonToBytes(error.toJson()));
}
};

final HttpOpenApiOperation OPENAPIV3 = new HttpOpenApiOperation(HttpOpenApiOperations.OPENAPIV3) {

Expand All @@ -852,17 +860,4 @@ public void process(RoutingContext routingContext) {
information(routingContext);
}
};

static class NotSupportedApi extends HttpOpenApiOperation {
public NotSupportedApi(HttpOpenApiOperations operationId) {
super(operationId);
}

@Override
public void process(RoutingContext routingContext) {
HttpBridgeError error = new HttpBridgeError(HttpResponseStatus.GONE.code(), "OpenAPI v2 Swagger not supported");
HttpUtils.sendResponse(routingContext, HttpResponseStatus.GONE.code(),
BridgeContentType.KAFKA_JSON, JsonUtils.jsonToBytes(error.toJson()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import org.apache.kafka.common.header.internals.RecordHeaders;

import javax.xml.bind.DatatypeConverter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -44,14 +42,14 @@ public ProducerRecord<byte[], byte[]> toKafkaRecord(String kafkaTopic, Integer p
if (!keyNode.isTextual()) {
throw new IllegalStateException("Because the embedded format is 'text', the key must be a string");
}
key = keyNode.asText().getBytes(Charset.forName("UTF-8"));
key = keyNode.asText().getBytes();
}
if (json.has("value")) {
JsonNode valueNode = json.get("value");
if (!valueNode.isTextual()) {
throw new IllegalStateException("Because the embedded format is 'text', the value must be a string");
}
value = valueNode.asText().getBytes(Charset.forName("UTF-8"));
value = valueNode.asText().getBytes();
}
if (json.has("timestamp")) {
timestamp = json.get("timestamp").asLong();
Expand Down Expand Up @@ -102,8 +100,8 @@ public byte[] toMessages(ConsumerRecords<byte[], byte[]> records) {
ObjectNode jsonObject = JsonUtils.createObjectNode();

jsonObject.set("topic", new TextNode(record.topic()));
jsonObject.set("key", record.key() != null ? new TextNode(new String(record.key(), StandardCharsets.UTF_8)) : null);
jsonObject.set("value", record.value() != null ? new TextNode(new String(record.value(), StandardCharsets.UTF_8)) : null);
jsonObject.set("key", record.key() != null ? new TextNode(new String(record.key())) : null);
jsonObject.set("value", record.value() != null ? new TextNode(new String(record.value())) : null);
jsonObject.put("partition", record.partition());
jsonObject.put("offset", record.offset());
jsonObject.put("timestamp", record.timestamp());
Expand Down

0 comments on commit 328afba

Please sign in to comment.