spring-cloud-gateway traceid does not transmit #3411 (#3446)

* spring-cloud-gateway traceid does not transmit #3411

skywalking-version:6.5.0

spring-gateway-version:2.1.2

Error Description:

 Customize the filter, traceid does not transmit.

 "ServerWebExchangeDecorator" is a transport chain,His structure should be like this:

	 serverWebExchangeDecorator
	    -----(ServerWebExchangeDecorator)delegate
		    ------(ServerWebExchangeDecorator)delegate
			  ------.....
			   -----(DefaultServerWebExchange)delegate
  In the current source code, there is no deep search, but only the next level. When there are multiple custom filters, you get an error.

Repair method:

  Look for "delegate" of "ServerWebExchangeDecorator" recursively until "DefaultServerWebExchange"

* spring-boot-webflux traceid does not transmit #3411

spring-boot-starter-webflux-version:2.1.6

Error Description:

Customize the filter, traceid does not transmit.

"ServerWebExchangeDecorator" is a transport chain,His structure should be like this:

 serverWebExchangeDecorator
    -----(ServerWebExchangeDecorator)delegate
	    ------(ServerWebExchangeDecorator)delegate
		  ------.....
		   -----(DefaultServerWebExchange)delegate

In the current source code, there is no deep search, but only the next level. When there are multiple custom filters, you get an error.

Repair method:

Look for "delegate" of "ServerWebExchangeDecorator" recursively until "DefaultServerWebExchange"

* checkStyle
This commit is contained in:
hi-sb 2019-09-11 13:44:36 +08:00 committed by 吴晟 Wu Sheng
parent e1ce6edfab
commit 96b2baaddb
2 changed files with 31 additions and 8 deletions

View File

@ -82,13 +82,25 @@ public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethods
public static EnhancedInstance getInstance(Object o) {
EnhancedInstance instance = null;
if (o instanceof ServerWebExchangeDecorator) {
ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
if (delegate instanceof DefaultServerWebExchange) {
instance = (EnhancedInstance) delegate;
}
instance = getEnhancedInstance((ServerWebExchangeDecorator) o);
} else if (o instanceof DefaultServerWebExchange) {
instance = (EnhancedInstance) o;
}
return instance;
}
private static EnhancedInstance getEnhancedInstance(ServerWebExchangeDecorator serverWebExchangeDecorator) {
Object o = serverWebExchangeDecorator.getDelegate();
if (o instanceof ServerWebExchangeDecorator) {
return getEnhancedInstance((ServerWebExchangeDecorator) o);
} else if (o instanceof DefaultServerWebExchange) {
return (EnhancedInstance) o;
} else if (o == null) {
throw new NullPointerException("The expected class DefaultServerWebExchange is null");
} else {
throw new RuntimeException("Unknown parameter types:" + o.getClass());
}
}
}

View File

@ -79,13 +79,24 @@ public class NettyRoutingFilterInterceptor implements InstanceMethodsAroundInter
public static EnhancedInstance getInstance(Object o) {
EnhancedInstance instance = null;
if (o instanceof ServerWebExchangeDecorator) {
ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
if (delegate instanceof DefaultServerWebExchange) {
instance = (EnhancedInstance) delegate;
}
instance = getEnhancedInstance((ServerWebExchangeDecorator) o);
} else if (o instanceof DefaultServerWebExchange) {
instance = (EnhancedInstance) o;
}
return instance;
}
private static EnhancedInstance getEnhancedInstance(ServerWebExchangeDecorator serverWebExchangeDecorator) {
Object o = serverWebExchangeDecorator.getDelegate();
if (o instanceof ServerWebExchangeDecorator) {
return getEnhancedInstance((ServerWebExchangeDecorator) o);
} else if (o instanceof DefaultServerWebExchange) {
return (EnhancedInstance) o;
} else if (o == null) {
throw new NullPointerException("The expected class DefaultServerWebExchange is null");
} else {
throw new RuntimeException("Unknown parameter types:" + o.getClass());
}
}
}