Skip to content

Commit 9d553e7

Browse files
Merge branch 'master' into alexeyk/spotless-for-build-src
2 parents 11823ad + 8299bb0 commit 9d553e7

File tree

7 files changed

+91
-21
lines changed

7 files changed

+91
-21
lines changed

.gitlab/one-pipeline.locked.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# DO NOT EDIT THIS FILE MANUALLY
22
# This file is auto-generated by automation.
33
include:
4-
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/311d4ed6e0cd674e45520ecc38dfccff5c59bc987122305b2ae39600ce5e8a25/one-pipeline.yml
4+
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/04f6a88e3db67cb88821632d138a2a5c3105ba59760bd3dfc60b54733501ecc3/one-pipeline.yml

dd-java-agent/instrumentation/confluent-schema-registry/confluent-schema-registry-4.1/build.gradle

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ muzzle {
1111
}
1212
}
1313

14+
addTestSuiteForDir('latestDepTest', 'test')
15+
16+
tasks.named("latestDepTest", Test) {
17+
testJvmConstraints {
18+
minJavaVersion = JavaVersion.VERSION_11
19+
}
20+
}
21+
1422
dependencies {
1523
implementation project(':dd-java-agent:instrumentation:kafka:kafka-common')
1624
compileOnly group: 'io.confluent', name: 'kafka-schema-registry-client', version: '4.1.0'
17-
compileOnly group: 'io.confluent', name: 'kafka-avro-serializer', version: '4.1.0'
18-
compileOnly group: 'io.confluent', name: 'kafka-protobuf-serializer', version: '4.1.0'
19-
compileOnly group: 'org.apache.kafka', name: 'kafka-clients', version: '3.0.0'
2025

21-
testImplementation project(':dd-java-agent:instrumentation:kafka:kafka-common')
22-
testImplementation group: 'io.confluent', name: 'kafka-schema-registry-client', version: '7.5.2'
23-
testImplementation group: 'io.confluent', name: 'kafka-avro-serializer', version: '7.5.2'
24-
testImplementation group: 'io.confluent', name: 'kafka-protobuf-serializer', version: '7.5.1'
25-
testImplementation group: 'org.apache.kafka', name: 'kafka-clients', version: '3.5.0'
26-
testImplementation group: 'org.apache.avro', name: 'avro', version: '1.11.0'
26+
testImplementation group: 'io.confluent', name: 'kafka-avro-serializer', version: '7.4.0'
27+
28+
latestDepTestImplementation group: 'io.confluent', name: 'kafka-avro-serializer', version: '+'
2729
}
2830

dd-java-agent/instrumentation/servlet/jakarta-servlet-5.0/src/main/java/datadog/trace/instrumentation/servlet5/RumHttpServletResponseWrapper.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public void setHeader(String name, String value) {
107107
if (isContentLengthHeader(name)) {
108108
return;
109109
}
110+
checkForContentType(name, value);
110111
checkForContentSecurityPolicy(name);
111112
}
112113
super.setHeader(name, value);
@@ -118,6 +119,7 @@ public void addHeader(String name, String value) {
118119
if (isContentLengthHeader(name)) {
119120
return;
120121
}
122+
checkForContentType(name, value);
121123
checkForContentSecurityPolicy(name);
122124
}
123125
super.addHeader(name, value);
@@ -133,6 +135,12 @@ private void checkForContentSecurityPolicy(String name) {
133135
}
134136
}
135137

138+
private void checkForContentType(String name, String value) {
139+
if ("content-type".equalsIgnoreCase(name)) {
140+
handleContentType(value);
141+
}
142+
}
143+
136144
@Override
137145
public void setContentLength(int len) {
138146
// don't set it since we don't know if we will inject
@@ -182,15 +190,20 @@ public void onInjected() {
182190
}
183191
}
184192

185-
@Override
186-
public void setContentType(String type) {
193+
private void handleContentType(String type) {
194+
final boolean wasInjecting = shouldInject;
187195
if (shouldInject) {
188196
shouldInject = type != null && type.contains("text/html");
189197
}
190-
if (!shouldInject) {
198+
if (wasInjecting && !shouldInject) {
191199
commit();
192200
stopFiltering();
193201
}
202+
}
203+
204+
@Override
205+
public void setContentType(String type) {
206+
handleContentType(type);
194207
super.setContentType(type);
195208
}
196209

dd-java-agent/instrumentation/servlet/jakarta-servlet-5.0/src/test/groovy/RumHttpServletResponseWrapperTest.groovy

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,36 @@ class RumHttpServletResponseWrapperTest extends InstrumentationSpecification {
5454
1 * mockResponse.getOutputStream()
5555
}
5656

57-
void 'getWriter with non-HTML content reports skipped'() {
58-
setup:
57+
void 'getWriter with non-HTML content reports skipped (setContentType)'() {
58+
when:
5959
wrapper.setContentType("text/plain")
60+
wrapper.getWriter()
61+
62+
then:
63+
1 * mockTelemetryCollector.onInjectionSkipped(SERVLET_VERSION)
64+
1 * mockResponse.setContentType("text/plain")
65+
1 * mockResponse.getWriter()
66+
}
67+
68+
void 'getWriter with non-HTML content reports skipped (setHeader)'() {
69+
when:
70+
wrapper.setHeader("Content-Type", "text/plain")
71+
wrapper.getWriter()
72+
73+
then:
74+
1 * mockTelemetryCollector.onInjectionSkipped(SERVLET_VERSION)
75+
1 * mockResponse.setHeader("Content-Type", "text/plain")
76+
1 * mockResponse.getWriter()
77+
}
6078
79+
void 'getWriter with non-HTML content reports skipped (addHeader)'() {
6180
when:
81+
wrapper.addHeader("Content-Type", "text/plain")
6282
wrapper.getWriter()
6383
6484
then:
6585
1 * mockTelemetryCollector.onInjectionSkipped(SERVLET_VERSION)
86+
1 * mockResponse.addHeader("Content-Type", "text/plain")
6687
1 * mockResponse.getWriter()
6788
}
6889

dd-java-agent/instrumentation/servlet/javax-servlet/javax-servlet-3.0/src/main/java/datadog/trace/instrumentation/servlet3/RumHttpServletResponseWrapper.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public void setHeader(String name, String value) {
126126
if (isContentLengthHeader(name)) {
127127
return;
128128
}
129+
checkForContentType(name, value);
129130
checkForContentSecurityPolicy(name);
130131
}
131132
super.setHeader(name, value);
@@ -137,6 +138,7 @@ public void addHeader(String name, String value) {
137138
if (isContentLengthHeader(name)) {
138139
return;
139140
}
141+
checkForContentType(name, value);
140142
checkForContentSecurityPolicy(name);
141143
}
142144
super.addHeader(name, value);
@@ -205,15 +207,26 @@ public void onInjected() {
205207
}
206208
}
207209

208-
@Override
209-
public void setContentType(String type) {
210+
private void handleContentType(String type) {
211+
final boolean wasInjecting = shouldInject;
210212
if (shouldInject) {
211213
shouldInject = type != null && type.contains("text/html");
212214
}
213-
if (!shouldInject) {
215+
if (wasInjecting && !shouldInject) {
214216
commit();
215217
stopFiltering();
216218
}
219+
}
220+
221+
private void checkForContentType(String name, String value) {
222+
if ("content-type".equalsIgnoreCase(name)) {
223+
handleContentType(value);
224+
}
225+
}
226+
227+
@Override
228+
public void setContentType(String type) {
229+
handleContentType(type);
217230
super.setContentType(type);
218231
}
219232

dd-java-agent/instrumentation/servlet/javax-servlet/javax-servlet-3.0/src/test/groovy/RumHttpServletResponseWrapperTest.groovy

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,36 @@ class RumHttpServletResponseWrapperTest extends InstrumentationSpecification {
5454
1 * mockResponse.getOutputStream()
5555
}
5656

57-
void 'getWriter with non-HTML content reports skipped'() {
58-
setup:
57+
void 'getWriter with non-HTML content reports skipped (setContentType)'() {
58+
when:
5959
wrapper.setContentType("text/plain")
60+
wrapper.getWriter()
61+
62+
then:
63+
1 * mockTelemetryCollector.onInjectionSkipped(SERVLET_VERSION)
64+
1 * mockResponse.setContentType("text/plain")
65+
1 * mockResponse.getWriter()
66+
}
67+
68+
void 'getWriter with non-HTML content reports skipped (setHeader)'() {
69+
when:
70+
wrapper.setHeader("Content-Type", "text/plain")
71+
wrapper.getWriter()
72+
73+
then:
74+
1 * mockTelemetryCollector.onInjectionSkipped(SERVLET_VERSION)
75+
1 * mockResponse.setHeader("Content-Type", "text/plain")
76+
1 * mockResponse.getWriter()
77+
}
6078
79+
void 'getWriter with non-HTML content reports skipped (addHeader)'() {
6180
when:
81+
wrapper.addHeader("Content-Type", "text/plain")
6282
wrapper.getWriter()
6383
6484
then:
6585
1 * mockTelemetryCollector.onInjectionSkipped(SERVLET_VERSION)
86+
1 * mockResponse.addHeader("Content-Type", "text/plain")
6687
1 * mockResponse.getWriter()
6788
}
6889

internal-api/src/main/java/datadog/trace/api/TagMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public final String tag() {
290290
}
291291

292292
public final boolean matches(String tag) {
293-
return this.tag.equals(tag);
293+
return (this.tag == tag) || this.tag.equals(tag);
294294
}
295295

296296
public abstract boolean isRemoval();

0 commit comments

Comments
 (0)