Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JaCoCo 0.8.12 crashes when running tests that pre-interrupt the thread #1836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
asheldon opened this issue Jan 11, 2025 · 0 comments
Open
Labels
type: bug 🐛 Something isn't working

Comments

@asheldon
Copy link

THIS IS A BUG TRACKER ONLY. FOR QUESTIONS PLEASE CHECK FAQ OR USE FORUM:

http://www.jacoco.org/jacoco/trunk/doc/faq.html

https://groups.google.com/forum/?fromgroups=#!forum/jacoco

Please understand that
ISSUES WITHOUT FOLLOWING INFORMATION WILL BE CLOSED WITHOUT COMMENTS!
Thank you for filing a useful bug report!

Steps to reproduce

  • JaCoCo version: 0.8.12
  • Operating system:
  • Tool integration: Ant
  • Complete executable reproducer: TBD
  • Steps: TBD

Unit tests that interrupt threads as part of the setup, prior to accessing classes under test, cause JaCoCo 0.8.12 to crash while loading the class. This was not an issue with earlier JaCoCo 0.7 versions.

A workaround in the tests themselves is to access the class under test prior to interrupting the thread so that JaCoCo can initialize before the thread is interrupted.

@Test(expected=InterruptedException.class) {
        Thread.currentThread().interrupt();
        Foo.sleep(1);
}

public static class Foo {
    public static void sleep(final long millis) throws InterruptedException
    {
        TimeUnit.MILLISECONDS.sleep(millis);
    }
}

Expected behaviour

Unit tests that pass without JaCoCo also pass with JaCoCo.

Actual behaviour

[junit]      Testsuite: com.example.DemoInterruptionFailure
[junit]      java.nio.channels.FileLockInterruptionException
[junit]          at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1091)
[junit]          at java.nio.channels.FileChannel.lock(FileChannel.java:1053)
[junit]          at org.jacoco.agent.rt.internal_aeaf9ab.output.FileOutput.openFile(FileOutput.java:83)
[junit]          at org.jacoco.agent.rt.internal_aeaf9ab.output.FileOutput.startup(FileOutput.java:57)
[junit]          at org.jacoco.agent.rt.internal_aeaf9ab.Agent.startup(Agent.java:129)
[junit]          at org.jacoco.agent.rt.internal_aeaf9ab.Agent.getInstance(Agent.java:54)
[junit]          at org.jacoco.agent.rt.internal_aeaf9ab.Offline.getRuntimeData(Offline.java:39)
[junit]          at org.jacoco.agent.rt.internal_aeaf9ab.Offline.getProbes(Offline.java:60)
[junit]          at com.example.Foo.<clinit>(Foo.java)
[junit]          at com.example.FooTest$1.run(FooTest.java:48)
@asheldon asheldon added the type: bug 🐛 Something isn't working label Jan 11, 2025
@asheldon asheldon changed the title JaCoCo 0.8.12 crashes when running tests that interrupt the thread JaCoCo 0.8.12 crashes when running tests that pre-interrupt the thread Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant