提交 1b1f8d49 编写于 作者: wu-sheng's avatar wu-sheng

Add checker for extract and inject.

上级 b88b3559
...@@ -16,7 +16,9 @@ import org.skywalking.apm.util.StringUtil; ...@@ -16,7 +16,9 @@ import org.skywalking.apm.util.StringUtil;
/** /**
* {@link ContextManager} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to * {@link ContextManager} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
* single-thread, so this context use {@link ThreadLocal} to maintain the context, and make sure, since a {@link * single-thread, so this context use {@link ThreadLocal} to maintain the context, and make sure, since a {@link
* TraceSegment} starts, all ChildOf spans are in the same context. <p> What is 'ChildOf'? {@see * TraceSegment} starts, all ChildOf spans are in the same context.
* <p>
* What is 'ChildOf'? {@see
* https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans} * https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans}
* *
* <p> Also, {@link ContextManager} delegates to all {@link AbstractTracerContext}'s major methods. * <p> Also, {@link ContextManager} delegates to all {@link AbstractTracerContext}'s major methods.
...@@ -107,12 +109,17 @@ public class ContextManager implements TracingContextListener, BootService, Igno ...@@ -107,12 +109,17 @@ public class ContextManager implements TracingContextListener, BootService, Igno
return span; return span;
} }
public static void inject(ContextCarrier contextCarrier) { public static void inject(ContextCarrier carrier) {
get().inject(contextCarrier); if (carrier != null && carrier.isValid()) {
get().inject(carrier);
}
} }
public static void extract(ContextCarrier contextCarrier) { public static void extract(ContextCarrier carrier) {
get().extract(contextCarrier); if (carrier == null) {
throw new IllegalArgumentException("ContextCarrier can't be null.");
}
get().extract(carrier);
} }
public ContextSnapshot capture() { public ContextSnapshot capture() {
......
...@@ -70,8 +70,8 @@ public class TracingContext implements AbstractTracerContext { ...@@ -70,8 +70,8 @@ public class TracingContext implements AbstractTracerContext {
* Inject the context into the given carrier, only when the active span is an exit one. * Inject the context into the given carrier, only when the active span is an exit one.
* *
* @param carrier to carry the context for crossing process. * @param carrier to carry the context for crossing process.
* @see {@link AbstractTracerContext#inject(ContextCarrier)}
* @throws IllegalStateException, if the active span isn't an exit one. * @throws IllegalStateException, if the active span isn't an exit one.
* @see {@link AbstractTracerContext#inject(ContextCarrier)}
*/ */
@Override @Override
public void inject(ContextCarrier carrier) { public void inject(ContextCarrier carrier) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册