Skip to content

Commit 2144a15

Browse files
committed
Remove spring-web dependency from ZipkinHttpClientSender
Closes gh-42160
1 parent 109142e commit 2144a15

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/HttpSender.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
import zipkin2.reporter.Encoding;
2828
import zipkin2.reporter.HttpEndpointSupplier.Factory;
2929

30-
import org.springframework.http.HttpHeaders;
30+
import org.springframework.util.LinkedMultiValueMap;
31+
import org.springframework.util.MultiValueMap;
3132
import org.springframework.util.unit.DataSize;
3233

3334
/**
@@ -60,20 +61,20 @@ protected byte[] newBody(List<byte[]> list) {
6061

6162
@Override
6263
protected void postSpans(URI endpoint, byte[] body) throws IOException {
63-
HttpHeaders headers = getDefaultHeaders();
64+
MultiValueMap<String, String> headers = getDefaultHeaders();
6465
if (needsCompression(body)) {
6566
body = compress(body);
66-
headers.set("Content-Encoding", "gzip");
67+
headers.add("Content-Encoding", "gzip");
6768
}
6869
postSpans(endpoint, headers, body);
6970
}
7071

71-
abstract void postSpans(URI endpoint, HttpHeaders headers, byte[] body) throws IOException;
72+
abstract void postSpans(URI endpoint, MultiValueMap<String, String> headers, byte[] body) throws IOException;
7273

73-
HttpHeaders getDefaultHeaders() {
74-
HttpHeaders headers = new HttpHeaders();
75-
headers.set("b3", "0");
76-
headers.set("Content-Type", this.encoding.mediaType());
74+
MultiValueMap<String, String> getDefaultHeaders() {
75+
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
76+
headers.add("b3", "0");
77+
headers.add("Content-Type", this.encoding.mediaType());
7778
return headers;
7879
}
7980

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinHttpClientSender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import zipkin2.reporter.Encoding;
3030
import zipkin2.reporter.HttpEndpointSupplier.Factory;
3131

32-
import org.springframework.http.HttpHeaders;
32+
import org.springframework.util.MultiValueMap;
3333

3434
/**
3535
* A {@link HttpSender} which uses the JDK {@link HttpClient} for HTTP communication.
@@ -50,7 +50,7 @@ class ZipkinHttpClientSender extends HttpSender {
5050
}
5151

5252
@Override
53-
void postSpans(URI endpoint, HttpHeaders headers, byte[] body) throws IOException {
53+
void postSpans(URI endpoint, MultiValueMap<String, String> headers, byte[] body) throws IOException {
5454
Builder request = HttpRequest.newBuilder()
5555
.POST(BodyPublishers.ofByteArray(body))
5656
.uri(endpoint)

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinRestTemplateSender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import zipkin2.reporter.HttpEndpointSupplier.Factory;
2323

2424
import org.springframework.http.HttpEntity;
25-
import org.springframework.http.HttpHeaders;
2625
import org.springframework.http.HttpMethod;
26+
import org.springframework.util.MultiValueMap;
2727
import org.springframework.web.client.RestTemplate;
2828

2929
/**
@@ -45,7 +45,7 @@ class ZipkinRestTemplateSender extends HttpSender {
4545
}
4646

4747
@Override
48-
void postSpans(URI endpoint, HttpHeaders headers, byte[] body) {
48+
void postSpans(URI endpoint, MultiValueMap<String, String> headers, byte[] body) {
4949
HttpEntity<byte[]> request = new HttpEntity<>(body, headers);
5050
this.restTemplate.exchange(endpoint, HttpMethod.POST, request, Void.class);
5151
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinWebClientSender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import zipkin2.reporter.Encoding;
2323
import zipkin2.reporter.HttpEndpointSupplier.Factory;
2424

25-
import org.springframework.http.HttpHeaders;
25+
import org.springframework.util.MultiValueMap;
2626
import org.springframework.web.reactive.function.client.WebClient;
2727

2828
/**
@@ -47,7 +47,7 @@ class ZipkinWebClientSender extends HttpSender {
4747
}
4848

4949
@Override
50-
void postSpans(URI endpoint, HttpHeaders headers, byte[] body) {
50+
void postSpans(URI endpoint, MultiValueMap<String, String> headers, byte[] body) {
5151
this.webClient.post()
5252
.uri(endpoint)
5353
.headers((h) -> h.addAll(headers))

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinHttpClientSenderTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import zipkin2.reporter.HttpEndpointSupplier;
3636
import zipkin2.reporter.HttpEndpointSuppliers;
3737

38+
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
39+
3840
import static org.assertj.core.api.Assertions.assertThat;
3941
import static org.assertj.core.api.Assertions.assertThatException;
4042
import static org.assertj.core.api.Assertions.assertThatIOException;
@@ -44,6 +46,7 @@
4446
*
4547
* @author Moritz Halbritter
4648
*/
49+
@ClassPathExclusions("spring-web-*.jar")
4750
class ZipkinHttpClientSenderTests extends ZipkinHttpSenderTests {
4851

4952
private MockWebServer mockBackEnd;

0 commit comments

Comments
 (0)