Skip to content

Commit 57b721b

Browse files
committed
Merge remote-tracking branch 'origin/main' into CVE-2024-7254
2 parents 6b2c652 + 974191e commit 57b721b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
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);

instrumentation/servlet/servlet-5.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/servlet/v5_0/Servlet50AndFilterInstrumentation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ public static void exit(
187187

188188
if (!request.isAsyncStarted()) {
189189
if (instrumentationConfig.httpHeaders().response()) {
190+
if (throwable == null && !httpResponse.isCommitted()) {
191+
httpResponse.flushBuffer();
192+
}
190193
for (String headerName : httpResponse.getHeaderNames()) {
191194
String headerValue = httpResponse.getHeader(headerName);
192195
currentSpan.setAttribute(
@@ -216,6 +219,7 @@ public static void exit(
216219
urlEncodedMapContextStore);
217220
}
218221
}
222+
} catch (IOException ignored) {
219223
} finally {
220224
Throwable tmp = throwable;
221225
while (tmp != null) { // loop in case our exception is nested (eg. springframework)

0 commit comments

Comments
 (0)