Skip to content

Commit

Permalink
Merge pull request #722 from camunda-community-hub/np-fix-exporter-ht…
Browse files Browse the repository at this point in the history
…tpcore5

Fix compatibility with Apache httpcore5 5.2.5 by adding a virtual host for Testcontainers' proxy
  • Loading branch information
npepinpe authored Jul 4, 2024
2 parents c40ce9a + a2f1da5 commit 43dc3a9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ default T withDebugExporter(final int port) {
"ZEEBE_BROKER_EXPORTERS_DEBUG_CLASSNAME", "io.zeebe.containers.exporter.DebugExporter")
.withEnv(
"ZEEBE_BROKER_EXPORTERS_DEBUG_ARGS_URL",
"http://host.testcontainers.internal:" + containerPort + "/records");
GenericContainer.INTERNAL_HOST_HOSTNAME + ":" + containerPort + "/records");

return self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apiguardian.api.API.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;

/**
* Receives records sent from one or more debug exporter instances. The receiver will start an HTTP
Expand Down Expand Up @@ -257,7 +258,10 @@ private HttpAsyncServer createServer() {
.setIOReactorConfig(config)
.setCanonicalHostName("localhost")
.setCharCodingConfig(CharCodingConfig.custom().setCharset(StandardCharsets.UTF_8).build())
.setHttpProcessor(HttpProcessors.server("zpt-debug/1.1"))
.setHttpProcessor(HttpProcessors.server("ztc-debug/1.1"))
// need to register the handler on both the primary and possibly Testcontainers' proxy for
// our local server, as otherwise the requests with hosts that do not match will be skipped
.registerVirtual(GenericContainer.INTERNAL_HOST_HOSTNAME, "/records", recordHandler)
.register("/records", recordHandler)
.create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import io.camunda.zeebe.protocol.record.Record;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.HttpException;
Expand Down Expand Up @@ -72,7 +72,7 @@ final class RecordHandler implements AsyncServerRequestHandler<Message<HttpReque

private final Consumer<Record<?>> recordConsumer;
private final boolean autoAcknowledge;
private final Map<Integer, Long> positions = new HashMap<>();
private final Map<Integer, Long> positions = new ConcurrentHashMap<>();

RecordHandler(final Consumer<Record<?>> recordConsumer, final boolean autoAcknowledge) {
this.recordConsumer = Objects.requireNonNull(recordConsumer, "must specify a record consumer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private HttpRequest buildRequestForRecord(final Record<?> record) throws JsonPro
.header("Content-Type", JSON_MIME_TYPE)
.header("Accept", JSON_MIME_TYPE)
.header("charset", "utf-8")
.header("User-Agent", "zpt-debug-exporter/4.0.0")
.header("User-Agent", "ztc-debug-exporter/4.0.0")
.timeout(Duration.ofSeconds(5))
.POST(
BodyPublishers.ofByteArray(MAPPER.writeValueAsBytes(Collections.singletonList(record))))
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<version.docker>3.3.6</version.docker>
<version.duct-tape>1.0.8</version.duct-tape>
<version.feign>13.2.1</version.feign>
<version.httpcore5>5.2.4</version.httpcore5>
<version.httpcore5>5.2.5</version.httpcore5>
<version.jackson>2.17.1</version.jackson>
<version.jcip>1.0</version.jcip>
<version.junit-jupiter>5.10.3</version.junit-jupiter>
Expand Down

0 comments on commit 43dc3a9

Please sign in to comment.