Unable to use LocalDate as a controller parameter
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Task List
- [x] Steps to reproduce provided
- [x] Stacktrace (if present) provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)
### Steps to Reproduce
1. Checkout https://github.com/acanby/grails-controller-localdate-test and bootRun
2. README.md has cURL commands to call to produce the error
### Expected Behaviour
Controller should not invoke newInstance for methods where there is no public constructor (easier said than done, I know)
### Actual Behaviour
Controller throws a 500 error due to the constructor not existing for `LocalDate`
```
Could not find matching constructor for: java.time.LocalDate(). Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.time.LocalDate()
at grails.artefact.Controller$Trait$Helper.initializeCommandObject(Controller.groovy:425)
... 14 common frames omitted
```
### Environment Information
- **Operating System**: Mac OS 10.12
- **Grails Version:** 3.3.1
- **JDK Version:** 1.8_131
- **Container Version (If Applicable):** NA
### Example Application
https://github.com/acanby/grails-controller-localdate-test
Contributor guide
Research direction
Reproduce the failure using the linked example application's README.md cURL commands. Start with grails.artefact.Controller$Trait$Helper.initializeCommandObject at Controller.groovy:425 and the invocation path in DefaultGrailsControllerClass.java:211. Done means a controller can receive a LocalDate parameter without the missing-constructor 500 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100