[
https://issues.apache.org/jira/browse/GROOVY-9742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17943526#comment-17943526
]
ASF GitHub Bot commented on GROOVY-9742:
----------------------------------------
codecov-commenter commented on PR #2185:
URL: https://github.com/apache/groovy/pull/2185#issuecomment-2796669887
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2185?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 68.9196%. Comparing base
[(`662ac50`)](https://app.codecov.io/gh/apache/groovy/commit/662ac50b2264225de916179417ddfc3020b1725f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
to head
[(`ceb5532`)](https://app.codecov.io/gh/apache/groovy/commit/ceb5532916b11c6841b1f7ee58e0028a408f585b?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/2185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2185 +/- ##
==================================================
+ Coverage 68.9179% 68.9196% +0.0018%
+ Complexity 29596 29595 -1
==================================================
Files 1423 1423
Lines 113924 113924
Branches 19758 19758
==================================================
+ Hits 78514 78516 +2
Misses 28785 28785
+ Partials 6625 6623 -2
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2185?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[src/main/java/groovy/lang/GroovyClassLoader.java](https://app.codecov.io/gh/apache/groovy/pull/2185?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Flang%2FGroovyClassLoader.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvbGFuZy9Hcm9vdnlDbGFzc0xvYWRlci5qYXZh)
| `72.8682% <100.0000%> (ø)` | |
|
[...g/codehaus/groovy/runtime/memoize/CommonCache.java](https://app.codecov.io/gh/apache/groovy/pull/2185?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2Fmemoize%2FCommonCache.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvbWVtb2l6ZS9Db21tb25DYWNoZS5qYXZh)
| `75.8621% <ø> (ø)` | |
|
[.../groovy/runtime/memoize/ConcurrentCommonCache.java](https://app.codecov.io/gh/apache/groovy/pull/2185?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2Fmemoize%2FConcurrentCommonCache.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvbWVtb2l6ZS9Db25jdXJyZW50Q29tbW9uQ2FjaGUuamF2YQ==)
| `75.0000% <ø> (ø)` | |
|
[...aus/groovy/runtime/memoize/StampedCommonCache.java](https://app.codecov.io/gh/apache/groovy/pull/2185?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2Fmemoize%2FStampedCommonCache.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvbWVtb2l6ZS9TdGFtcGVkQ29tbW9uQ2FjaGUuamF2YQ==)
| `61.6438% <ø> (ø)` | |
... and [3 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2185/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>
> GroovyClassLoader.parseClass() StampedCommonCache.getAndPut() hang
> ------------------------------------------------------------------
>
> Key: GROOVY-9742
> URL: https://issues.apache.org/jira/browse/GROOVY-9742
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 3.0.5
> Environment: Java version AdoptOpenJDK (build 25.262-b10, mixed mode)
> Gradle version 6.6.1
> Groovy version 3.0.5
> Reporter: Chiang Seng Chang
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 5.0.0-alpha-13
>
> Attachments: g3cl.tar.gz
>
>
> We have an IDE-like app which allows our coders to develop groovy scripts and
> classes.
> Essentially, the coders would write groovy sources and test them in the app.
> We made a CustomClassLoader which is created and destroyed for each test run,
> so that the app need no be restarted every time there is code change.
> In Groovy 3.0.5, the GroovyClassLoader's cache is refactored to use
> StampedCommonCache, which does not support recursion.
> This is the distilled simplified version of our CustomClassLoader:
> {noformat}
> public class CustomGroovyClassLoader extends ClassLoader {
> public CustomGroovyClassLoader(ClassLoader parent) {
> super(parent);
> groovyClassLoader = new GroovyClassLoader(this);
> }
> private final File srcDir = new File("./src/main/groovy");
> private final GroovyClassLoader groovyClassLoader;
> @Override
> protected Class<?> loadClass(String name, boolean resolve)
> throws ClassNotFoundException {
> synchronized (getClassLoadingLock(name)) {
> Class<?> c = doFindClass(name);
> if (c != null) {
> if (resolve) {
> resolveClass(c);
> }
> return c;
> }
> }
> return super.loadClass(name, resolve);
> }
> private Class<?> doFindClass(String name) {
> File classFile = new File(srcDir, name.replace('.', '/') + ".groovy");
> if (classFile.exists()) {
> try {
> System.out.println("PARSE\t: " + name);
> Class<?> clz = groovyClassLoader.parseClass(classFile);
> System.out.println("PARSED\t: " + clz);
> return clz;
> }
> catch (IOException e) {
> throw new RuntimeException(e);
> }
> }
> return null;
> }
> }
> {noformat}
> Essentially, it uses the GroovyClassLoader.parseClass() for our test classes.
> Here are the 2 classes to demonstrate the issue:
> {noformat}
> package foo
> import groovy.transform.CompileStatic
> @CompileStatic
> interface Bar {}
> {noformat}
> {noformat}
> package foo
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo implements Bar {}
> {noformat}
> And the test harness:
> {noformat}
> package foo;
> public class TestHarness {
> public static void main(String[] args) throws Exception {
> ClassLoader pcl = TestHarness.class.getClassLoader();
> CustomGroovyClassLoader ccl = new CustomGroovyClassLoader(pcl);
> Class<?> clz = ccl.loadClass("foo.Foo");
> System.out.println("DONE\t: " + clz);
> }
> }
> {noformat}
> The harness attempt to load Foo.groovy.
> The sequence of events would be:
> # CustomClassLoader.loadClass(Foo)
> # GroovyClassLoader.parseClass(Foo.groovy)
> # sourceCache.getAndPut(Foo)
> # Since Foo implements Bar, CustomClassLoader is called to load Bar
> # which in turn calls GroovyClassLoader.parseClass(Bar.groovy)
> # and sourceCache.getAndPut(Bar)
> # Since StampedCommonCache does not support recursion, the loading hangs.
> The attached project can be run using ./gradlew run to demonstrate the
> hanging.
> It seems to me that the GroovyClassLoader needs to support recursion for this
> use case.
> Or perhaps the CustomClassLoader is implemented wrongly?
> Groovy 2.5.12 does not have this issue because its GroovyClassLoader uses
> ConcurrentCommonCache.
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)