Skip to content

Grails 6.2.3 - Cast Exception in Controller Action with a parameter with the same name as a local variable in a different action #14947

@solaechea

Description

@solaechea

Expected Behavior

No incorrect cast should be performed on a controller action that takes a String parameter.

Actual Behaviour

In the example project attached to this ticket you can see that the exampleController defines an echo action, this action takes a String parameter named person. When another action in the same controller defines a local variable with the same name (person) and a different type (type Person in the example), an incorrect cast in being performed. The person parameter, which should be received as String is being converted to the type Person and a GroovyCastException is thrown.

This issue is similar to #13486

Steps To Reproduce

Details in README.md

  1. Launch grails app
  2. Visit http://localhost:8080/example/echo?person=George+Doe

Environment Information

Windows 11 Home
Version 24H2
OS build 26100.4652
Experience Windows Feature Experience Pack 1000.26100.128.0

java 17.0.9 2023-10-17 LTS
Java(TM) SE Runtime Environment (build 17.0.9+11-LTS-201)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.9+11-LTS-201, mixed mode, sharing)

Example Application

https://github.com/solaechea/grails-broken-binding

Version

6.2.3

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions