[
https://issues.apache.org/jira/browse/DERBY-6715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen updated DERBY-6715:
--------------------------------------
Attachment: d6715-1a.diff
There are two reasons why the test fails under JaCoCo:
1) The custom policy file used by the testModifyThreadGroup test case does not
include the extra permissions needed by JaCoCo.
2) SecurityManagerSetup.checkIfJacocoIsRunning() fails when it's called during
initialization of the SecurityManagerSetup class, because it doesn't have
RuntimePermission("getProtectionDomain"). The permission is not usually needed
when the class is initialized, because the security manager is installed by
SecurityManagerSetup after the class has been initialized. The reason why it's
needed here, is that the test starts JUnit in a subprocess with the
-Djava.security.manager flag so that the security manager is already installed
when SecurityManagerSetup is initialized in the subprocess.
Patch [^d6715-1a.diff] fixes both of these problems.
#1 is fixed by adding extra permissions to the custom policy file if JaCoCo is
enabled.
#2 is fixed by changing how SecurityManagerSetup checks for the existence of
JaCoCo. Instead of calling getURL() on one of the JaCoCo classes, it now only
calls Class.forName() to check if the class is present. Class.forName() doesn't
require RuntimePermission("getProtectionDomain"), and the URL isn't needed.
(An alternative fix for #2 would be to grant
RuntimePermission("getProtectionDomain") to derbyTesting.jar in the custom
policy file.)
> MissingPermissionsTest fails under JaCoCo
> -----------------------------------------
>
> Key: DERBY-6715
> URL: https://issues.apache.org/jira/browse/DERBY-6715
> Project: Derby
> Issue Type: Bug
> Components: Test
> Affects Versions: 10.12.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Attachments: d6715-1a.diff
>
>
> MissingPermissionsTest has started failing in the [code coverage
> tests|https://builds.apache.org/job/Derby-JaCoCo/] lately.
> {noformat}
> subprocess run failed: :Spawned MPT exitCode=134
> STDERR:
> java.security.AccessControlException: access denied ("java.io.FilePermission"
> "/home/jenkins/jenkins-slave/workspace/Derby-JaCoCo/trunk/junit_20140825_1759"
> "read")
> at
> java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
> at
> java.security.AccessController.checkPermission(AccessController.java:559)
> at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
> at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
> at java.io.File.exists(File.java:770)
> at java.io.File.mkdirs(File.java:1263)
> at
> org.jacoco.agent.rt.internal_9dd1198.output.FileOutput.startup(FileOutput.java:46)
> at org.jacoco.agent.rt.internal_9dd1198.Agent.startup(Agent.java:126)
> at org.jacoco.agent.rt.internal_9dd1198.Agent.getInstance(Agent.java:56)
> at org.jacoco.agent.rt.internal_9dd1198.PreMain.premain(PreMain.java:45)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)
> at
> sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)
> Exception in thread "main" java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)
> at
> sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)
> Caused by: java.security.AccessControlException: access denied
> ("java.lang.RuntimePermission" "shutdownHooks")
> at
> java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
> at
> java.security.AccessController.checkPermission(AccessController.java:559)
> at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
> at java.lang.Runtime.addShutdownHook(Runtime.java:209)
> at org.jacoco.agent.rt.internal_9dd1198.Agent.getInstance(Agent.java:57)
> at org.jacoco.agent.rt.internal_9dd1198.PreMain.premain(PreMain.java:45)
> ... 6 more
> STDOUT:
> FATAL ERROR in native method: processing of -javaagent failed
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)