[
https://issues.apache.org/jira/browse/GROOVY-12040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18083476#comment-18083476
]
ASF GitHub Bot commented on GROOVY-12040:
-----------------------------------------
codecov-commenter commented on PR #2565:
URL: https://github.com/apache/groovy/pull/2565#issuecomment-4543725194
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2565?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 68.1928%. Comparing base
([`42ce7e0`](https://app.codecov.io/gh/apache/groovy/commit/42ce7e09611dd02d85d6d1e80e3c079a90100460?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`782863a`](https://app.codecov.io/gh/apache/groovy/commit/782863a0f21e854dd05a4c5d77479d9f15d814fd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/2565?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2565 +/- ##
==================================================
+ Coverage 68.1904% 68.1928% +0.0024%
- Complexity 33103 33106 +3
==================================================
Files 1508 1508
Lines 126157 126157
Branches 22891 22891
==================================================
+ Hits 86027 86030 +3
+ Misses 32490 32487 -3
Partials 7640 7640
```
[see 3 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2565/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests,
report on failures, and find test suite problems.
- :package: [JS Bundle
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save
yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
> restore @Builder retention to RUNTIME in 5.0.x
> ----------------------------------------------
>
> Key: GROOVY-12040
> URL: https://issues.apache.org/jira/browse/GROOVY-12040
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
> This broke Grails.
> h3. Summary
> {{@groovy.transform.builder.Builder}} was {{@Retention(RUNTIME)}} through
> Groovy 4.0.x. In Groovy 5.0.0 it was changed to {{@Retention(SOURCE)}} in
> [GROOVY-10855|https://issues.apache.org/jira/browse/GROOVY-10855]
> ("normalized annotation metadata"). As a result,
> {{Class.getAnnotation(Builder.class)}} now returns {{null}} at runtime,
> breaking frameworks that reflect on the annotation to detect builder-shaped
> classes (e.g. Grails {{ConfigurationBuilder.buildRecurse}} -- see
> [apache/grails-core#15557|https://github.com/apache/grails-core/pull/15557]
> row 4).
> GROOVY-10855 was initially about the annotation collectors but we bundled in
> some more AST transform annotations that we weren't aware anyone was using at
> runtime. Builder ended up being a case that was being used.
> h3. Minimal Standalone Reproducer
> {code:groovy}
> import groovy.transform.builder.Builder
> import groovy.transform.builder.SimpleStrategy
> @Builder(builderStrategy = SimpleStrategy, prefix = '')
> class ConnectionSettings { String host = 'localhost' }
> // Copied from ConfigurationBuilder.buildRecurse, line 244-245:
> Builder ann = ConnectionSettings.getAnnotation(Builder)
> assert ann != null && ann.builderStrategy() == SimpleStrategy
> {code}
> || Version || {{getAnnotation(Builder)}} ||
> | 3.0.x | non-null (RUNTIME) |
> | 4.0.x | non-null (RUNTIME) |
> | 5.0.x / 6.0.0-alpha-1 | *null* (SOURCE) |
> h3. Reproducer (drives the real {{ConfigurationBuilder}}; no spring-context /
> spring-boot)
> {{ConfigurationBuilder}}'s constructor takes
> {{org.springframework.core.env.PropertyResolver}}, so {{spring-core}} is
> unavoidable on the classpath -- but no Spring container, binding chain, or
> converter machinery is needed.
> {code:groovy}
> @Grab('org.grails:grails-datastore-core:9.0.0-M3')
> @Grab('org.springframework:spring-core:6.1.14')
> import groovy.transform.builder.Builder
> import groovy.transform.builder.SimpleStrategy
> import org.grails.datastore.mapping.config.ConfigurationBuilder
> import org.springframework.core.env.PropertyResolver
> import org.springframework.core.env.AbstractPropertyResolver
> @Builder(builderStrategy = SimpleStrategy, prefix = '')
> class ConnectionSettings {
> String host = 'localhost'
> }
> class RootSettings {
> ConnectionSettings connection = new ConnectionSettings()
> void setConnection(ConnectionSettings cs) { this.connection = cs }
> ConnectionSettings getConnection() { connection }
> }
> class MapResolver extends AbstractPropertyResolver {
> private final Map<String, String> m
> MapResolver(Map<String, String> m) { this.m = m }
> boolean containsProperty(String key) { m.containsKey(key) }
> String getProperty(String key) { m.get(key) }
> <T> T getProperty(String key, Class<T> t) { (T) m.get(key) }
> String getPropertyOrDefault(String key, String d) { m.getOrDefault(key,
> d) }
> protected String getPropertyAsRawString(String key) { m.get(key) }
> }
> class RootBuilder extends ConfigurationBuilder<RootSettings, RootSettings> {
> RootBuilder(PropertyResolver pr) { super(pr, 'app') }
> protected RootSettings createBuilder() { new
> RootSettings() }
> protected RootSettings toConfiguration(RootSettings b) { b }
> }
> def resolver = new MapResolver(['app.connection.host': 'remotehost'])
> def cfg = new RootBuilder(resolver).build()
> println "Groovy ${GroovySystem.version}: host = ${cfg.connection.host}
> (expected 'remotehost')"
> assert cfg.connection.host == 'remotehost' :
> "ConfigurationBuilder did not recurse into the
> @Builder(SimpleStrategy) nested type — " +
> "getAnnotation(Builder) returned null"
> {code}
> h3. Result
> || Version || Output ||
> | 4.0.27 | {{host = remotehost}} (passes) |
> | 5.0.6 | {{host = localhost}} (AssertionError) |
> Same JVM, same Spring jar, same Grails jar. Only the Groovy runtime differs.
> h3. Root cause
> Commit {{3311ee95f5}} flipped {{Builder.java}} from {{RUNTIME}} to
> {{SOURCE}}. GROOVY-10855's stated scope was only the
> collector/meta-annotations ({{@Canonical}}, {{@CompileDynamic}},
> {{@Immutable}}, {{@RecordType}}) -- the change to {{@Builder}} (and a number
> of other user-facing class annotations) was scope-creep, undocumented in
> release notes, and not covered by tests.
> h3. Proposed fix
> Revert just {{@Builder}}'s retention to {{RUNTIME}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)