Skip to content

Commit 40c54bf

Browse files
authored
feat: update apache-httpclient to not use HttpEntity getContent (#410)
* update apache-httpclient to not use getContent * spotless apply
1 parent aca5f12 commit 40c54bf

File tree

1 file changed

+5
-1
lines changed
  • instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0

1 file changed

+5
-1
lines changed

instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.opentelemetry.api.common.AttributeKey;
2020
import io.opentelemetry.api.trace.Span;
2121
import io.opentelemetry.javaagent.instrumentation.hypertrace.apachehttpclient.v4_0.ApacheHttpClientObjectRegistry.SpanAndAttributeKey;
22+
import java.io.ByteArrayInputStream;
2223
import java.io.IOException;
2324
import java.io.InputStream;
2425
import java.io.InputStreamReader;
@@ -113,7 +114,10 @@ public static void traceEntity(
113114
&& contentEncoding.getValue().toLowerCase().contains("gzip");
114115
if (entity.isRepeatable()) {
115116
try {
116-
InputStream contentStream = entity.getContent();
117+
BoundedByteArrayOutputStream byteArrayOutputStream =
118+
BoundedBuffersFactory.createStream(charset);
119+
entity.writeTo(byteArrayOutputStream);
120+
InputStream contentStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
117121
if (isGzipEncoded) {
118122
try {
119123
contentStream = new GZIPInputStream(contentStream);

0 commit comments

Comments
 (0)