From ba2aae6740cb997d27b9571ba83f63b8870a88c8 Mon Sep 17 00:00:00 2001 From: Yashwant Date: Tue, 10 Dec 2024 21:00:36 +0530 Subject: [PATCH] update apache-httpclient to not use getContent --- .../apachehttpclient/v4_0/ApacheHttpClientUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java b/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java index 8e49bc0b..3de9a001 100644 --- a/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java +++ b/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java @@ -19,6 +19,7 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.Span; import io.opentelemetry.javaagent.instrumentation.hypertrace.apachehttpclient.v4_0.ApacheHttpClientObjectRegistry.SpanAndAttributeKey; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -113,7 +114,9 @@ public static void traceEntity( && contentEncoding.getValue().toLowerCase().contains("gzip"); if (entity.isRepeatable()) { try { - InputStream contentStream = entity.getContent(); + BoundedByteArrayOutputStream byteArrayOutputStream = BoundedBuffersFactory.createStream(charset); + entity.writeTo(byteArrayOutputStream); + InputStream contentStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); if (isGzipEncoded) { try { contentStream = new GZIPInputStream(contentStream);