apache / apache/grails-core

Map constructors do not work when accessed from with a grails.gsp.PageRenderer

Open
#11,870 1 comment 0 reactions 0 assignees View on GitHub
relates-to: gorm
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

When I use a map constructor like:

Person p = new Person(name: "Bob")

through something that is called via a grails.gsp.PageRenderer, the field values are not populated. When I use an empty constructor and then set the fields individually like:

Person p = new Person()
p.name = "Bob"

it succeeds. When I use the map constructor in normal use cases, it also succeeds.

### Example project
https://github.com/danduke/constructor-test/

### Stackoverflow question, discussion, backstory
https://stackoverflow.com/questions/68446060/named-map-constructors-do-not-work-in-grails-gsp-pagerenderer

### Steps to Reproduce

1 - Download and run example application

### Expected Behaviour

`Person` object should be successfully created in all cases

### Actual Behaviour

`Person` object is not successfully created when map constructor is used via PageRenderer

### Caveats
This is certainly not a particularly impactful bug, and there is an easy workaround. However, it can easily lead to subtle failures in complex applications, and would be good to fix if feasible, or at least document if not.

Contributor guide

Open the contributing guide

Research direction

Start with the linked constructor-test example application and reproduce the difference between normal construction and construction through grails.gsp.PageRenderer. Read the linked Stack Overflow discussion for context, then trace the PageRenderer entry point and the map-constructor path. Done means the Person values are populated through PageRenderer, or the limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.