Skip to content

Commit 25554d0

Browse files
committed
Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit 43e047c.
1 parent 4f86282 commit 25554d0

File tree

17 files changed

+32
-322
lines changed

17 files changed

+32
-322
lines changed

spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -137,24 +137,11 @@ public WebTestClient.Builder filters(Consumer<List<ExchangeFilterFunction>> filt
137137
}
138138

139139
@Override
140-
@Deprecated
141140
public WebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies) {
142141
this.webClientBuilder.exchangeStrategies(strategies);
143142
return this;
144143
}
145144

146-
@Override
147-
public WebTestClient.Builder exchangeStrategies(ExchangeStrategies.Builder strategies) {
148-
this.webClientBuilder.exchangeStrategies(strategies);
149-
return this;
150-
}
151-
152-
@Override
153-
public WebTestClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer) {
154-
this.webClientBuilder.exchangeStrategies(configurer);
155-
return this;
156-
}
157-
158145
@Override
159146
public WebTestClient.Builder responseTimeout(Duration timeout) {
160147
this.responseTimeout = timeout;

spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
* and Spring Kotlin extensions to perform integration tests on an embedded WebFlux server.
7878
*
7979
* @author Rossen Stoyanchev
80-
* @author Brian Clozel
8180
* @since 5.0
8281
* @see StatusAssertions
8382
* @see HeaderAssertions
@@ -437,34 +436,11 @@ interface Builder {
437436

438437
/**
439438
* Configure the {@link ExchangeStrategies} to use.
440-
* <p>This is useful for changing the default settings, yet still allowing
441-
* further customizations via {@link #exchangeStrategies(Consumer)}.
442-
* By default {@link ExchangeStrategies#withDefaults()} is used.
439+
* <p>By default {@link ExchangeStrategies#withDefaults()} is used.
443440
* @param strategies the strategies to use
444-
* @deprecated as of 5.1 in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)}
445441
*/
446-
@Deprecated
447442
Builder exchangeStrategies(ExchangeStrategies strategies);
448443

449-
/**
450-
* Configure the {@link ExchangeStrategies.Builder} to use.
451-
* <p>This is useful for changing the default settings, yet still allowing
452-
* further customizations via {@link #exchangeStrategies(Consumer)}.
453-
* By default {@link ExchangeStrategies#builder()} is used.
454-
* @param strategies the strategies to use
455-
* @since 5.1.12
456-
*/
457-
Builder exchangeStrategies(ExchangeStrategies.Builder strategies);
458-
459-
/**
460-
* Customize the {@link ExchangeStrategies}.
461-
* <p>Allows further customization on {@link ExchangeStrategies},
462-
* mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set},
463-
* or starting from {@link ExchangeStrategies#withDefaults() defaults}.
464-
* @since 5.1.12
465-
*/
466-
Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer);
467-
468444
/**
469445
* Max amount of time to wait for responses.
470446
* <p>By default 5 seconds.
@@ -901,7 +877,7 @@ interface BodyContentSpec {
901877
* @since 5.1
902878
* @see #xpath(String, Map, Object...)
903879
*/
904-
default XpathAssertions xpath(String expression, Object... args) {
880+
default XpathAssertions xpath(String expression, Object... args){
905881
return xpath(expression, null, args);
906882
}
907883

@@ -915,7 +891,7 @@ default XpathAssertions xpath(String expression, Object... args) {
915891
* @param args arguments to parameterize the expression
916892
* @since 5.1
917893
*/
918-
XpathAssertions xpath(String expression, @Nullable Map<String, String> namespaces, Object... args);
894+
XpathAssertions xpath(String expression, @Nullable Map<String, String> namespaces, Object... args);
919895

920896
/**
921897
* Assert the response body content with the given {@link Consumer}.

spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,11 +63,6 @@ public interface ClientCodecConfigurer extends CodecConfigurer {
6363
@Override
6464
ClientDefaultCodecs defaultCodecs();
6565

66-
/**
67-
* Clone this {@link ClientCodecConfigurer}.
68-
*/
69-
@Override
70-
ClientCodecConfigurer clone();
7166

7267
/**
7368
* Static factory method for a {@code ClientCodecConfigurer}.

spring-web/src/main/java/org/springframework/http/codec/CodecConfigurer.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ public interface CodecConfigurer {
8787
*/
8888
List<HttpMessageWriter<?>> getWriters();
8989

90-
/**
91-
* Clone this {@link CodecConfigurer}.
92-
* @since 5.1.12
93-
*/
94-
CodecConfigurer clone();
95-
9690

9791
/**
9892
* Customize or replace the HTTP message readers and writers registered by

spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434
* client and server specific variants.
3535
*
3636
* @author Rossen Stoyanchev
37-
* @author Brian Clozel
3837
* @since 5.0
3938
*/
4039
class BaseCodecConfigurer implements CodecConfigurer {
4140

42-
protected final BaseDefaultCodecs defaultCodecs;
41+
private final BaseDefaultCodecs defaultCodecs;
4342

44-
protected final DefaultCustomCodecs customCodecs;
43+
private final DefaultCustomCodecs customCodecs = new DefaultCustomCodecs();
4544

4645

4746
/**
@@ -51,16 +50,6 @@ class BaseCodecConfigurer implements CodecConfigurer {
5150
BaseCodecConfigurer(BaseDefaultCodecs defaultCodecs) {
5251
Assert.notNull(defaultCodecs, "'defaultCodecs' is required");
5352
this.defaultCodecs = defaultCodecs;
54-
this.customCodecs = new DefaultCustomCodecs();
55-
}
56-
57-
/**
58-
* Constructor with another {@link BaseCodecConfigurer} to copy
59-
* the configuration from.
60-
*/
61-
BaseCodecConfigurer(BaseCodecConfigurer other) {
62-
this.defaultCodecs = other.cloneDefaultCodecs();
63-
this.customCodecs = new DefaultCustomCodecs(other.customCodecs);
6453
}
6554

6655

@@ -98,17 +87,6 @@ public List<HttpMessageWriter<?>> getWriters() {
9887
return getWritersInternal(false);
9988
}
10089

101-
102-
@Override
103-
public CodecConfigurer clone() {
104-
return new BaseCodecConfigurer(this);
105-
}
106-
107-
protected BaseDefaultCodecs cloneDefaultCodecs() {
108-
return new BaseDefaultCodecs(this.defaultCodecs);
109-
}
110-
111-
11290
/**
11391
* Internal method that returns the configured writers.
11492
* @param forMultipart whether to returns writers for general use ("false"),
@@ -132,7 +110,7 @@ protected List<HttpMessageWriter<?>> getWritersInternal(boolean forMultipart) {
132110
/**
133111
* Default implementation of {@code CustomCodecs}.
134112
*/
135-
protected static final class DefaultCustomCodecs implements CustomCodecs {
113+
private static final class DefaultCustomCodecs implements CustomCodecs {
136114

137115
private final List<HttpMessageReader<?>> typedReaders = new ArrayList<>();
138116

@@ -143,16 +121,6 @@ protected static final class DefaultCustomCodecs implements CustomCodecs {
143121
private final List<HttpMessageWriter<?>> objectWriters = new ArrayList<>();
144122

145123

146-
DefaultCustomCodecs() {
147-
}
148-
149-
DefaultCustomCodecs(DefaultCustomCodecs other) {
150-
other.typedReaders.addAll(this.typedReaders);
151-
other.typedWriters.addAll(this.typedWriters);
152-
other.objectReaders.addAll(this.objectReaders);
153-
other.objectWriters.addAll(this.objectWriters);
154-
}
155-
156124
@Override
157125
public void decoder(Decoder<?> decoder) {
158126
reader(new DecoderHttpMessageReader<>(decoder));
@@ -175,6 +143,7 @@ public void writer(HttpMessageWriter<?> writer) {
175143
(canWriteObject ? this.objectWriters : this.typedWriters).add(writer);
176144
}
177145

146+
178147
// Package private accessors...
179148

180149
List<HttpMessageReader<?>> getTypedReaders() {

spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,6 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs {
105105
private boolean registerDefaults = true;
106106

107107

108-
BaseDefaultCodecs() {
109-
}
110-
111-
protected BaseDefaultCodecs(BaseDefaultCodecs other) {
112-
this.jackson2JsonDecoder = other.jackson2JsonDecoder;
113-
this.jackson2JsonEncoder = other.jackson2JsonEncoder;
114-
this.protobufDecoder = other.protobufDecoder;
115-
this.protobufEncoder = other.protobufEncoder;
116-
this.jaxb2Decoder = other.jaxb2Decoder;
117-
this.jaxb2Encoder = other.jaxb2Encoder;
118-
this.maxInMemorySize = other.maxInMemorySize;
119-
this.enableLoggingRequestDetails = other.enableLoggingRequestDetails;
120-
this.registerDefaults = other.registerDefaults;
121-
}
122-
123108
@Override
124109
public void jackson2JsonDecoder(Decoder<?> decoder) {
125110
this.jackson2JsonDecoder = decoder;

spring-web/src/main/java/org/springframework/http/codec/support/ClientDefaultCodecsImpl.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,17 +49,6 @@ class ClientDefaultCodecsImpl extends BaseDefaultCodecs implements ClientCodecCo
4949
private Supplier<List<HttpMessageWriter<?>>> partWritersSupplier;
5050

5151

52-
ClientDefaultCodecsImpl() {
53-
}
54-
55-
ClientDefaultCodecsImpl(ClientDefaultCodecsImpl other) {
56-
super(other);
57-
this.multipartCodecs = new DefaultMultipartCodecs(other.multipartCodecs);
58-
this.sseDecoder = other.sseDecoder;
59-
this.partWritersSupplier = other.partWritersSupplier;
60-
}
61-
62-
6352
/**
6453
* Set a supplier for part writers to use when
6554
* {@link #multipartCodecs()} are not explicitly configured.
@@ -84,14 +73,6 @@ public void serverSentEventDecoder(Decoder<?> decoder) {
8473
this.sseDecoder = decoder;
8574
}
8675

87-
@Override
88-
public ClientDefaultCodecsImpl clone() {
89-
ClientDefaultCodecsImpl codecs = new ClientDefaultCodecsImpl();
90-
codecs.multipartCodecs = this.multipartCodecs;
91-
codecs.sseDecoder = this.sseDecoder;
92-
codecs.partWritersSupplier = this.partWritersSupplier;
93-
return codecs;
94-
}
9576

9677
@Override
9778
protected void extendObjectReaders(List<HttpMessageReader<?>> objectReaders) {
@@ -135,17 +116,6 @@ private static class DefaultMultipartCodecs implements ClientCodecConfigurer.Mul
135116

136117
private final List<HttpMessageWriter<?>> writers = new ArrayList<>();
137118

138-
139-
DefaultMultipartCodecs() {
140-
}
141-
142-
DefaultMultipartCodecs(@Nullable DefaultMultipartCodecs other) {
143-
if (other != null) {
144-
this.writers.addAll(other.writers);
145-
}
146-
}
147-
148-
149119
@Override
150120
public ClientCodecConfigurer.MultipartCodecs encoder(Encoder<?> encoder) {
151121
writer(new EncoderHttpMessageWriter<>(encoder));

spring-web/src/main/java/org/springframework/http/codec/support/DefaultClientCodecConfigurer.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,30 +26,14 @@
2626
*/
2727
public class DefaultClientCodecConfigurer extends BaseCodecConfigurer implements ClientCodecConfigurer {
2828

29-
3029
public DefaultClientCodecConfigurer() {
3130
super(new ClientDefaultCodecsImpl());
3231
((ClientDefaultCodecsImpl) defaultCodecs()).setPartWritersSupplier(() -> getWritersInternal(true));
3332
}
3433

35-
private DefaultClientCodecConfigurer(DefaultClientCodecConfigurer other) {
36-
super(other);
37-
}
38-
39-
4034
@Override
4135
public ClientDefaultCodecs defaultCodecs() {
4236
return (ClientDefaultCodecs) super.defaultCodecs();
4337
}
4438

45-
@Override
46-
public DefaultClientCodecConfigurer clone() {
47-
return new DefaultClientCodecConfigurer(this);
48-
}
49-
50-
@Override
51-
protected BaseDefaultCodecs cloneDefaultCodecs() {
52-
return new ClientDefaultCodecsImpl((ClientDefaultCodecsImpl) defaultCodecs());
53-
}
54-
5539
}

spring-web/src/main/java/org/springframework/http/codec/support/DefaultServerCodecConfigurer.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,28 +26,13 @@
2626
*/
2727
public class DefaultServerCodecConfigurer extends BaseCodecConfigurer implements ServerCodecConfigurer {
2828

29-
3029
public DefaultServerCodecConfigurer() {
3130
super(new ServerDefaultCodecsImpl());
3231
}
3332

34-
private DefaultServerCodecConfigurer(BaseCodecConfigurer other) {
35-
super(other);
36-
}
37-
38-
3933
@Override
4034
public ServerDefaultCodecs defaultCodecs() {
4135
return (ServerDefaultCodecs) super.defaultCodecs();
4236
}
4337

44-
@Override
45-
public DefaultServerCodecConfigurer clone() {
46-
return new DefaultServerCodecConfigurer(this);
47-
}
48-
49-
@Override
50-
protected BaseDefaultCodecs cloneDefaultCodecs() {
51-
return new ServerDefaultCodecsImpl((ServerDefaultCodecsImpl) defaultCodecs());
52-
}
5338
}

spring-web/src/main/java/org/springframework/http/codec/support/ServerDefaultCodecsImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ class ServerDefaultCodecsImpl extends BaseDefaultCodecs implements ServerCodecCo
4646
private Encoder<?> sseEncoder;
4747

4848

49-
ServerDefaultCodecsImpl() {
50-
}
51-
52-
ServerDefaultCodecsImpl(ServerDefaultCodecsImpl other) {
53-
super(other);
54-
this.multipartReader = other.multipartReader;
55-
this.sseEncoder = other.sseEncoder;
56-
}
57-
58-
5949
@Override
6050
public void multipartReader(HttpMessageReader<?> reader) {
6151
this.multipartReader = reader;

0 commit comments

Comments
 (0)