Do not provide hints for can*() methods anymore
Issue: SPR-14557
This commit is contained in:
@@ -56,8 +56,8 @@ public class DecoderHttpMessageReader<T> implements HttpMessageReader<T> {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canRead(ResolvableType elementType, MediaType mediaType, Map<String, Object> hints) {
|
||||
return this.decoder != null && this.decoder.canDecode(elementType, mediaType, hints);
|
||||
public boolean canRead(ResolvableType elementType, MediaType mediaType) {
|
||||
return this.decoder != null && this.decoder.canDecode(elementType, mediaType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,8 +60,8 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canWrite(ResolvableType elementType, MediaType mediaType, Map<String, Object> hints) {
|
||||
return this.encoder != null && this.encoder.canEncode(elementType, mediaType, hints);
|
||||
public boolean canWrite(ResolvableType elementType, MediaType mediaType) {
|
||||
return this.encoder != null && this.encoder.canEncode(elementType, mediaType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,10 +42,9 @@ public interface HttpMessageReader<T> {
|
||||
* @param elementType the stream element type to test for readability
|
||||
* @param mediaType the media type to read, can be {@code null} if not specified.
|
||||
* Typically the value of a {@code Content-Type} header.
|
||||
* @param hints additional information about how to do read
|
||||
* @return {@code true} if readable; {@code false} otherwise
|
||||
*/
|
||||
boolean canRead(ResolvableType elementType, MediaType mediaType, Map<String, Object> hints);
|
||||
boolean canRead(ResolvableType elementType, MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Read a {@link Flux} of the given type form the given input message, and returns it.
|
||||
@@ -53,7 +52,7 @@ public interface HttpMessageReader<T> {
|
||||
* passed to the {@link #canRead canRead} method of this interface, which must have
|
||||
* returned {@code true}.
|
||||
* @param inputMessage the HTTP input message to read from
|
||||
* @param hints additional information about how to do read
|
||||
* @param hints additional information about how to read the body
|
||||
* @return the converted {@link Flux} of elements
|
||||
*/
|
||||
Flux<T> read(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints);
|
||||
@@ -64,7 +63,7 @@ public interface HttpMessageReader<T> {
|
||||
* passed to the {@link #canRead canRead} method of this interface, which must have
|
||||
* returned {@code true}.
|
||||
* @param inputMessage the HTTP input message to read from
|
||||
* @param hints additional information about how to do read
|
||||
* @param hints additional information about how to read the body
|
||||
* @return the converted {@link Mono} of object
|
||||
*/
|
||||
Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints);
|
||||
|
||||
@@ -42,10 +42,9 @@ public interface HttpMessageWriter<T> {
|
||||
* @param elementType the stream element type to test for writability
|
||||
* @param mediaType the media type to write, can be {@code null} if not specified.
|
||||
* Typically the value of an {@code Accept} header.
|
||||
* @param hints additional information about how to write
|
||||
* @return {@code true} if writable; {@code false} otherwise
|
||||
*/
|
||||
boolean canWrite(ResolvableType elementType, MediaType mediaType, Map<String, Object> hints);
|
||||
boolean canWrite(ResolvableType elementType, MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Write an given object to the given output message.
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite(ResolvableType elementType, MediaType mediaType, Map<String, Object> hints) {
|
||||
public boolean canWrite(ResolvableType elementType, MediaType mediaType) {
|
||||
return mediaType == null || TEXT_EVENT_STREAM.isCompatibleWith(mediaType);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
||||
ResolvableType elementType = ResolvableType.forClass(data.getClass());
|
||||
Optional<Encoder<?>> encoder = dataEncoders
|
||||
.stream()
|
||||
.filter(e -> e.canEncode(elementType, MimeTypeUtils.APPLICATION_JSON, Collections.emptyMap()))
|
||||
.filter(e -> e.canEncode(elementType, MimeTypeUtils.APPLICATION_JSON))
|
||||
.findFirst();
|
||||
return ((Encoder<T>) encoder.orElseThrow(() -> new CodecException("No suitable encoder found!")))
|
||||
.encode(Mono.just((T) data), bufferFactory, elementType, MimeTypeUtils.APPLICATION_JSON, hints)
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Jackson2JsonDecoder extends AbstractJackson2Codec implements Decode
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canDecode(ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
public boolean canDecode(ResolvableType elementType, MimeType mimeType) {
|
||||
if (mimeType == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Jackson2JsonEncoder extends AbstractJackson2Codec implements Encode
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canEncode(ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
public boolean canEncode(ResolvableType elementType, MimeType mimeType) {
|
||||
if (mimeType == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ public class Jaxb2XmlDecoder extends AbstractDecoder<Object> {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canDecode(ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
if (super.canDecode(elementType, mimeType, hints)) {
|
||||
public boolean canDecode(ResolvableType elementType, MimeType mimeType) {
|
||||
if (super.canDecode(elementType, mimeType)) {
|
||||
Class<?> outputClass = elementType.getRawClass();
|
||||
return outputClass.isAnnotationPresent(XmlRootElement.class) ||
|
||||
outputClass.isAnnotationPresent(XmlType.class);
|
||||
|
||||
@@ -53,8 +53,8 @@ public class Jaxb2XmlEncoder extends AbstractSingleValueEncoder<Object> {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canEncode(ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
if (super.canEncode(elementType, mimeType, hints)) {
|
||||
public boolean canEncode(ResolvableType elementType, MimeType mimeType) {
|
||||
if (super.canEncode(elementType, mimeType)) {
|
||||
Class<?> outputClass = elementType.getRawClass();
|
||||
return (outputClass.isAnnotationPresent(XmlRootElement.class) ||
|
||||
outputClass.isAnnotationPresent(XmlType.class));
|
||||
|
||||
@@ -196,7 +196,7 @@ public abstract class ResponseExtractors {
|
||||
ResolvableType responseType, MediaType contentType) {
|
||||
|
||||
return messageReaders.stream()
|
||||
.filter(e -> e.canRead(responseType, contentType, Collections.emptyMap()))
|
||||
.filter(e -> e.canRead(responseType, contentType))
|
||||
.findFirst()
|
||||
.orElseThrow(() ->
|
||||
new WebClientException(
|
||||
|
||||
@@ -297,7 +297,7 @@ public final class WebClient {
|
||||
protected Optional<HttpMessageWriter<?>> resolveWriter(List<HttpMessageWriter<?>> messageWriters,
|
||||
ResolvableType type, MediaType mediaType) {
|
||||
|
||||
return messageWriters.stream().filter(e -> e.canWrite(type, mediaType, Collections.emptyMap())).findFirst();
|
||||
return messageWriters.stream().filter(e -> e.canWrite(type, mediaType)).findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ public class RxJava1ResponseExtractors {
|
||||
ResolvableType responseType, MediaType contentType) {
|
||||
|
||||
return messageReaders.stream()
|
||||
.filter(e -> e.canRead(responseType, contentType, Collections.emptyMap()))
|
||||
.filter(e -> e.canRead(responseType, contentType))
|
||||
.findFirst()
|
||||
.orElseThrow(() ->
|
||||
new WebClientException(
|
||||
|
||||
Reference in New Issue
Block a user