question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValidateLayerConsistencyTest is flaky

See original GitHub issue

Apache NetBeans version

Apache NetBeans latest daily build

What happened

The ValidateLayerConsistencyTest seems to be flaky:

https://github.com/apache/netbeans/blob/2bdbb637653cf19179963a3150add8f99d8b6977/platform/o.n.core/test/qa-functional/src/org/netbeans/core/validation/ValidateLayerConsistencyTest.java

Sometimes fails in an assertion:

2022-06-08T18:30:24.0613903Z     [junit] FINE [org.openide.util.lookup.implspi.ActiveQueue]: Got dequeued reference org.openide.util.lookup.AbstractLookup$ReferenceToResult@597289e4
2022-06-08T18:30:24.0614562Z     [junit] FINE [org.openide.util.lookup.implspi.ActiveQueue]: Got dequeued reference org.openide.util.lookup.AbstractLookup$ReferenceToResult@67cb9a30
2022-06-08T18:30:27.1650822Z     [junit] java.lang.AssertionError: Has to be NbRepository: org.openide.filesystems.Repository@5cf749fa Initialization stack: java.lang.Exception: initialized
2022-06-08T18:30:27.1651908Z     [junit] 	at org.openide.filesystems.Repository.<init>(Repository.java:326)
2022-06-08T18:30:27.1652502Z     [junit] 	at org.openide.filesystems.Repository$3.call(Repository.java:373)
2022-06-08T18:30:27.1652987Z     [junit] 	at org.openide.filesystems.Repository$3.call(Repository.java:368)
2022-06-08T18:30:27.1653709Z     [junit] 	at org.openide.filesystems.Repository.delayFileSystemAttachImpl(Repository.java:1018)
2022-06-08T18:30:27.1654297Z     [junit] 	at org.openide.filesystems.Repository.getDefault(Repository.java:368)
2022-06-08T18:30:27.1654794Z     [junit] 	at org.netbeans.core.startup.Main.start(Main.java:298)
2022-06-08T18:30:27.1655764Z     [junit] 	at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
2022-06-08T18:30:27.1656203Z     [junit] 	at java.lang.Thread.run(Thread.java:750)
2022-06-08T18:30:27.1656523Z     [junit] 
2022-06-08T18:30:27.1656885Z     [junit] 	at org.netbeans.core.startup.Main.start(Main.java:298)
2022-06-08T18:30:27.1657532Z     [junit] 	at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
2022-06-08T18:30:27.1657948Z     [junit] 	at java.lang.Thread.run(Thread.java:750)

The full log of the run is zipped: fulllog.txt.zip (The quoted part start in line 109186).

The listed stack trace was retrieved using an idea from @jtulach, by creating a fake exception in the Repository constructor, fetching the stacktrace from it and storing it into a public field of that class.

This seems to be a race when initializing the META-INF based services. The NbRepository that is expected, is registered as such a service and thus should be available from the default lookup.

This is the code in master (at time of writing):

https://github.com/apache/netbeans/blob/66e010eb26d449be68b3f0c860d1b5d1e8c375fd/platform/openide.filesystems/src/org/openide/filesystems/Repository.java#L348-L376

and the wrong Repository is created in line 362.

Did this work correctly in an earlier version?

No

Operating System

Linux

JDK

JDK 8 - 19 all show behavior sometimes

Apache NetBeans packaging

Other

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jglickcommented, Jul 6, 2022
0reactions
ebresiecommented, Jul 9, 2022

Is some sort of additional tear down logic needed in some context (after test or before test)to prevent or something to setup this correctly?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tips for Fixing Your Flaky Tests - HackerNoon
Learn how to get better consistency around your automated tests by both fixing your existing flaky tests, and writing better tests going ...
Read more >
Avoiding Flaky Tests - Mattermost Developers
7) Don't assume the test is actually flaky!​​ One danger of having flaky tests is conditioning developers to believe that any unexpected test ......
Read more >
How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >
Test Flakiness - One of the main challenges of automated testing
The tests themselves can introduce flakiness. Typical causes include: Improper initialization or cleanup. Invalid assumptions about the state of ...
Read more >
Handling Flaky Unit Tests in Java | Uber Blog
A flaky test can exhibit flaky behavior independently or be flaky due to external factors, such as runtime environment/infrastructure, or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found