diff --git a/spectator-ext-ipc/src/main/java/com/netflix/spectator/ipc/IpcLogEntry.java b/spectator-ext-ipc/src/main/java/com/netflix/spectator/ipc/IpcLogEntry.java index 2f843b6e6..bf7009e4d 100644 --- a/spectator-ext-ipc/src/main/java/com/netflix/spectator/ipc/IpcLogEntry.java +++ b/spectator-ext-ipc/src/main/java/com/netflix/spectator/ipc/IpcLogEntry.java @@ -156,7 +156,7 @@ public IpcLogEntry withLatency(long latency, TimeUnit unit) { * the request completes it is recommended to call {@link #markEnd()}. */ public IpcLogEntry markStart() { - if (registry != null && !disableMetrics && logger.inflightEnabled()) { + if (registry != null && !disableMetrics && logger != null && logger.inflightEnabled()) { inflightId = getInflightId(); int n = logger.inflightRequests(inflightId).incrementAndGet(); registry.distributionSummary(inflightId).record(n); diff --git a/spectator-ext-ipc/src/test/java/com/netflix/spectator/ipc/IpcLogEntryTest.java b/spectator-ext-ipc/src/test/java/com/netflix/spectator/ipc/IpcLogEntryTest.java index 526e05356..8e7336e4e 100644 --- a/spectator-ext-ipc/src/test/java/com/netflix/spectator/ipc/IpcLogEntryTest.java +++ b/spectator-ext-ipc/src/test/java/com/netflix/spectator/ipc/IpcLogEntryTest.java @@ -20,6 +20,7 @@ import com.netflix.spectator.api.DefaultRegistry; import com.netflix.spectator.api.DistributionSummary; import com.netflix.spectator.api.ManualClock; +import com.netflix.spectator.api.NoopRegistry; import com.netflix.spectator.api.Registry; import com.netflix.spectator.api.Utils; import com.netflix.spectator.api.patterns.CardinalityLimiters; @@ -36,6 +37,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import static org.junit.jupiter.api.Assertions.assertSame; + public class IpcLogEntryTest { private final ManualClock clock = new ManualClock(); @@ -889,4 +892,12 @@ public void endpointUnknownIfNotSet() { Assertions.assertEquals("unknown", Utils.getTagValue(c.id(), "ipc.endpoint")); }); } + + @Test + public void markNullLogger() { + IpcLogEntry entry = new IpcLogEntry(clock) + .withRegistry(new NoopRegistry()); + entry.markStart(); + assertSame(entry, entry.markEnd()); + } }