Skip to content

Request param value with curly braces throws IllegalArgumentException #335

Open
@dreambrother

Description

@dreambrother

Example:

@ResponseBody
@RequestMapping(value = "", method = RequestMethod.GET)
public Resources<FileResource> listFilesHal(
        @RequestParam(value = "q") String query) {
    Link self = linkTo(methodOn(FileRestController.class).listFilesHal(query)).withSelfRel();
    return new Resources<>(listFilesImpl(query), self);
}

If q contains curly braces (and it does because it's JSON) then linkTo throws
GET http://localhost:8080/files?q={"foo": "bar"}

java.lang.IllegalArgumentException: Map has no value for '"foo"'
    at org.springframework.web.util.UriComponents$MapTemplateVariables.getValue(UriComponents.java:276)
    at org.springframework.web.util.UriComponents.expandUriComponent(UriComponents.java:221)
    at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:326)
    at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:46)
    at org.springframework.web.util.UriComponents.expand(UriComponents.java:152)
    at org.springframework.web.util.UriComponentsBuilder.buildAndExpand(UriComponentsBuilder.java:302)
    at org.springframework.hateoas.mvc.ControllerLinkBuilderFactory.linkTo(ControllerLinkBuilderFactory.java:145)
    at org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo(ControllerLinkBuilder.java:135)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions