Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,17 @@ class GrailsParameterMapTests {
assert '[a.b.c.d:1, a:[b.c.d:1, b:[c.d:1, c:[d:1], e:2], b.e:2], a.b.e:2]' == params.toString()
assert params != null
}

@Test
void testArrayKeys() {
def request = new MockHttpServletRequest()
def requestParams = ['a[3].b': '1', 'a[4].b': '2']
request.setParameters(requestParams)
def params = new GrailsParameterMap(request)
assert '[a[3].b:1, a[4].b:2, a:[3: [b:1], 4:[b:2]]]' == params.toString()
// right now grails also breaks it up by also adding:
// "[a[0]:[b:1], a[1]:[b:2]]"
// Personally, I think that's useless, but whether you want to retain it, I don't know.
assert params != null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asserting that params is not null may not make sense here. In order for it to be null, the new GrailsParameterMap(request) would have to return null, and then a NullPointerException would have been thrown at line 504 I think. Is that correct?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable, I was just following the existing pattern.

}
}