Closed nikolavojicic closed 2 years ago
I've been looking at this myself for a bit. There are two main barriers to supporting records. The first is in the Introspector. I think I've found a way to solve that problem. The second is in bean parameter resolver for Spring MVC and Webflux. There seems to be support for records by way of constructor argument binding but unfortunately the extension points for me to hook into don't provide enough data for me to run the Introspector and fetch the data. I'm trying to see if there is a change I can make to Spring to provide a better extension point but so far no luck. The alternative is to duplicate the resolver which is not an idea I like as it would be a maintenance burden I'm not interested in.
Long story short, I have no ETA on records support.
I am open to suggestions and pull requests.
Thank you for the details. I will dive into the codebase and try to come up with ideas how to do it.
I spent some time yesterday working on this. My branch is here. It requires Java 17 to build now. The bytecode is still Java 8 though.
I have some basic support for records. Nested binding doesn't work and is unlikely to in this iteration.
I've published a snapshot (0.5.0-SNAPSHOT) to Maven Central if you want to try it out.
Thanks for the branch. We don't currently use nested binding anyway. Will test it this week.
Snapshot version works with records for our (simple) cases.
One surprising thing is that e.g. @RequestParameter("first_name")
accepts both first_name
and firstName
.
Thats fine for us though...
@nikolavojicic I think that is due to the nature of how this binding works. I'm essentially leveraging the existing constructor binding that Spring has for creating beans. It can also bind via camelcase names. This is something I disabled in the standard bean binding but I'm not sure I can do that here.
I'll work to get the rest of the tests in place and make a release.
@nikolavojicic I just pushed up another snapshot with the completed work. Can you test one more time before I publish the final version to Maven Central? Thanks.
I've published version 0.5.0 to Maven Central. It might take a few hours to propagate. This should give basic records support. I'll keep following updates on the Spring framework support and adjust if they improve things there. Closing this as completed.
Would it be much work to support Java 15
record
s?It seems that those are not working currently.
I guess the main problem is
get
missing fromrecord
"getters".