From 2962f085e508b066ad33c7285178ba2d2b7095bc Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Thu, 12 Oct 2017 17:48:42 +0200 Subject: [PATCH] Relax type check in FormHttpMessage(Reader|Writer) Issue: SPR-16055 --- .../springframework/http/codec/FormHttpMessageReader.java | 5 +++-- .../springframework/http/codec/FormHttpMessageWriter.java | 3 ++- .../http/codec/FormHttpMessageReaderTests.java | 5 +++++ .../http/codec/FormHttpMessageWriterTests.java | 4 ++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java index e3626d0991..ff58e9e5af 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java @@ -77,8 +77,9 @@ public class FormHttpMessageReader implements HttpMessageReader()), + MediaType.APPLICATION_FORM_URLENCODED)); + assertFalse(this.reader.canRead( ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, Object.class), MediaType.APPLICATION_FORM_URLENCODED)); diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java index dd1c9c9d2d..1bd1fff361 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java @@ -44,6 +44,10 @@ public class FormHttpMessageWriterTests { ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, String.class), MediaType.APPLICATION_FORM_URLENCODED)); + assertTrue(this.writer.canWrite( + ResolvableType.forInstance(new LinkedMultiValueMap()), + MediaType.APPLICATION_FORM_URLENCODED)); + assertFalse(this.writer.canWrite( ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, Object.class), MediaType.APPLICATION_FORM_URLENCODED));