@@ -2432,15 +2432,18 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
24322432
24332433 final BiFunction<RequestContext , IGSpanInfo , Flow<Void > > requestEndedCb =
24342434 ({ RequestContext rqCtxt , IGSpanInfo info ->
2435- Context context = rqCtxt. getData(RequestContextSlot . APPSEC )
2436- if (context. responseBodyTag) {
2437- rqCtxt. traceSegment. setTagTop(' response.body' , context. responseBody)
2438- }
2439- if (context. extraSpanName) {
2440- runUnderTrace(context. extraSpanName, false ) {
2441- def span = activeSpan()
2442- context. tags. each { key , val ->
2443- span. setTag(key, val)
2435+ Object contextObj = rqCtxt. getData(RequestContextSlot . APPSEC )
2436+ if (contextObj instanceof Context ) {
2437+ Context context = (Context ) contextObj
2438+ if (context. responseBodyTag) {
2439+ rqCtxt. traceSegment. setTagTop(' response.body' , context. responseBody)
2440+ }
2441+ if (context. extraSpanName) {
2442+ runUnderTrace(context. extraSpanName, false ) {
2443+ def span = activeSpan()
2444+ context. tags. each { key , val ->
2445+ span. setTag(key, val)
2446+ }
24442447 }
24452448 }
24462449 }
@@ -2649,8 +2652,9 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
26492652
26502653 final BiFunction<RequestContext , String , Flow<Void > > requestSessionCb =
26512654 { RequestContext rqCtxt , String sessionId ->
2652- Context context = rqCtxt. getData(RequestContextSlot . APPSEC )
2653- if (sessionId != null ) {
2655+ Object contextObj = rqCtxt. getData(RequestContextSlot . APPSEC )
2656+ if (contextObj instanceof Context && sessionId != null ) {
2657+ Context context = (Context ) contextObj
26542658 context. extraSpanName = ' appsec-span'
26552659 context. tags. put(IG_SESSION_ID_TAG , sessionId)
26562660 }
0 commit comments