Skip to content

Commit

Permalink
Update TracingFilter.java
Browse files Browse the repository at this point in the history
fix NullPointerException  with dubbo getMetadata request
  • Loading branch information
yingziisme committed Sep 16, 2022
1 parent d3dd81b commit bc1607d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
Expand All @@ -20,7 +22,7 @@ final class TracingFilter implements Filter {

private final Instrumenter<DubboRequest, Result> serverInstrumenter;
private final Instrumenter<DubboRequest, Result> clientInstrumenter;

TracingFilter(
Instrumenter<DubboRequest, Result> serverInstrumenter,
Instrumenter<DubboRequest, Result> clientInstrumenter) {
Expand All @@ -35,6 +37,10 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) {
}

RpcContext rpcContext = RpcContext.getContext();
if (rpcContext.getUrl() == null) {
return invoker.invoke(invocation);
}

boolean isServer = rpcContext.isProviderSide();
Instrumenter<DubboRequest, Result> instrumenter =
isServer ? serverInstrumenter : clientInstrumenter;
Expand Down

0 comments on commit bc1607d

Please sign in to comment.