[
https://issues.apache.org/jira/browse/GROOVY-12844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152534#comment-18152534
]
ASF GitHub Bot commented on GROOVY-12844:
-----------------------------------------
codecov-commenter commented on PR #3378:
URL: https://github.com/apache/groovy/pull/3378#issuecomment-7253382956
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3378?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 75.2908%. Comparing base
([`494d161`](https://app.codecov.io/gh/apache/groovy/commit/494d161bb13d832e65136174312ea6609867d869?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`3640aa7`](https://app.codecov.io/gh/apache/groovy/commit/3640aa730e8e4ae2a2570d60298208f4efacaf06?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/3378?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3378 +/- ##
==================================================
+ Coverage 75.2860% 75.2908% +0.0049%
- Complexity 49967 49972 +5
==================================================
Files 1775 1775
Lines 163660 163660
Branches 32301 32301
==================================================
+ Hits 123213 123221 +8
+ Misses 28947 28945 -2
+ Partials 11500 11494 -6
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3378?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...che/groovy/contracts/generation/BaseGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/3378?src=pr&el=tree&filepath=subprojects%2Fgroovy-contracts%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fcontracts%2Fgeneration%2FBaseGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnRyYWN0cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L2NvbnRyYWN0cy9nZW5lcmF0aW9uL0Jhc2VHZW5lcmF0b3IuamF2YQ==)
| `95.3125% <100.0000%> (ø)` | |
... and [12 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3378/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-contracts: StackOverflowError when a contract calls a checked method
> more than once
> ------------------------------------------------------------------------------------------
>
> Key: GROOVY-12844
> URL: https://issues.apache.org/jira/browse/GROOVY-12844
> Project: Groovy
> Issue Type: Bug
> Components: groovy-contracts
> Affects Versions: 6.0.0, 6.0.1
> Reporter: Paul King
> Priority: Major
>
> A class invariant that makes two calls to methods of its own class overflows
> the stack:
> {code:groovy}
> import groovy.contracts.*
> @Invariant({ lo <= hi })
> class Range {
> int getLo() { 1 }
> int getHi() { 2 }
> }
> new Range() // StackOverflowError
> {code}
> The same happens when one getter or method is called twice, e.g. {{v > 0 && v
> < 9}}, and for a {{@Requires}} or {{@Ensures}} that calls its own method
> twice, e.g. {{@Ensures({ m(1) > 0 && m(2) > 0 })}} on {{m}}. A single call
> works, as do ordinary properties of the class ({{int lo = 1, hi = 2}}). The
> invariant was tried in dynamic and statically compiled code, with the same
> result. All of these fail on 6.0.0, 6.0.1 and master.
> h3. Trait properties, from 6.0.1
> Reading a trait property once is enough:
> {code:groovy}
> trait T { Integer count }
> @Invariant({ count == null || count >= 0 })
> class C implements T { }
> new C() // 6.0.0: no error; 6.0.1: StackOverflowError
> {code}
> Two generated accessors are involved in one read ({{getCount}} and
> {{T__count$get}}), and both check the invariant. On 6.0.0 the check in those
> accessors wasn't run. Since GROOVY-12742 it is, which exposes this problem.
> 6.0.0 didn't handle these invariants properly either: its accessors returned
> null, so only an invariant that allows null passed.
> It's easy to meet on 6.0.1, since GROOVY-12741 advises moving a trait's
> invariant to the implementing class.
> h3. Cause
> {{ContractExecutionTracker}} should stop a contract from checking itself
> again while it runs. The code generated by
> {{BaseGenerator.wrapAssertionBooleanExpression}} is, in effect:
> {code:java}
> try {
> if (ContractExecutionTracker.track(...)) {
> // evaluate the condition
> }
> } finally {
> ContractExecutionTracker.clear(...);
> }
> {code}
> A nested check is refused by {{track}}, but still runs {{clear}}, which
> removes the outer check's entry. The next call from the same condition is
> then no longer recognised as nested, and evaluates the condition again,
> without end.
> h3. Possible fix
> Clear only what was tracked:
> {code:java}
> if (ContractExecutionTracker.track(...)) {
> try {
> // evaluate the condition
> } finally {
> ContractExecutionTracker.clear(...);
> }
> }
> {code}
> With this change on master, all the forms above work, including the trait
> properties, and violations are still reported, also on a second call after a
> first violation.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)