[
https://issues.apache.org/jira/browse/GROOVY-12024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18085007#comment-18085007
]
ASF GitHub Bot commented on GROOVY-12024:
-----------------------------------------
github-actions[bot] commented on PR #2580:
URL: https://github.com/apache/groovy/pull/2580#issuecomment-4587461623
### JMH summary — classic (commit `84922ba`)
Speedup vs trailing 90-day baseline on gh-pages. Higher = faster.
`1.00` = in line with history. Per-benchmark ratio, geomean within group.
Time-per-op units inverted so direction is consistent.
| Group | Speedup | n |
|--------|---------|---|
| bench | 0.997 × | 26 |
| core | 1.141 × | 77 |
| grails | 0.977 × | 80 |
<sub>Baseline: <code>dev/bench/jmh/<part>/classic/data.js</code> on
gh-pages, trailing 90 days. <a
href="https://apache.github.io/groovy/dev/bench/jmh/summary.html">Daily
dashboard</a> · <a
href="https://apache.github.io/groovy/dev/bench/jmh/">Per-suite raw
data</a></sub>
<!
> Subscript operator for Map has unexpected behavior when key is 'properties'
> ---------------------------------------------------------------------------
>
> Key: GROOVY-12024
> URL: https://issues.apache.org/jira/browse/GROOVY-12024
> Project: Groovy
> Issue Type: Bug
> Reporter: David Costanzo
> Assignee: Eric Milles
> Priority: Minor
>
> The subscript operator has strange behavior for Map when the key is
> 'properties'. Instead of accessing the value associated with that key, it
> accesses a read-only Map object.
> This behavior changed between Groovy 3 and Groovy 5. My expectation is that
> the subscript operator can access values for a key named 'properties', as it
> did in Groovy 3.
> *Steps to Reproduce:*
> In groovysh 5, the subscript operator references the system-provided,
> read-only map.
>
> {code:java}
> groovy> map = ['properties': 1]
> groovy> map['properties']
> [:]
> groovy> map['properties'] = 2
> ReadOnlyPropertyException: Cannot set read-only property: properties for
> class: java.util.LinkedHashMap{code}
>
> In groovysh 3, the subscript operator references keys of the user-created map.
>
> {code:java}
> groovy:000> map = ['properties': 1]
> ===> [properties:1]
> groovy:000> map['properties']
> ===> 1
> groovy:000> map['properties'] = 2
> ===> 2{code}
>
> I don't know if this is intentional, but I couldn't find a reference to in
> the documentation. On
> [https://docs.groovy-lang.org/latest/html/documentation/#subscript-operator]
> it says that the subscript operators is a shorthand for getAt() and setAt().
> On
> [https://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Map.html#getAt(java.lang.Object)]
> it does not mention that "properties" can't be used as a key.
> In my view, this is either a code bug (an internal implementation detail is
> being exposed beyond it's intended scope) or a doc bug (the subscript
> operator or Map.getAt() should mention the reserved system key named
> "properties").
> *Impact:*
> This creates the potential for hidden bugs. For example, I have a script
> that manages some metadata for internal libraries using a map keyed by the
> library name. The script appears to work correctly, but then I add a
> library named "properties" and the script fails to work. (This is not
> theoretical, this is what actually happened to me).
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)