Affects: 6.1.5

A rest controller with the following method

    @GetMapping("/{path}")
    public void get(Params params, @PathVariable long path, @RequestParam String foo, @RequestHeader String accept) {
        System.out.printf("path: %d%n", path);
        System.out.printf("foo: %s%n", foo);
        System.out.printf("accept: %s%n", accept);
        System.out.printf("params: %s%n", params);
    }
    public record Params(@PathVariable long path, @RequestParam String foo, @RequestHeader String accept) {}

will produce the following log when called with /1?foo=FOO:

    path: 1
    foo: FOO
    accept: application/json, text/plain, */*
    params: Params[path=1, foo=FOO, accept=null]

@PathVariable and @RequestParam are correctly used to instantiate the record but the @RequestHeader remains null (although it works as a parameter of the controller method)

Comment From: sbrannen

Hi @kalgon,

Thanks for creating this issue.

@PathVariable and @RequestParam are correctly used to instantiate the record but the @RequestHeader remains null (although it works as a parameter of the controller method)

I have confirmed that to be the case.

@rstoyanchev, is it intentional that @RequestHeader is not supported for this use case?

Comment From: rstoyanchev

This is regular data binding at work, but applied through constructor args. Note that the @PathVariable, @RequestParam, and @RequestHeader annotations on the record fields play no role at all, so you can drop them unless you want to keep them for clarity.

For data binding we've long supported using both request parameters and path variables. We can add headers to the map of values to bind from.