Skip to content

WebClient failed to write application/x-www-form-urlencoded [SPR-16055] #20604

@spring-projects-issues

Description

@spring-projects-issues

Sola opened SPR-16055 and commented

According to
https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageWriter.java#L53-L54
and
https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageWriter.java#L53-L54

the FormHttpMessageWriter should accept any MultiValueMap<String,String>,
but the following test can't get passed

import org.junit.Assert
import org.junit.Test
import org.springframework.core.ResolvableType
import org.springframework.http.MediaType
import org.springframework.http.codec.FormHttpMessageWriter
import org.springframework.util.LinkedMultiValueMap
import org.springframework.util.MultiValueMap

class ResolvableTypeTest {

    @Test
    fun test() {
        val writer = FormHttpMessageWriter()
        Assert.assertTrue(
                writer.canWrite(
                        ResolvableType.forInstance(LinkedMultiValueMap<String, String>()),
                        MediaType.APPLICATION_FORM_URLENCODED
                )
        )
    }

    private val MULTIVALUE_TYPE = ResolvableType.forClassWithGenerics(MultiValueMap::class.java, String::class.java, String::class.java)

    @Test
    fun testSimulate() {
        Assert.assertTrue(
                MULTIVALUE_TYPE.isAssignableFrom(
                        ResolvableType.forInstance(
                                LinkedMultiValueMap<String, String>()
                        )
                )
        )
    }

}

// code above was written in Kotlin


Affects: 5.0 GA

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions