Skip to content
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

java.nio.channels.OverlappingFileLockException for Jacoco offline #331

Closed
david-wei-wei opened this issue Jul 9, 2015 · 46 comments · Fixed by #1057
Closed

java.nio.channels.OverlappingFileLockException for Jacoco offline #331

david-wei-wei opened this issue Jul 9, 2015 · 46 comments · Fixed by #1057

Comments

@david-wei-wei
Copy link

david-wei-wei commented Jul 9, 2015

Hi, recently I used Jacoco 0.7.2 to test our AppServer, Encountered such a problem:

java.nio.channels.OverlappingFileLockException 
at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) 
at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) 
at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1030) 
at java.nio.channels.FileChannel.lock(FileChannel.java:1053) 
at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.openFile(FileOutput.java:69) 
at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.writeExecutionData(FileOutput.java:53) 
at org.jacoco.agent.rt.internal_e6e56f0.Agent.shutdown(Agent.java:137) 
at org.jacoco.agent.rt.internal_e6e56f0.Agent$1.run(Agent.java:54) 

In Jacoco Offline, are there different threads to synchronisation/write locking for jacoco.exec in one JVM? In order to avoid concurrent writes from different threads running in parallel in one JVM, I changed some code, it can solve our problem temporarily, as below:

private OutputStream openFile() throws IOException {
  final FileOutputStream file = new FileOutputStream(destFile, append);
  int retries = 5;//retries 5 times
  // Avoid concurrent writes from different agents running in parallel:
  for (int t = 0; t < retries; t++)
  try{
      file.getChannel().lock();
      break;
  }catch(OverlappingFileLockException ofe){
      System.out.println("[JACOCO][RT] Got OverlappingFileLockException, re-trying.");
      try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                //ignore
            }
  }
  return file;
 }

Please help to check the issue.

@Godin Godin self-assigned this Jul 9, 2015
@Godin
Copy link
Member

Godin commented Jul 9, 2015

@david-wei-wei Quoting JavaDoc for OverlappingFileLockException - "Unchecked exception thrown when an attempt is made to acquire a lock on a region of a file that overlaps a region already locked by the same Java virtual machine". However in case of online instrumentation single JVM should have only single JaCoCo agent, and in case of offline instrumentation agent isn't needed and I suspect that indeed may interfere, so shouldn't be used. So could you please check those conditions?

@Godin Godin added the feedback pending Further information is requested label Jul 9, 2015
@david-wei-wei
Copy link
Author

david-wei-wei commented Jul 10, 2015

@Godin Thanks for your quick reply.
When I tested some function for Weblogic Server, I instrumented all jars with offline model. When I shutdown Weblogic Server with following command, the exception will occur.
Running command and logs:

./stopWebLogic.sh
Stopping Weblogic Server...
/ade/user1_xx/bootstrap/java/1.8.0-40-25-150213.1.8.0.40.0025/jdk/bin/java -classpath /ade/user1_xx/bootstrap/java/1.8.0-40-25-150213.1.8.0.40.0025/jdk/lib/tools.jar:/scratch/user1/work/mw6775/wlserver/../oracle_common/modules/features/wlst.cam.classpath.jar:/scratch/user1/work/mw6775/wlserver/modules/features/wlst.wls.classpath.jar -Xms256m -Xmx512m -XX:CompileThreshold=8000   -Xverify:none -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader -Djacoco-agent.output=file -Djacoco-agent.destfile=/ade/user1_xx/oracle/work/coverage/coverage.jacoco  -javaagent:/scratch/user1/work/mw6775/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/scratch/user1/work/mw6775/wlserver/server -Dweblogic.home=/scratch/user1/work/mw6775/wlserver/server   -Dweblogic.management.server=t3://xx:7004  weblogic.WLST shutdown-pwdchkServer.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://xx:7004 with userid weblogic ...

The EditMBeanServer is not enabled or not initialized
properly. This might happen if the EditMBeanServer is
disabled via the JMXMBean. Without this MBeanServer you
cannot make any configuration changes. Navigation to the
edit tree will be prohibited.

To view the root cause exception use dumpStack()
Successfully connected to Admin Server "pwdchkServer" that belongs to domain "custom_pwd_dom".

Warning: An insecure protocol was used to connect to the server.
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

Shutting down the server pwdchkServer with force=false while connected to pwdchkServer ...
WLST lost connection to the WebLogic Server that you were connected to.
This may happen if the server was shut down or partitioned.
You will have to re-connect to the server once the server is available.
Disconnected from weblogic server: pwdchkServer
Disconnected from weblogic server:

Exiting WebLogic Scripting Tool.

java.nio.channels.OverlappingFileLockException
        at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
        at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
        at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1030)
        at java.nio.channels.FileChannel.lock(FileChannel.java:1053)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.openFile(FileOutput.java:69)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.writeExecutionData(FileOutput.java:53)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.shutdown(Agent.java:137)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent$1.run(Agent.java:54)
Done
Stopping Derby Server...

@marchof
Copy link
Member

marchof commented Jul 11, 2015

It actually looks like there are two JaCoCo agents involved, maybe in two different versions (otherwise JaCoCo would detect this situation).

@marchof
Copy link
Member

marchof commented Jul 11, 2015

So what would be interesting is the full command line of the running server process.

@david-wei-wei
Copy link
Author

david-wei-wei commented Jul 12, 2015

@marchof @Godin I have dumped the thread stack. It seems that there are two JVM shutdown hooks in a classloader:PolicyClassLoader and a javaagent:DebugPatchAgent.

My test process:

  1. instrument all server jars with Jacoco offline
  2. execute server stopping

The exception will occur during stopping the server.

  1. code changed for org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.java
   private OutputStream openFile() throws IOException {
     FileOutputStream file = new FileOutputStream(this.destFile, this.append);
   
     System.out.println("will lock, thread name:"+Thread.currentThread().getName());
     Thread.currentThread().dumpStack();
   
     file.getChannel().lock();
     return file;
   }
  1. Full command line and logs for stopping server:

command:

/ade/aime1_xx/bootstrap/java/1.8.0-40-25-150213.1.8.0.40.0025/jdk/bin/java -classpath /ade/aime1_xx/bootstrap/java/1.8.0-40-25-150213.1.8.0.40.0025/jdk/lib/tools.jar:/scratch/user1/work/mw6981/wlserver/../oracle_common/modules/features/wlst.cam.classpath.jar:/scratch/user1/work/mw6981/wlserver/modules/features/wlst.wls.classpath.jar -Xms256m -Xmx512m -XX:CompileThreshold=8000   -Xverify:none -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader -Djacoco-agent.output=file -Djacoco-agent.destfile=/ade/user1_xx/oracle/work/coverage/coverage.jacoco  -javaagent:/scratch/user1/work/mw6981/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/scratch/user1/work/mw6981/wlserver/server -Dweblogic.home=/scratch/user1/work/mw6981/wlserver/server   -Dweblogic.management.server=t3://xx:7004  weblogic.WLST shutdown-pwdchkServer.py

key logs:

will lock, thread name:main
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1329)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.openFile(FileOutput.java:51)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.startup(FileOutput.java:30)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.startup(Agent.java:122)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.getInstance(Agent.java:50)
        at org.jacoco.agent.rt.internal_e6e56f0.Offline.<clinit>(Offline.java:31)
        at com.oracle.classloader.PolicyClassLoader.$jacocoInit(PolicyClassLoader.java)
        at com.oracle.classloader.PolicyClassLoader.<clinit>(PolicyClassLoader.java)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at java.lang.SystemClassLoaderAction.run(ClassLoader.java:2205)
        at java.lang.SystemClassLoaderAction.run(ClassLoader.java:2191)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1453)
        at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1433)

will lock, thread name:main
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1329)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.openFile(FileOutput.java:51)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.startup(FileOutput.java:30)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.startup(Agent.java:122)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.getInstance(Agent.java:50)
        at org.jacoco.agent.rt.internal_e6e56f0.Offline.<clinit>(Offline.java:31)
        at weblogic.diagnostics.debug.DebugLogger.$jacocoInit(DebugLogger.java)
        at weblogic.diagnostics.debug.DebugLogger.<clinit>(DebugLogger.java)
        at weblogic.diagnostics.debugpatch.agent.DebugPatchAgent.<clinit>(DebugPatchAgent.java:23)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
...
will lock, thread name:Thread-0
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1329)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.openFile(FileOutput.java:51)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.writeExecutionData(FileOutput.java:34)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.shutdown(Agent.java:137)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent$1.run(Agent.java:54)

will lock, thread name:Thread-3
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1329)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.openFile(FileOutput.java:51)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.writeExecutionData(FileOutput.java:34)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.shutdown(Agent.java:137)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent$1.run(Agent.java:54)

java.nio.channels.OverlappingFileLockException
        at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
        at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
        at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1030)
        at java.nio.channels.FileChannel.lock(FileChannel.java:1053)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.openFile(FileOutput.java:53)
        at org.jacoco.agent.rt.internal_e6e56f0.output.FileOutput.writeExecutionData(FileOutput.java:34)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent.shutdown(Agent.java:137)
        at org.jacoco.agent.rt.internal_e6e56f0.Agent$1.run(Agent.java:54)

@Godin
Copy link
Member

Godin commented Jul 20, 2015

@david-wei-wei As was said earlier - you don't need JaCoCo agent, if you use offline instrumentation. They both register shutdown hook and so interfere.

@david-wei-wei
Copy link
Author

david-wei-wei commented Jul 20, 2015

@Godin I remembered I did't use JaCoCo agent, I only set JaCoCo properties in Java Command: -Djacoco-agent.output=file -Djacoco-agent.destfile=/ade/user1_xx/oracle/work/coverage/coverage.jacoco. Could you help me to check it?

@Godin
Copy link
Member

Godin commented Jul 20, 2015

@david-wei-wei I suspect that debugpatch-agent.jar is a patched JaCoCo agent, no?

@Godin
Copy link
Member

Godin commented Jul 20, 2015

@david-wei-wei Another explanation could be that jar file org.jacoco:org.jacoco.agent:runtime, which is used by offline-instrumented classes is loaded multiple times by different classloaders, causing multiple shutdown hooks. Which could easily be the case for application containers. I would even say that offline instrumentation is tricky to setup compared to online instrumentation with agent, so why not simply use online instrumentation?

@marchof
Copy link
Member

marchof commented Jul 30, 2015

@david-wei-wei Any updates on this issue?

@marchof marchof added declined: invalid ❌ and removed feedback pending Further information is requested labels Oct 2, 2015
@marchof marchof closed this as completed Oct 2, 2015
@evgen48
Copy link

evgen48 commented Apr 14, 2016

Hello, I've ran into exact that problem when creating eclipse RCP application, according to jacoco offline instrumentation, jacocoagent.jar should be in class path, since rcp uses own class loaders for different plugins, I had to add jacocoagent.jar both in classpath of junit tests, and in one of RCP module, and got described problem. Agent based instrumentation also not easily possibly for my project, dueto extensive usage of powermock. So I've tried proposed solution with cycle and several attempts to lock file, in my case there were only 1 collision,

Results :

Tests run: 142, Failures: 0, Errors: 0, Skipped: 10

[JACOCO][RT] Got OverlappingFileLockException, re-trying.
[INFO] All tests passed!

@Godin
Copy link
Member

Godin commented May 25, 2016

@evgen48 could you please provide reproducer? this will greatly increase chances to re-open this ticket and finally make an official fix for it.

@Godin Godin added feedback pending Further information is requested and removed declined: invalid ❌ labels May 25, 2016
@Godin Godin reopened this May 25, 2016
@marchof
Copy link
Member

marchof commented May 25, 2016

@Godin For me the case of @evgen48 is obvious: If you put jacoco into multiple OSGi bundles you get different instances, as every bundle has its own classloader. I would close this ticked as invalid.

We might improve error reporting though: If there would be a reliable way to detect that we have more than one JaCoCo runtime in a JVM we could issue a proper error message.

@Godin
Copy link
Member

Godin commented May 25, 2016

@marchof after careful rereading and your comment indeed case is obvious

And now I'm wondering: ok, offline instrumentation is required because of use of PowerMock, but what if it is combined with agent - I don't remember, if in this case it is still required to have jacocoagent.jar in class path? If not, then isn't it a solution? If yes, maybe we could make this possible as an improvement?

@marchof
Copy link
Member

marchof commented May 25, 2016

@Godin Either add jacocoagent.jar to the classpath or configure the jar as an agent (which also ends on the classpath). In the latter configuration one has to set excludes property accordingly to avoid instrumentation of offline-instrumented classes.

@famod
Copy link

famod commented Jun 5, 2020

FYI: Just stumbled upon this in Quarkus and created an issue there: quarkusio/quarkus#9837

I doubt that Quarkus can/will work around all cases, so any improvement on your side (JaCoCo) is very much appreciated!

@marchof
Copy link
Member

marchof commented Jun 8, 2020

@famod Thanks for the detailed analysis on the Quarkus issue! Do you have specific proposals what we can improve in the JaCoCo side in this situation?

@marchof
Copy link
Member

marchof commented Jun 8, 2020

@famod Here is the version to for testing: https://ci.appveyor.com/project/JaCoCo/jacoco/builds/33396073/artifacts

@famod
Copy link

famod commented Jun 9, 2020

@marchof Thanks, that was quick! Will test that later this week.

To be fair and transparent, me and my team have just decided to evaluate a possible online solution first: quarkusio/quarkus#9837 (comment)

@famod
Copy link

famod commented Jun 14, 2020

@marchof I am having a hard time getting the testing version to work properly in a Maven setup (https://github.com/famod/quarkus-issue-9837).
This was probably a bit naive:

mvn install:install-file -Dfile=jacocoagent.jar -DartifactId=org.jacoco.agent -DgoupId=org.jacoco -Dversion=0.8.6-SNAPSHOT -Dclassifier=runtime

as this yields:

[INFO] Running org.acme.testcoverage.GreetingServiceTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.017 s <<< FAILURE! - in org.acme.testcoverage.GreetingServiceTest
[ERROR] testGreetingService  Time elapsed: 0.01 s  <<< ERROR!
java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_43f5073/Offline
        at org.acme.testcoverage.GreetingServiceTest.testGreetingService(GreetingServiceTest.java:10)
Caused by: java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_43f5073.Offline
        at org.acme.testcoverage.GreetingServiceTest.testGreetingService(GreetingServiceTest.java:10)

I guess the dedepencies of the Maven-Plugin are inconsistent (still on 0.8.5)?
There is one jacocoagent.jar in the zip (the other one is an OSGI-bundle). Which one is it? runtime or the "regular" one? And where is the other one?

Sorry for so many questions but I am a bit lost. Thanks!

@famod
Copy link

famod commented Jun 17, 2020

@marchof ping, thanks!

@Godin
Copy link
Member

Godin commented Jun 17, 2020

@famod

This was probably a bit naive
I guess the dedepencies of the Maven-Plugin are inconsistent

yep, quoting https://www.jacoco.org/jacoco/trunk/doc/faq.html :

Why do I get a NoClassDefFoundError or ClassNotFoundException for class org.jacoco.agent[...]Offline?

If you use offline instrumentation the instrumented classes get a direct dependency on the JaCoCo runtime. Therefore jacocoagent.jar of the same JaCoCo version must be on the classpath and accessible from by the instrumented classes.

For the match between org.jacoco:org.jacoco.core (dependency of jacoco-maven-plugin) and org.jacoco:org.jacoco.agent:runtime

you can try either building from @marchof branch:

git clone git@github.com:jacoco/jacoco.git --branch retry-execfile-lock
cd jacoco
mvn clean install

or try to update dependency of jacoco-maven-plugin - see https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_dependencies_Tag

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.jacoco</groupId>
                        <artifactId>org.jacoco.core</artifactId>
                        <version>0.8.6-SNAPSHOT</version>
                    </dependency>
                </dependencies>

after installing artifacts mentioned in #331 (comment)

mvn install:install-file \
  -Dfile=jacoco-0.8.6.202006080825/lib/jacocoagent.jar \
  -DartifactId=org.jacoco.agent \
  -DgoupId=org.jacoco \
  -Dversion=0.8.6-SNAPSHOT \
  -Dclassifier=runtime

mvn install:install-file \
  -Dfile=jacoco-0.8.6.202006080825/lib/org.jacoco.core-0.8.6.202006080825.jar \
  -DartifactId=org.jacoco.core \
  -DgoupId=org.jacoco \
  -Dversion=0.8.6-SNAPSHOT

Which one is it? runtime or the "regular" one? And where is the other one?

Don't know what you mean by "it", "regular" and "other", but content of ZIP is described in documentation at https://www.jacoco.org/jacoco/trunk/index.html (index.html inside ZIP) and content of Maven repository described at https://www.jacoco.org/jacoco/trunk/doc/repo.html (doc/repo.html inside ZIP), so putting them together:

groupId artifactId classifier inside ZIP description
org.jacoco org.jacoco.agent runtime lib/jacocoagent.jar Agent
org.jacoco org.jacoco.agent lib/org.jacoco.agent-0.8.6.202006080825.jar OSGi Bundle with API to get a local copy of the agent
org.jacoco jacoco-maven-plugin - Plug-in for Maven

@famod
Copy link

famod commented Jun 17, 2020

@Godin Thanks a lot for this very detailed answer!

Don't know what you mean by "it", "regular" and "other"

I was under the impression that there are three agent flavours: the "regular" one (without classifier), the one with the runtime classifier and the OSGi one.

Again, thanks for this clarification!

I'll try building from the branch and will report back.

@famod
Copy link

famod commented Jun 22, 2020

I'll try building from the branch and will report back.

#1057 (comment) 🆗

@famod
Copy link

famod commented Sep 16, 2020

I must say it is rather disappointing that the fix for this is not included in the recently released 0.8.6. The PR is over 3 months old.

@marchof
Copy link
Member

marchof commented Sep 16, 2020

@famod I apologies that this PR did not make it into the release. Please understand this is all spare time work. We prioritized the release because of experimental Java 15 and Java 16 support. Also we didn't want to do a "last minute merge". There will be a release soon, for official Java 15 support, so there is another chance to get this PR in.

@famod
Copy link

famod commented Sep 16, 2020

@marchof ok, thanks for letting me know.

@xtaixe
Copy link

xtaixe commented Oct 13, 2020

Just a +1 on merging this and hopefully getting a release soon, since it's also affecting us and we tested with this branch and the fix works. Thanks.

@silviu-negoita
Copy link

any updates on this? im waiting to be fixed

@xtaixe
Copy link

xtaixe commented Jun 29, 2021

@marchof I just realized today that there was another release and this still didn't make it. Just to set expectations, will this be merged at some point? Can we help in any way? Thanks.

@Godin
Copy link
Member

Godin commented Jun 29, 2021

@xtaixe Here is why we lowered priority of this - in the meantime while we were on Java 16, as far as we can see quarkusio/quarkus#9837 was solved on Quarkus side by quarkusio/quarkus#14311 Isn't it? Or in your case it is not about Quarkus?

@xtaixe
Copy link

xtaixe commented Jun 29, 2021

@Godin that comment mentions why it wasn't added in 0.8.6 but that the actual Java 15 - 16 release (0.8.7) would be an opportunity to get this in.

Our issue is with using Quarkus, but the Quarkus solution won't work for us cause it only works for a specific type of Quarkus tests (plus not sure if it works for Maven multi module projects).

So right now, we are running a patched JaCoCo jar to be able to get coverage properly, so it's going to be a pain to upgrade for every release this is not in... Since this seems to be ready and tested by some people, can it be prioritized now?

@Godin
Copy link
Member

Godin commented Jun 29, 2021

but that the actual Java 15 - 16 release (0.8.7) would be an opportunity to get this in.

As was already said - we saw resolution of corresponding ticket on Quarkus side, but till now no mention of

the Quarkus solution won't work for us cause it only works for a specific type of Quarkus tests

maybe I miss something, but don't see any example of this or any mentions of this anywhere on Quarkus side, while IMO this is valuable information - maybe Quarkus developers can already suggest something for your type of tests or do further improvements, or improve documentation/examples by mentioning known limitations. Anyway thank you for sharing/mentioning this at least here now 👍

Also yes sorry that this opportunity and ticket were overlooked in 0.8.7 - there were many things to do for Kotlin 1.5 and far less spare time.

Since this seems to be ready and tested by some people, can it be prioritized now?

Yes and thank you for the reminder, explanations and testing.

@Godin Godin added this to the 0.8.8 milestone Jun 29, 2021
@Godin Godin added this to Candidates in Current work items via automation Jun 29, 2021
@xtaixe
Copy link

xtaixe commented Jun 29, 2021

Cool. Thanks! Sorry, I see now I didn't understand your first comment about priority properly and you are right it should have been mentioned the Quarkus solution has some caveats... In case it helps or just FYI the Quarkus limitation and suggestion to fallback to the normal plugin is explained here: https://quarkus.io/guides/tests-with-coverage#coverage-for-tests-not-using-quarkustest

Can't wait for the next release! Thanks again.

@famod
Copy link

famod commented Jun 29, 2021

@xtaixe I must say the combination of the quarkus-jacoco extension plus the jacoco-maven-plugin (as described by the article you've linked to) works rather well for us.
Which cases don't work for you?

@xtaixe
Copy link

xtaixe commented Jun 29, 2021

Honestly, I missed that the fallback is supposed to be used in combination with the extension and not as replacement (with the same configuration as before) 🤦🏻... So it's using online instrumentation now, right? @famod if you can confirm everything works also for multi module projects I might try to give it a go and report back IF I find time cause it's not going to be a quick change since we have different reports for different types of tests, so our configuration is a bit complex and relying on offline instrumentation right now...

@famod
Copy link

famod commented Jun 29, 2021

@xtaixe It's all "online" which I consider a big plus.
Multi module should work as well. The Quarkus extension is even merging everything, AFAIK.
How well that merge works with non-Quarkus tests I cannot say yet (we are currently splitting our main backend into modules).

@xtaixe
Copy link

xtaixe commented Jun 29, 2021

I started reviewing our config and things are starting to come back to me (it was hard getting everything working)... For the end to end tests we do (and how they need to be setup) we are still going to need offline instrumentation, so if the maintainers are ok with it, getting this issue fixed in JaCoCo is still the best solution for us to be able to keep the configuration the same for our different coverage reports (just changing a maven profile with some properties), otherwise it's going to get crazy to get every thing working differently in a big-ish multi module project...

@xtaixe
Copy link

xtaixe commented Sep 20, 2021

Just FYI, not all cases currently work on Quarkus: quarkusio/quarkus#18559. So hopefully this can still be prioritized... Thanks.

@eformat
Copy link

eformat commented Dec 16, 2021

+1 to getting this merged. i have been following it for a while.

I have a similiar test case that is fixed with this PR i.e.

using jacoco version 0.8.7 - gives 0% code coverage
using 0.8.8-SNAPSHOT (which has this PR) works OK

Code is here (mvn test) ..
https://github.com/petbattle/pet-battle-api/blob/master/pom.xml

Current work items automation moved this from Candidates to Done Apr 4, 2022
@xtaixe
Copy link

xtaixe commented Apr 5, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

8 participants