Skip to content

Commit d73b5da

Browse files
committed
fix(appsec): move BlockingException inside brf guard in all remaining paths
The content path in Netty and both the filenames and content paths in Tomcat were setting the BlockingException outside the if (brf != null) block, meaning the exception would be thrown even when no blocking response had actually been committed. Align all three with the canonical pattern: tryCommitBlockingResponse + effectivelyBlocked + exception assignment all inside if (brf != null). The Netty body-processed path intentionally still omits effectivelyBlocked() because tryCommitBlockingResponse() closes the Netty span synchronously in the test environment, making a subsequent effectivelyBlocked() call fail.
1 parent a1a267d commit d73b5da

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

dd-java-agent/instrumentation/netty/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/HttpPostRequestDecoderInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ static void after(
192192
if (brf != null) {
193193
brf.tryCommitBlockingResponse(requestContext.getTraceSegment(), rba);
194194
requestContext.getTraceSegment().effectivelyBlocked();
195+
thr = new BlockingException("Blocked request (multipart file upload content)");
195196
}
196-
thr = new BlockingException("Blocked request (multipart file upload content)");
197197
}
198198
}
199199

dd-java-agent/instrumentation/tomcat/tomcat-appsec/tomcat-appsec-7.0/src/main/java/datadog/trace/instrumentation/tomcat7/ParsePartsInstrumentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ static void after(
143143
if (brf != null) {
144144
brf.tryCommitBlockingResponse(reqCtx.getTraceSegment(), rba);
145145
reqCtx.getTraceSegment().effectivelyBlocked();
146+
t = new BlockingException("Blocked request (multipart file upload)");
146147
}
147-
t = new BlockingException("Blocked request (multipart file upload)");
148148
}
149149
}
150150
}
@@ -164,8 +164,8 @@ static void after(
164164
if (brf != null) {
165165
brf.tryCommitBlockingResponse(reqCtx.getTraceSegment(), rba);
166166
reqCtx.getTraceSegment().effectivelyBlocked();
167+
t = new BlockingException("Blocked request (multipart file upload content)");
167168
}
168-
t = new BlockingException("Blocked request (multipart file upload content)");
169169
}
170170
}
171171
}

0 commit comments

Comments
 (0)