nickylin / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Add jacoco package to the default packages to be deferred #458

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use PowerMock with jacoco offline instrumentation
2. In the test result, one can see errors like :
java.nio.channels.OverlappingFileLockException
        at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166)
        at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068)
        at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:824)
        at java.nio.channels.FileChannel.lock(FileChannel.java:860)
        at org.jacoco.agent.rt.internal_9dd1198.output.FileOutput.openFile(FileOutput.java:69)
        at org.jacoco.agent.rt.internal_9dd1198.output.FileOutput.writeExecutionData(FileOutput.java:53)
        at org.jacoco.agent.rt.internal_9dd1198.Agent.shutdown(Agent.java:143)
        at org.jacoco.agent.rt.internal_9dd1198.Agent$1.run(Agent.java:60)
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
PowerMock 1.5 + Jacoco 0.6.3

Please provide any additional information below.

The problem is that jacoco class 
org.jacoco.agent.rt.internal_9dd1198.output.FileOutput registers a shutdown 
hook in the JVM which should normally execute only once per JVM.
With PowerMock, jacoco classes are loaded several times because of the 
MockClassLoader and thus the shutdownhook is registered and executed several 
times in parallel when the JVM shuts down, leading to the above 
OverlappingFileLockException.

One could add @PowerMockIgnore("org.jacoco.agent.rt.*") to each test class but 
this is annoying.
I see that there's already a list of packages to ignore by default, in 
org.powermock.core.classloader.MockClassLoader.packagesToBeDeferred

Please add "org.jacoco.agent.rt.*" to this list.

Also, it would be nice to be able to add such ignores globally with a system 
property !

Original issue reported on code.google.com by sylvain....@gmail.com on 13 Sep 2013 at 7:43

GoogleCodeExporter commented 9 years ago
Hi, 

Adding ignores globally is a good idea, could you please add this as a separate 
issue?

I've added org.jacoco.agent.rt.* to the list now, please try it out by building 
PowerMock from source (skip tests and javadoc if you're not running Java 6).

Regards,
/Johan

Original comment by johan.ha...@gmail.com on 21 Sep 2013 at 3:51