Skip to content

Commit

Permalink
Fix potential null-dereference in CommandHandler #1703
Browse files Browse the repository at this point in the history
  • Loading branch information
wbzj1110 authored and mp911de committed Apr 7, 2021
1 parent d43534e commit b393287
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/main/java/io/lettuce/core/protocol/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,21 +466,26 @@ private void attachTracing(ChannelHandlerContext ctx, RedisCommand<?, ?, ?> comm
TracedCommand<?, ?, ?> traced = CommandWrapper.unwrap(command, TracedCommand.class);
TraceContextProvider provider = (traced == null ? clientResources.tracing().initialTraceContextProvider() : traced);
Tracer tracer = clientResources.tracing().getTracerProvider().getTracer();
TraceContext context = provider.getTraceContext();

Tracer.Span span = tracer.nextSpan(context);
span.name(command.getType().name());
if (provider != null) {

if (tracedEndpoint != null) {
span.remoteEndpoint(tracedEndpoint);
} else {
span.remoteEndpoint(clientResources.tracing().createEndpoint(ctx.channel().remoteAddress()));
}
TraceContext context = provider.getTraceContext();

Tracer.Span span = tracer.nextSpan(context);
span.name(command.getType().name());

if (tracedEndpoint != null) {
span.remoteEndpoint(tracedEndpoint);
} else {
span.remoteEndpoint(clientResources.tracing().createEndpoint(ctx.channel().remoteAddress()));
}

span.start(command);
span.start(command);

if (traced != null) {
traced.setSpan(span);
if (traced != null) {
traced.setSpan(span);

}
}
}

Expand Down

0 comments on commit b393287

Please sign in to comment.