[
https://issues.apache.org/jira/browse/GROOVY-12089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18089055#comment-18089055
]
ASF GitHub Bot commented on GROOVY-12089:
-----------------------------------------
codecov-commenter commented on PR #2611:
URL: https://github.com/apache/groovy/pull/2611#issuecomment-4706073383
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2611?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.4577%. Comparing base
([`7200290`](https://app.codecov.io/gh/apache/groovy/commit/72002909d7079f9b60b12459b203eeac234541f2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`62805bc`](https://app.codecov.io/gh/apache/groovy/commit/62805bc96261c9b718c327b09f6dd2f408da6963?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/2611?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2611 +/- ##
==================================================
+ Coverage 68.4522% 68.4577% +0.0055%
- Complexity 33503 33504 +1
==================================================
Files 1518 1518
Lines 127096 127096
Branches 23062 23063 +1
==================================================
+ Hits 87000 87007 +7
+ Misses 32372 32365 -7
Partials 7724 7724
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2611?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[.../main/java/org/codehaus/groovy/ast/MethodNode.java](https://app.codecov.io/gh/apache/groovy/pull/2611?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FMethodNode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9NZXRob2ROb2RlLmphdmE=)
| `97.9381% <100.0000%> (ø)` | |
... and [9 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2611/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>
> Groovy 5 ClassNode.getGetterMethod() can clone a getter with a null
> exceptions array when @Entity and @Sortable are combined
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12089
> URL: https://issues.apache.org/jira/browse/GROOVY-12089
> Project: Groovy
> Issue Type: Bug
> Components: AST Transforms
> Affects Versions: 5.0.6
> Reporter: Mattias Reichel
> Assignee: Paul King
> Priority: Major
>
> With Groovy 5, a Grails domain class annotated with both {{@Entity}} and
> {{@Sortable}} can fail during canonicalization with:
> {code:java}
> BUG! exception in phase 'canonicalization' in source unit '...' unexpected
> NullPointerException
> Caused by: java.lang.NullPointerException: Cannot read the array length
> because "<local3>" is null
> at
> org.codehaus.groovy.classgen.VariableScopeVisitor.visitConstructorOrMethod(...)
> at
> org.codehaus.groovy.transform.SortableASTTransformation.createSortable(...){code}
> A minimal reproducer is:
> {code:java}
> import grails.persistence.Entity
> import groovy.transform.Sortable
> @Entity
> @Sortable(includes = ['a'])
> class Repro {
> String a
> }{code}
> {{@Sortable}} by itself compiles, and {{@Entity}} by itself compiles. The
> failure only appears when they are combined.
> According to GPT, the Groovy-side branch that introduces the null exceptions
> array is in
> {{{}org.codehaus.groovy.ast.ClassNode#getGetterMethod(String){}}},
> specifically the default-argument getter synthesis branch:
> {code:java}
> } else if (method.hasDefaultValue() &&
> Stream.of(method.getParameters()).allMatch(Parameter::hasInitialExpression)) {
> // GROOVY-11380: getter generated later by default arguments
> if (isNullOrSynthetic.test(getterMethod)) {
> getterMethod = new MethodNode(method.getName(), method.getModifiers()
> & ~ACC_ABSTRACT, method.getReturnType(), Parameter.EMPTY_ARRAY,
> method.getExceptions(), null);
> getterMethod.setSynthetic(true);
> getterMethod.setDeclaringClass(this);
> getterMethod.addAnnotations(method.getAnnotations());
> AnnotatedNodeUtils.markAsGenerated(this, getterMethod);
> getterMethod.setGenericsTypes(method.getGenericsTypes());
> }
> }
> {code}
> If the source method carries a null exceptions array, that null is preserved
> on the synthesized getter and later blows up in
> {{{}VariableScopeVisitor.visitConstructorOrMethod(...){}}}.
> I can also add, that historically, Grails often created methods in AST with a
> null exceptions parameter. With Groovy 5 this blew up in the same way. We
> have therefore changed to consistently pass ClassNode.EMPTY_ARRAY to remedy
> that situation. However, it feels like there should be a guard on the Groovy
> side for this instead of blowing up.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)