Fixed broken build with a hack

This commit is contained in:
Marcin Grzejszczak
2018-12-04 23:07:09 +01:00
parent fe1f3e856a
commit 5e4b8e3cef
5 changed files with 50 additions and 9 deletions

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2013-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brave.spring.rabbit;
/**
* Internal class - do not use. Will be removed when fixed in Brave.
*
* @author Marcin Grzejszczak
* @since 2.1.0
*/
public final class SleuthTracingRabbitListenerAdvice {
public static TracingRabbitListenerAdvice advice(SpringRabbitTracing tracing) {
return new TracingRabbitListenerAdvice(tracing);
}
}

View File

@@ -26,6 +26,7 @@ import brave.Tracing;
import brave.jms.JmsTracing;
import brave.kafka.clients.KafkaTracing;
import brave.propagation.CurrentTraceContext;
import brave.spring.rabbit.SleuthTracingRabbitListenerAdvice;
import brave.spring.rabbit.SpringRabbitTracing;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
@@ -38,6 +39,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.aop.framework.ProxyFactoryBean;
@@ -183,8 +185,18 @@ class SleuthRabbitBeanPostProcessor implements BeanPostProcessor {
return rabbitTracing().decorateRabbitTemplate((RabbitTemplate) bean);
}
else if (bean instanceof SimpleRabbitListenerContainerFactory) {
return rabbitTracing().decorateSimpleRabbitListenerContainerFactory(
(SimpleRabbitListenerContainerFactory) bean);
try {
return rabbitTracing().decorateSimpleRabbitListenerContainerFactory(
(SimpleRabbitListenerContainerFactory) bean);
}
catch (NullPointerException ex) {
// TODO: Fix this in Rabbit or Brave
SpringRabbitTracing springRabbitTracing = rabbitTracing();
SimpleRabbitListenerContainerFactory factory = (SimpleRabbitListenerContainerFactory) bean;
factory.setAdviceChain(
SleuthTracingRabbitListenerAdvice.advice(springRabbitTracing));
return factory;
}
}
return bean;
}

View File

@@ -93,7 +93,7 @@ public class TraceWebAutoConfiguration {
}
@Configuration
@ConditionalOnClass({ServerProperties.class, WebEndpointProperties.class})
@ConditionalOnClass({ ServerProperties.class, WebEndpointProperties.class })
protected static class ServerSkipPatternProviderConfig {
/**

View File

@@ -73,16 +73,15 @@ public final class HelloServiceGrpc {
}
/**
* Creates a new blocking-style stub that supports unary and streaming
* output calls on the service
* Creates a new blocking-style stub that supports unary and streaming output calls on
* the service
*/
public static HelloServiceBlockingStub newBlockingStub(io.grpc.Channel channel) {
return new HelloServiceBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on
* the service
* Creates a new ListenableFuture-style stub that supports unary calls on the service
*/
public static HelloServiceFutureStub newFutureStub(io.grpc.Channel channel) {
return new HelloServiceFutureStub(channel);

View File

@@ -384,8 +384,7 @@ public class WebClientTests {
try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span)) {
this.webClient.get().uri("http://localhost:" + this.port + "/noresponse")
.retrieve().bodyToMono(String.class)
.timeout(Duration.ofMillis(0))
.retrieve().bodyToMono(String.class).timeout(Duration.ofMillis(0))
.block();
}
catch (Exception e) {