-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed as not planned
Closed as not planned
Copy link
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement
Description
Affects: 6.0.0.M5 (but also 5.x)
I'm trying to get an immutable representation of the query parameters in my @RestController
, like this:
@RestController
public class MyController {
@RequestMapping("/foo")
public void foo(A a) {
}
record A(String s, B b) {
}
record B(Integer i) {
}
}
For single-level query params this works as expected: GET /foo?s=xyz
But as soon as I try to set b.i
using GET /foo?b.i=42
it will throw an exception, because AbstractNestablePropertyAccessor is looking for a default constructor:
java.lang.NoSuchMethodException: com.example.demo.MyController$B.<init>()
at java.base/java.lang.Class.getConstructor0(Class.java:3585) ~[na:na]
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754) ~[na:na]
at org.springframework.beans.AbstractNestablePropertyAccessor.newValue(AbstractNestablePropertyAccessor.java:910) ~[spring-beans-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.beans.AbstractNestablePropertyAccessor.createDefaultPropertyValue(AbstractNestablePropertyAccessor.java:883) ~[spring-beans-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.beans.AbstractNestablePropertyAccessor.setDefaultValue(AbstractNestablePropertyAccessor.java:870) ~[spring-beans-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.beans.AbstractNestablePropertyAccessor.getNestedPropertyAccessor(AbstractNestablePropertyAccessor.java:842) ~[spring-beans-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyAccessorForPropertyPath(AbstractNestablePropertyAccessor.java:816) ~[spring-beans-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:257) ~[spring-beans-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104) ~[spring-beans-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:889) ~[spring-context-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.validation.DataBinder.doBind(DataBinder.java:780) ~[spring-context-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:207) ~[spring-web-6.0.0-M5.jar:6.0.0-M5]
at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:129) ~[spring-web-6.0.0-M5.jar:6.0.0-M5]
Thanks for your help!
yotov and mvpcortes
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement