Polishing
See gh-23961
This commit is contained in:
@@ -64,11 +64,12 @@ public interface ClientCodecConfigurer extends CodecConfigurer {
|
||||
ClientDefaultCodecs defaultCodecs();
|
||||
|
||||
/**
|
||||
* Clone this {@link ClientCodecConfigurer}.
|
||||
* {@inheritDoc}.
|
||||
*/
|
||||
@Override
|
||||
ClientCodecConfigurer clone();
|
||||
|
||||
|
||||
/**
|
||||
* Static factory method for a {@code ClientCodecConfigurer}.
|
||||
*/
|
||||
|
||||
@@ -88,7 +88,10 @@ public interface CodecConfigurer {
|
||||
List<HttpMessageWriter<?>> getWriters();
|
||||
|
||||
/**
|
||||
* Clone this {@link CodecConfigurer}.
|
||||
* Create a copy of this {@link CodecConfigurer}. The returned clone has its
|
||||
* own lists of default and custom codecs and generally can be configured
|
||||
* independently. Keep in mind however that codec instances (if any are
|
||||
* configured) are themselves not cloned.
|
||||
* @since 5.1.12
|
||||
*/
|
||||
CodecConfigurer clone();
|
||||
|
||||
@@ -62,6 +62,12 @@ public interface ServerCodecConfigurer extends CodecConfigurer {
|
||||
@Override
|
||||
ServerDefaultCodecs defaultCodecs();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}.
|
||||
*/
|
||||
@Override
|
||||
ServerCodecConfigurer clone();
|
||||
|
||||
|
||||
/**
|
||||
* Static factory method for a {@code ServerCodecConfigurer}.
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.util.Assert;
|
||||
* @author Brian Clozel
|
||||
* @since 5.0
|
||||
*/
|
||||
class BaseCodecConfigurer implements CodecConfigurer {
|
||||
abstract class BaseCodecConfigurer implements CodecConfigurer {
|
||||
|
||||
protected final BaseDefaultCodecs defaultCodecs;
|
||||
|
||||
@@ -55,14 +55,21 @@ class BaseCodecConfigurer implements CodecConfigurer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with another {@link BaseCodecConfigurer} to copy
|
||||
* the configuration from.
|
||||
* Create a deep copy of the given {@link BaseCodecConfigurer}.
|
||||
* @since 5.1.12
|
||||
*/
|
||||
BaseCodecConfigurer(BaseCodecConfigurer other) {
|
||||
protected BaseCodecConfigurer(BaseCodecConfigurer other) {
|
||||
this.defaultCodecs = other.cloneDefaultCodecs();
|
||||
this.customCodecs = new DefaultCustomCodecs(other.customCodecs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sub-classes should override this to create deep copy of
|
||||
* {@link BaseDefaultCodecs} which can can be client or server specific.
|
||||
* @since 5.1.12
|
||||
*/
|
||||
protected abstract BaseDefaultCodecs cloneDefaultCodecs();
|
||||
|
||||
|
||||
@Override
|
||||
public DefaultCodecs defaultCodecs() {
|
||||
@@ -99,16 +106,6 @@ class BaseCodecConfigurer implements CodecConfigurer {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CodecConfigurer clone() {
|
||||
return new BaseCodecConfigurer(this);
|
||||
}
|
||||
|
||||
protected BaseDefaultCodecs cloneDefaultCodecs() {
|
||||
return new BaseDefaultCodecs(this.defaultCodecs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal method that returns the configured writers.
|
||||
* @param forMultipart whether to returns writers for general use ("false"),
|
||||
@@ -128,6 +125,9 @@ class BaseCodecConfigurer implements CodecConfigurer {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract CodecConfigurer clone();
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of {@code CustomCodecs}.
|
||||
@@ -146,6 +146,10 @@ class BaseCodecConfigurer implements CodecConfigurer {
|
||||
DefaultCustomCodecs() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a deep copy of the given {@link DefaultCustomCodecs}.
|
||||
* @since 5.1.12
|
||||
*/
|
||||
DefaultCustomCodecs(DefaultCustomCodecs other) {
|
||||
other.typedReaders.addAll(this.typedReaders);
|
||||
other.typedWriters.addAll(this.typedWriters);
|
||||
|
||||
@@ -109,6 +109,9 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs {
|
||||
BaseDefaultCodecs() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a deep copy of the given {@link BaseDefaultCodecs}.
|
||||
*/
|
||||
protected BaseDefaultCodecs(BaseDefaultCodecs other) {
|
||||
this.jackson2JsonDecoder = other.jackson2JsonDecoder;
|
||||
this.jackson2JsonEncoder = other.jackson2JsonEncoder;
|
||||
|
||||
Reference in New Issue
Block a user