opentracing-contrib / java-web-servlet-filter

OpenTracing Java Web Servlet Filter Instrumentation
Apache License 2.0
24 stars 31 forks source link

创建filter,引用web.xml报错 #33

Closed flycloudOne closed 6 years ago

flycloudOne commented 6 years ago

异常信息如下: java.lang.NullPointerException at brave.opentracing.BraveSpanBuilder.addReference(BraveSpanBuilder.java:72) at brave.opentracing.BraveSpanBuilder.asChildOf(BraveSpanBuilder.java:60) at brave.opentracing.BraveSpanBuilder.asChildOf(BraveSpanBuilder.java:41) at io.opentracing.contrib.web.servlet.filter.TracingFilter.doFilter(TracingFilter.java:154) at com.efounder.opentracing.OpentracingFilter.doFilter(OpentracingFilter.java:28)

filter 代码如下:

`public class OpentracingFilter implements Filter {

private TracingFilter filter = null;

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    Tracer tracer = OpentracingManager.me().getTracer();
    filter = new TracingFilter(tracer);
}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    filter.doFilter(request, response, chain);
}

@Override
public void destroy() {
    filter.destroy();
}

}`

请指教

objectiser commented 6 years ago

This would appear to be an issue in the brave-opentracing implementation, not handling a null parent passed to the asChildOf method: see https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/Tracer.java#L115

I'll close this issue, but if you have any further question please re-open.

flycloudOne commented 6 years ago

i have commit pull request, please review