Fixed wrong https

This commit is contained in:
Marcin Grzejszczak
2019-03-29 12:15:25 +01:00
3 changed files with 98 additions and 97 deletions

View File

@@ -161,7 +161,8 @@ class HttpClientBeanPostProcessor implements BeanPostProcessor {
AtomicReference reference = req.currentContext()
.getOrDefault(AtomicReference.class, new AtomicReference());
Span span = handler().handleSend(injector(), req.requestHeaders(), req,
reference.get() == null ? handler().nextSpan(req) : (Span) reference.get());
reference.get() == null ? handler().nextSpan(req)
: (Span) reference.get());
reference.set(span);
}

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -208,21 +208,21 @@ public class WebClientTests {
(ResponseEntityProvider) (tests) -> tests.testFeignInterface.getNoTrace(),
(ResponseEntityProvider) (tests) -> tests.testFeignInterface.getNoTrace(),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class),
.getForEntity("http://fooservice/notrace", String.class),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class),
.getForEntity("http://fooservice/notrace", String.class),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class),
.getForEntity("http://fooservice/notrace", String.class),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class),
.getForEntity("http://fooservice/notrace", String.class),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class),
.getForEntity("http://fooservice/notrace", String.class),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class),
.getForEntity("http://fooservice/notrace", String.class),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class),
.getForEntity("http://fooservice/notrace", String.class),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/notrace", String.class) };
.getForEntity("http://fooservice/notrace", String.class) };
}
@Test
@@ -251,7 +251,7 @@ public class WebClientTests {
return new Object[] {
(ResponseEntityProvider) (tests) -> tests.testFeignInterface.headers(),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/", Map.class) };
.getForEntity("http://fooservice/", Map.class) };
}
@Test
@@ -264,7 +264,7 @@ public class WebClientTests {
try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span)) {
ResponseEntity<String> response = provider.get(this);
// https://github.com/spring-cloud/spring-cloud-sleuth/issues/327
// http://github.com/spring-cloud/spring-cloud-sleuth/issues/327
// we don't want to respond with any tracing data
then(getHeader(response, SAMPLED_NAME)).isNull();
then(getHeader(response, TRACE_ID_NAME)).isNull();
@@ -407,7 +407,7 @@ public class WebClientTests {
return new Object[] {
(ResponseEntityProvider) (tests) -> tests.testFeignInterface.headers(),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/traceid", String.class) };
.getForEntity("http://fooservice/traceid", String.class) };
}
@Test
@@ -432,13 +432,13 @@ public class WebClientTests {
(ResponseEntityProvider) (tests) -> tests.testFeignInterface
.noResponseBody(),
(ResponseEntityProvider) (tests) -> tests.template
.getForEntity("https://fooservice/noresponse", String.class) };
.getForEntity("http://fooservice/noresponse", String.class) };
}
@Test
public void shouldCloseSpanWhenErrorControllerGetsCalled() {
try {
this.template.getForEntity("https://fooservice/nonExistent", String.class);
this.template.getForEntity("http://fooservice/nonExistent", String.class);
fail("An exception should be thrown");
}
catch (HttpClientErrorException e) {
@@ -465,7 +465,7 @@ public class WebClientTests {
@Test
public void shouldNotExecuteErrorControllerWhenUrlIsFound() {
this.template.getForEntity("https://fooservice/notrace", String.class);
this.template.getForEntity("http://fooservice/notrace", String.class);
then(this.tracer.currentSpan()).isNull();
then(this.testErrorController.getSpan()).isNull();

View File

@@ -1,82 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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
~
~ https://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.
-->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
https://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/task https://www.springframework.org/schema/task/spring-task.xsd">
<int:channel id="messagingChannel"/>
<int:channel id="splitterOutChannel">
<int:queue capacity="10"/>
</int:channel>
<int:channel id="messagingProcessedChannel">
<int:queue capacity="10"/>
</int:channel>
<int:channel id="messagingOutputChannel">
<int:queue capacity="10"/>
</int:channel>
<int:service-activator input-channel="splitterOutChannel"
method="invokeProcessor"
output-channel="messagingProcessedChannel"
ref="helloWorldImpl">
<int:poller max-messages-per-poll="1" fixed-rate="1"
task-executor="requestExecutor"/>
</int:service-activator>
<int:aggregator input-channel="messagingProcessedChannel"
output-channel="messagingOutputChannel"
message-store="messageStore"
send-partial-result-on-expiry="true">
<int:poller max-messages-per-poll="1" fixed-rate="1"
task-executor="requestExecutor"/>
</int:aggregator>
<!-- Define a store for our search results and set up a reaper that will
periodically expire those results. -->
<bean id="messageStore"
class="org.springframework.integration.store.SimpleMessageStore"/>
<bean id="messageStoreReaper"
class="org.springframework.integration.store.MessageGroupStoreReaper">
<property name="messageGroupStore" ref="messageStore"/>
<property name="timeout" value="2000"/>
</bean>
<int:gateway id="messagingGateway"
service-interface="org.springframework.cloud.sleuth.instrument.messaging.issues.issue_943.MessagingGateway"
default-request-channel="messagingChannel" default-reply-timeout="10000"
default-reply-channel="splitterOutChannel"/>
<task:executor id="requestExecutor" pool-size="10"/>
<int:splitter ref="helloWorldImpl" method="splitMessage"
input-channel="messagingChannel" output-channel="splitterOutChannel"/>
<bean id="helloWorldImpl"
class="org.springframework.cloud.sleuth.instrument.messaging.issues.issue_943.HelloWorldImpl"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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
~
~ https://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.
-->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/task https://www.springframework.org/schema/task/spring-task.xsd">
<int:channel id="messagingChannel"/>
<int:channel id="splitterOutChannel">
<int:queue capacity="10"/>
</int:channel>
<int:channel id="messagingProcessedChannel">
<int:queue capacity="10"/>
</int:channel>
<int:channel id="messagingOutputChannel">
<int:queue capacity="10"/>
</int:channel>
<int:service-activator input-channel="splitterOutChannel"
method="invokeProcessor"
output-channel="messagingProcessedChannel"
ref="helloWorldImpl">
<int:poller max-messages-per-poll="1" fixed-rate="1"
task-executor="requestExecutor"/>
</int:service-activator>
<int:aggregator input-channel="messagingProcessedChannel"
output-channel="messagingOutputChannel"
message-store="messageStore"
send-partial-result-on-expiry="true">
<int:poller max-messages-per-poll="1" fixed-rate="1"
task-executor="requestExecutor"/>
</int:aggregator>
<!-- Define a store for our search results and set up a reaper that will
periodically expire those results. -->
<bean id="messageStore"
class="org.springframework.integration.store.SimpleMessageStore"/>
<bean id="messageStoreReaper"
class="org.springframework.integration.store.MessageGroupStoreReaper">
<property name="messageGroupStore" ref="messageStore"/>
<property name="timeout" value="2000"/>
</bean>
<int:gateway id="messagingGateway"
service-interface="org.springframework.cloud.sleuth.instrument.messaging.issues.issue_943.MessagingGateway"
default-request-channel="messagingChannel" default-reply-timeout="10000"
default-reply-channel="splitterOutChannel"/>
<task:executor id="requestExecutor" pool-size="10"/>
<int:splitter ref="helloWorldImpl" method="splitMessage"
input-channel="messagingChannel" output-channel="splitterOutChannel"/>
<bean id="helloWorldImpl"
class="org.springframework.cloud.sleuth.instrument.messaging.issues.issue_943.HelloWorldImpl"/>
</beans>