From af60f593d093a54abe2e4a9b69530c0c9d0d0b52 Mon Sep 17 00:00:00 2001 From: wbzj1110 <13121913082@163.com> Date: Wed, 7 Apr 2021 15:08:02 +0800 Subject: [PATCH] Fix potential null-dereference in CommandHandler #1703 --- .../java/io/lettuce/core/protocol/CommandHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/lettuce/core/protocol/CommandHandler.java b/src/main/java/io/lettuce/core/protocol/CommandHandler.java index 48769760cc..58c3a9cf0a 100644 --- a/src/main/java/io/lettuce/core/protocol/CommandHandler.java +++ b/src/main/java/io/lettuce/core/protocol/CommandHandler.java @@ -421,9 +421,15 @@ private void writeSingleCommand(ChannelHandlerContext ctx, RedisCommand span.tag("redis.args", command.getArgs().toCommandString()); } - span.remoteEndpoint(tracedEndpoint); + if (tracedEndpoint != null) { + span.remoteEndpoint(tracedEndpoint); + } else { + span.remoteEndpoint(clientResources.tracing().createEndpoint(ctx.channel().remoteAddress())); + } span.start(); - provider.setSpan(span); + if (provider != null) { + provider.setSpan(span); + } CompleteableCommand completeableCommand = (CompleteableCommand) command; completeableCommand.onComplete((o, throwable) -> {