Skip to content

Commit 1560bbd

Browse files
committed
Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit b3020bc.
1 parent 1548a0c commit 1560bbd

File tree

18 files changed

+43
-343
lines changed

18 files changed

+43
-343
lines changed

spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,18 @@ interface Builder {
169169
RSocketRequester.Builder setupMetadata(Object value, @Nullable MimeType mimeType);
170170

171171
/**
172-
* Provide the {@link RSocketStrategies} to use.
173-
* <p>This is useful for changing the default settings, yet still allowing
174-
* further customizations via {@link #rsocketStrategies(Consumer)}.
175-
* If not set, defaults are obtained from {@link RSocketStrategies#builder()}.
176-
* @param strategies the strategies to use
172+
* Provide {@link RSocketStrategies} to use.
173+
* <p>By default this is based on default settings of
174+
* {@link RSocketStrategies.Builder} but may be further customized via
175+
* {@link #rsocketStrategies(Consumer)}.
177176
*/
178177
RSocketRequester.Builder rsocketStrategies(@Nullable RSocketStrategies strategies);
179178

180179
/**
181180
* Customize the {@link RSocketStrategies}.
182-
* <p>Allows further customization on {@link RSocketStrategies},
183-
* mutating them if they were {@link #rsocketStrategies(RSocketStrategies) set},
184-
* or starting from {@link RSocketStrategies#builder()} defaults}.
181+
* <p>By default this starts out as {@link RSocketStrategies#builder()}.
182+
* However if strategies were {@link #rsocketStrategies(RSocketStrategies) set}
183+
* explicitly, then they are {@link RSocketStrategies#mutate() mutated}.
185184
*/
186185
RSocketRequester.Builder rsocketStrategies(Consumer<RSocketStrategies.Builder> configurer);
187186

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

+1-14
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

+3-27
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
* perform integration tests on an embedded WebFlux server.
8585
*
8686
* @author Rossen Stoyanchev
87-
* @author Brian Clozel
8887
* @since 5.0
8988
* @see StatusAssertions
9089
* @see HeaderAssertions
@@ -444,34 +443,11 @@ interface Builder {
444443

445444
/**
446445
* Configure the {@link ExchangeStrategies} to use.
447-
* <p>This is useful for changing the default settings, yet still allowing
448-
* further customizations via {@link #exchangeStrategies(Consumer)}.
449-
* By default {@link ExchangeStrategies#withDefaults()} is used.
446+
* <p>By default {@link ExchangeStrategies#withDefaults()} is used.
450447
* @param strategies the strategies to use
451-
* @deprecated as of 5.1 in favor of {@link #exchangeStrategies(ExchangeStrategies.Builder)}
452448
*/
453-
@Deprecated
454449
Builder exchangeStrategies(ExchangeStrategies strategies);
455450

456-
/**
457-
* Configure the {@link ExchangeStrategies.Builder} to use.
458-
* <p>This is useful for changing the default settings, yet still allowing
459-
* further customizations via {@link #exchangeStrategies(Consumer)}.
460-
* By default {@link ExchangeStrategies#builder()} is used.
461-
* @param strategies the strategies to use
462-
* @since 5.1.12
463-
*/
464-
Builder exchangeStrategies(ExchangeStrategies.Builder strategies);
465-
466-
/**
467-
* Customize the {@link ExchangeStrategies}.
468-
* <p>Allows further customization on {@link ExchangeStrategies},
469-
* mutating them if they were {@link #exchangeStrategies(ExchangeStrategies) set},
470-
* or starting from {@link ExchangeStrategies#withDefaults() defaults}.
471-
* @since 5.1.12
472-
*/
473-
Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer);
474-
475451
/**
476452
* Max amount of time to wait for responses.
477453
* <p>By default 5 seconds.
@@ -952,7 +928,7 @@ interface BodyContentSpec {
952928
* @since 5.1
953929
* @see #xpath(String, Map, Object...)
954930
*/
955-
default XpathAssertions xpath(String expression, Object... args) {
931+
default XpathAssertions xpath(String expression, Object... args){
956932
return xpath(expression, null, args);
957933
}
958934

@@ -966,7 +942,7 @@ default XpathAssertions xpath(String expression, Object... args) {
966942
* @param args arguments to parameterize the expression
967943
* @since 5.1
968944
*/
969-
XpathAssertions xpath(String expression, @Nullable Map<String, String> namespaces, Object... args);
945+
XpathAssertions xpath(String expression, @Nullable Map<String, String> namespaces, Object... args);
970946

971947
/**
972948
* Assert the response body content with the given {@link Consumer}.

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

+1-6
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

-6
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

+4-35
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

-15
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,6 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs {
106106
private boolean registerDefaults = true;
107107

108108

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

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

+1-31
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

+1-17
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

+1-16
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
}

0 commit comments

Comments
 (0)