0

I have a class implementing RepresentationModelProcessor that's adding links to a resource:

linkTo(methodOn(MyController.class).findMyElements(file.getId(), null, null)) 
    .withRel("filterFiles"))

The controller looks like this:

@RequestMapping(method = { POST, GET }, value = "/myFiles/{fileId}/filterFiles")
public List<FileDto> findFilterFiles( @PathVariable("fileId") final Long fileId,
     @RequestParam(name = "fileType") final Long fileType, 
     @RequestBody(required = false) final FileFilterDto filter)

In Spring 2.6.4, it used to work. Now, I've tried upgrading to 2.7.4 and it does not work anymore. I've tracked the issue down and it seems like the required request param must not be null anymore.

I'm getting a null pointer exception with text like this: Illegal character in query at index 93: http://localhost:8080/files/10013/filterFiles?fileType={fileType} with the index pointing to '=' of fileType={fileType} .

Is it a bug? If yes - how can I fix it? Passing a constant number fixes the null-pointer exception:

linkTo(methodOn(MyController.class) .findMyElements(file.getId(), 1L, null))
    .withRel("filterFiles"))

but it leads to incorrect code.

I've raised an issue here: https://github.com/spring-projects/spring-hateoas/issues/1872 but it might be the wrong repository after all.

user1497119
  • 443
  • 6
  • 19

0 Answers0