diff --git a/transport-raknet/src/main/java/org/cloudburstmc/netty/handler/codec/raknet/common/RakSessionCodec.java b/transport-raknet/src/main/java/org/cloudburstmc/netty/handler/codec/raknet/common/RakSessionCodec.java index 03411f9..9ee631b 100644 --- a/transport-raknet/src/main/java/org/cloudburstmc/netty/handler/codec/raknet/common/RakSessionCodec.java +++ b/transport-raknet/src/main/java/org/cloudburstmc/netty/handler/codec/raknet/common/RakSessionCodec.java @@ -240,7 +240,10 @@ private void send(ChannelHandlerContext ctx, RakMessage message) { throw new IllegalArgumentException(); } - getMetrics().encapsulatedOut(1); + RakChannelMetrics metrics = this.getMetrics(); + if (metrics != null) { + metrics.encapsulatedOut(1); + } EncapsulatedPacket[] packets = this.createEncapsulated(message); if (message.priority() == RakPriority.IMMEDIATE) { this.sendImmediate(ctx, packets); @@ -317,14 +320,18 @@ private void handleDatagram(ChannelHandlerContext ctx, RakDatagramPacket packet) // Not reassembled continue; } - getMetrics().encapsulatedIn(1); + if (metrics != null) { + metrics.encapsulatedIn(1); + } try { this.checkForOrdered(ctx, reassembled); } finally { reassembled.release(); } } else { - getMetrics().encapsulatedIn(1); + if (metrics != null) { + metrics.encapsulatedIn(1); + } this.checkForOrdered(ctx, encapsulated); } }