grails-core: StackOverflowError when transactional controller method calls super class' method
Task List
- Example that reproduces the problem uploaded to Github
Steps to Reproduce
- Create a domain class and controller. The controller class should extend RestfulController.
- Generate views for the domain class.
- Add a method to the controller, named “save”, as below:
def save() {
super.save()
}
- Go to the domain class page and create a new domain instance. When you click “Save”, you will receive a StackOverflowError.
Stack Trace
The StackOverflowError trace has the following three lines repeated over and over:
at com.example.grails.controller.BookController$$EPsvqM2j.$tt__save(BookController.groovy:97)
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
Notice that RestfulController has a @Transactional annotation on the save() method. My hunch is that the AST transformation which applies the @Transactional annotation has a bug wherein the resulting AST blindly calls the method (“save” in this case) on the instance’s class (which results in the subclass’s “save” method being called) instead of directly calling the base class’ method (which is where the @Transactional attribute is).
The AST transformation is org.codehaus.groovy.grails.transaction.transform.TransactionalTransform
Environment Information
- Operating System: Windows 7, 64 bit
- Grails Version: 3.1.5
- JDK Version: 1.8.0u45
- Container Version (If Applicable): N/A
Example Application
- I do not have the ability to create a test github project (to reproduce) where I am at now. I may be able to do this at a later time, if I have the opportunity. If someone else is willing to do this, please do; the full steps are described above.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (14 by maintainers)
Fix requires upgrading to GORM 6.1.2 when it is released