Merge pull request #83 from SkyeBeFreeman/greenwich-new

fix:fix fetching wrong PEER_SERVICE in SCG filter.
pull/91/head
Haotian Zhang 3 years ago committed by GitHub
commit f29e766ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -55,25 +55,27 @@ public class MetadataFirstScgFilter implements GlobalFilter, Ordered {
Route route = exchange.getAttribute(GATEWAY_ROUTE_ATTR); Route route = exchange.getAttribute(GATEWAY_ROUTE_ATTR);
// get metadata of current thread // get metadata of current thread
MetadataContext metadataContext = exchange MetadataContext metadataContext = exchange.getAttribute(MetadataConstant.HeaderName.METADATA_CONTEXT);
.getAttribute(MetadataConstant.HeaderName.METADATA_CONTEXT);
if (metadataContext == null) { if (metadataContext == null) {
metadataContext = MetadataContextHolder.get(); metadataContext = MetadataContextHolder.get();
} }
// TODO The peer namespace is temporarily the same as the local namespace // TODO The peer namespace is temporarily the same as the local namespace
metadataContext.putSystemMetadata( metadataContext.putSystemMetadata(MetadataConstant.SystemMetadataKey.PEER_NAMESPACE,
MetadataConstant.SystemMetadataKey.PEER_NAMESPACE,
MetadataContext.LOCAL_NAMESPACE); MetadataContext.LOCAL_NAMESPACE);
metadataContext.putSystemMetadata(MetadataConstant.SystemMetadataKey.PEER_SERVICE, if (route != null) {
route.getUri().getAuthority()); metadataContext.putSystemMetadata(MetadataConstant.SystemMetadataKey.PEER_SERVICE,
route.getUri().getAuthority());
}
else {
metadataContext.putSystemMetadata(MetadataConstant.SystemMetadataKey.PEER_SERVICE,
exchange.getRequest().getURI().getAuthority());
}
metadataContext.putSystemMetadata(MetadataConstant.SystemMetadataKey.PEER_PATH, metadataContext.putSystemMetadata(MetadataConstant.SystemMetadataKey.PEER_PATH,
exchange.getRequest().getURI().getPath()); exchange.getRequest().getURI().getPath());
exchange.getAttributes().put(MetadataConstant.HeaderName.METADATA_CONTEXT, exchange.getAttributes().put(MetadataConstant.HeaderName.METADATA_CONTEXT, metadataContext);
metadataContext);
return chain.filter(exchange); return chain.filter(exchange);
} }
} }

Loading…
Cancel
Save