From c6f0d2d33625ec5c81cdab565daa416b05134a4d Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 25 Aug 2019 21:22:28 -0700 Subject: [PATCH] Fix NPE --- .../agent/internal/NopThreadContext.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/agent/src/main/java/com/microsoft/applicationinsights/agent/internal/NopThreadContext.java b/agent/src/main/java/com/microsoft/applicationinsights/agent/internal/NopThreadContext.java index 97b415866ac..981b285d0e8 100644 --- a/agent/src/main/java/com/microsoft/applicationinsights/agent/internal/NopThreadContext.java +++ b/agent/src/main/java/com/microsoft/applicationinsights/agent/internal/NopThreadContext.java @@ -106,8 +106,7 @@ public Timer startTimer(TimerName timerName) { @Override public AuxThreadContext createAuxThreadContext() { - // TODO Auto-generated method stub - return null; + return NopAuxThreadContext.INSTANCE; } @Override @@ -186,4 +185,19 @@ public int getCurrentSuppressionKeyId() { public void setCurrentSuppressionKeyId(int suppressionKeyId) { this.currentSuppressionKeyId = suppressionKeyId; } + + private static class NopAuxThreadContext implements AuxThreadContext { + + private static final AuxThreadContext INSTANCE = new NopAuxThreadContext(); + + @Override + public Span start() { + return NopTransactionService.LOCAL_SPAN; + } + + @Override + public Span startAndMarkAsyncTransactionComplete() { + return NopTransactionService.LOCAL_SPAN; + } + } }