Skip to content

Commit e0a8426

Browse files
committed
wip
1 parent e3254b2 commit e0a8426

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

dd-java-agent/appsec/src/main/java/com/datadog/appsec/api/security/AppSecSpanPostProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public void process(@Nonnull AgentSpan span, @Nonnull BooleanSupplier timeoutChe
5959
} finally {
6060
ctx.setKeepOpenForApiSecurityPostProcessing(false);
6161
try {
62+
// XXX: Close the additive first. This is not strictly needed, but it'll prevent getting it
63+
// detected as a
64+
// missed request-ended event.
65+
ctx.closeAdditive();
6266
ctx.close();
6367
} catch (Exception e) {
6468
log.debug("Error closing AppSecRequestContext", e);

dd-java-agent/appsec/src/test/groovy/com/datadog/appsec/api/security/AppSecSpanPostProcessorTest.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class AppSecSpanPostProcessorTest extends DDSpecification {
3737
1 * producer.publishDataEvent(_, ctx, _, _)
3838
1 * ctx.commitDerivatives(traceSegment)
3939
1 * ctx.setKeepOpenForApiSecurityPostProcessing(false)
40+
1 * ctx.closeAdditive()
4041
1 * ctx.close()
4142
1 * sampler.releaseOne()
4243
0 * _
@@ -61,6 +62,7 @@ class AppSecSpanPostProcessorTest extends DDSpecification {
6162
1 * ctx.isKeepOpenForApiSecurityPostProcessing() >> true
6263
1 * sampler.sampleRequest(_) >> false
6364
1 * ctx.setKeepOpenForApiSecurityPostProcessing(false)
65+
1 * ctx.closeAdditive()
6466
1 * ctx.close()
6567
1 * sampler.releaseOne()
6668
0 * _
@@ -88,6 +90,7 @@ class AppSecSpanPostProcessorTest extends DDSpecification {
8890
1 * reqCtx.getTraceSegment() >> traceSegment
8991
1 * producer.getDataSubscribers(_) >> null
9092
1 * ctx.setKeepOpenForApiSecurityPostProcessing(false)
93+
1 * ctx.closeAdditive()
9194
1 * ctx.close() >> { throw new RuntimeException() }
9295
1 * sampler.releaseOne()
9396
0 * _
@@ -111,6 +114,7 @@ class AppSecSpanPostProcessorTest extends DDSpecification {
111114
1 * reqCtx.getData(_) >> ctx
112115
1 * ctx.isKeepOpenForApiSecurityPostProcessing() >> true
113116
1 * ctx.setKeepOpenForApiSecurityPostProcessing(false)
117+
1 * ctx.closeAdditive()
114118
1 * ctx.close()
115119
1 * sampler.releaseOne()
116120
0 * _
@@ -208,6 +212,7 @@ class AppSecSpanPostProcessorTest extends DDSpecification {
208212
1 * producer.getDataSubscribers(_) >> subInfo
209213
1 * subInfo.isEmpty() >> true
210214
1 * ctx.setKeepOpenForApiSecurityPostProcessing(false)
215+
1 * ctx.closeAdditive()
211216
1 * ctx.close()
212217
1 * sampler.releaseOne()
213218
0 * _
@@ -238,6 +243,7 @@ class AppSecSpanPostProcessorTest extends DDSpecification {
238243
1 * subInfo.isEmpty() >> false
239244
1 * producer.publishDataEvent(_, ctx, _, _) >> { throw new ExpiredSubscriberInfoException() }
240245
1 * ctx.setKeepOpenForApiSecurityPostProcessing(false)
246+
1 * ctx.closeAdditive()
241247
1 * ctx.close()
242248
1 * sampler.releaseOne()
243249
0 * _

0 commit comments

Comments
 (0)