Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9453B11FA7 for ; Wed, 27 Aug 2014 08:10:19 +0000 (UTC) Received: (qmail 21133 invoked by uid 500); 27 Aug 2014 08:10:18 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 21102 invoked by uid 500); 27 Aug 2014 08:10:18 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 21093 invoked by uid 99); 27 Aug 2014 08:10:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Aug 2014 08:10:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Aug 2014 08:10:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 147B4238897A; Wed, 27 Aug 2014 08:09:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1620793 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: junit/SecurityManagerSetup.java unitTests/junit/MissingPermissionsTest.policy Date: Wed, 27 Aug 2014 08:09:56 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140827080957.147B4238897A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Wed Aug 27 08:09:56 2014 New Revision: 1620793 URL: http://svn.apache.org/r1620793 Log: DERBY-6715: MissingPermissionsTest fails under JaCoCo Add permissions required by JaCoCo to the custom policy used by the test. Change how SecurityManagerSetup checks for JaCoCo. By using Class.forName() instead of getURL() we avoid the need for calling the privileged getProtectionDomain() method, and the URL of the JaCoCo jar file is not needed. (It is usually OK to call this method without any special permissions granted when the SecurityManagerSetup class is initialized. This is because the SecurityManagerSetup is usually initialized before a SecurityManager has been installed. In this test, however, a subprocess is started with -Djava.security.manager, so a SecurityManager is already in place before the SecurityManagerSetup class is initialized in the subprocess.) Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java?rev=1620793&r1=1620792&r2=1620793&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java Wed Aug 27 08:09:56 2014 @@ -97,11 +97,14 @@ public final class SecurityManagerSetup private static boolean checkIfJacocoIsRunning() { return AccessController.doPrivileged(new PrivilegedAction() { public Boolean run() { - if (getURL("org.jacoco.agent.rt.RT") != null) { - System.setProperty("jacoco.active", ""); - return Boolean.TRUE; + try { + Class.forName("org.jacoco.agent.rt.RT"); + return true; + } catch (ClassNotFoundException e) { + return false; + } catch (LinkageError e) { + return false; } - return Boolean.FALSE; } }); } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy?rev=1620793&r1=1620792&r2=1620793&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy Wed Aug 27 08:09:56 2014 @@ -154,3 +154,9 @@ grant codeBase "${derbyTesting.antjunit} // This permission is needed when running the tests using ant 1.7 permission java.io.FilePermission "${user.dir}${/}*", "write"; }; + +// Grant the required permissions for JaCoCo (code coverage tool). +grant { + permission java.io.FilePermission "${jacoco.active}${user.dir}${/}*", "read, write"; + permission java.lang.RuntimePermission "${jacoco.active}shutdownHooks"; +};