Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 69635 invoked from network); 10 Apr 2009 17:38:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Apr 2009 17:38:44 -0000 Received: (qmail 63286 invoked by uid 500); 10 Apr 2009 17:38:44 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 63264 invoked by uid 500); 10 Apr 2009 17:38:44 -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 63255 invoked by uid 99); 10 Apr 2009 17:38:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Apr 2009 17:38:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Fri, 10 Apr 2009 17:38:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6771923888E6; Fri, 10 Apr 2009 17:38:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r763987 - in /db/derby/code/branches/10.5/java: drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ testing/org/apache/derbyTesting/functionTests/util/ Date: Fri, 10 Apr 2009 17:38:23 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090410173823.6771923888E6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Fri Apr 10 17:38:22 2009 New Revision: 763987 URL: http://svn.apache.org/viewvc?rev=763987&view=rev Log: DERBY-4128 Failure in ServerPropertiesTest due to java.security.AccessControlException on the server side, in 10.4 to 10.5.1. soft upgrade mode Modified: db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/DssTrace.java db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.policy db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy Modified: db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/DssTrace.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/DssTrace.java?rev=763987&r1=763986&r2=763987&view=diff ============================================================================== --- db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/DssTrace.java (original) +++ db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/DssTrace.java Fri Apr 10 17:38:22 2009 @@ -21,6 +21,7 @@ package org.apache.derby.impl.drda; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.security.AccessController; @@ -173,33 +174,59 @@ synchronized (comBufferSync) { // Only start the trace if it is off. if (comBufferTraceOn == false) { - try { - // Attempt to make the trace directory if it does not exist. - // If we can't create the directory the exception will occur - // when trying to create the trace file. - final File traceDirectory = new File(fileName).getParentFile(); - if (traceDirectory != null) { - AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - traceDirectory.mkdirs(); - return null; - } - }); - - } - // The writer will be buffered for effeciency. - comBufferWriter = ((PrintWriter)AccessController.doPrivileged( + // Make up to two attempts to create the trace file. + // First just try to make it. Then if we get a FileNotFoundException + // try making the directory and then retry the create. + // We don't try making the directory first because it would require + // extra permissions if the directory already exists. DERBY-4128 + for (int attempt=0; attempt <2; attempt++) { + try { + // The writer will be buffered for effeciency. + comBufferWriter = ((PrintWriter)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws SecurityException, IOException { return new PrintWriter (new java.io.BufferedWriter (new java.io.FileWriter (fileName), 4096)); } })); - } catch (PrivilegedActionException pae) { - throw pae.getException(); - - } - + // If we successfully made the file. break out here and don't retry + break; + } catch (PrivilegedActionException pae) { + Exception e = pae.getException(); + // If we got a FileNotFoundException on the first attempt, + // it is likely that the directory did not exist. + //We will try to make it. + if (attempt == 0 && (e instanceof FileNotFoundException)) { + final File traceDirectory = new File(fileName).getParentFile(); + if (traceDirectory != null) { + AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + // DERBY-4128: First try to create the + // directory with mkdir(), as that doesn't + // require read permission for the parent + // directory. It will only succeed if the + // parent directory exists. If mkdir() + // fails, retry with mkdirs(), which will + // create the parent directories as needed, + // but which also requires that read + // permission for the parent directory + // has been granted. + boolean created = traceDirectory.mkdir(); + if (!created) { + traceDirectory.mkdirs(); + } + return null; + } + }); + + } + } else { + // This is our second attempt or we got some other exception besides + // FileNotFoundException. Just throw the exception. + throw e; + } + } + } // Turn on the trace flag. comBufferTraceOn = true; // initialize the codepoint name table if it is null. Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.policy URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.policy?rev=763987&r1=763986&r2=763987&view=diff ============================================================================== --- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.policy (original) +++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.policy Fri Apr 10 17:38:22 2009 @@ -98,8 +98,8 @@ permission java.net.SocketPermission "${derbyTesting.serverhost}", "accept,connect"; // For testPropertiesAfterConnection and testPropertiesTraceOn - permission java.io.FilePermission "${derby.system.home}", "read"; permission java.io.FilePermission "${derby.system.home}${/}-", "write"; + }; // Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy?rev=763987&r1=763986&r2=763987&view=diff ============================================================================== --- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy (original) +++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy Fri Apr 10 17:38:22 2009 @@ -93,8 +93,7 @@ permission java.net.SocketPermission "${derbyTesting.clienthost}", "accept,connect"; permission java.net.SocketPermission "${derbyTesting.serverhost}", "accept,connect"; //tracing testing. NetworkServerControlApiTest - permission java.io.FilePermission "${derby.system.home}", "read"; - permission java.io.FilePermission "${derby.system.home}${/}-", "read,write"; + permission java.io.FilePermission "${derby.system.home}${/}-", "write"; }; // Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy?rev=763987&r1=763986&r2=763987&view=diff ============================================================================== --- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy (original) +++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy Fri Apr 10 17:38:22 2009 @@ -98,7 +98,6 @@ permission java.net.SocketPermission "${derbyTesting.serverhost}", "accept,connect"; // for testToggleTrace: - permission java.io.FilePermission "${derby.system.home}", "read,write"; permission java.io.FilePermission "${derby.system.home}${/}-", "write"; }; Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=763987&r1=763986&r2=763987&view=diff ============================================================================== --- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy (original) +++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy Fri Apr 10 17:38:22 2009 @@ -142,8 +142,8 @@ permission java.net.SocketPermission "${derbyTesting.clienthost}", "accept,connect"; permission java.net.SocketPermission "${derbyTesting.serverhost}", "accept,connect"; // Need to be able to write to trace file for NetworkServerControlApiTest + permission java.io.FilePermission "${user.dir}${/}system${/}trace", "write"; permission java.io.FilePermission "${user.dir}${/}system${/}trace${/}-", "write"; - permission java.io.FilePermission "${user.dir}${/}system${/}trace", "read,write"; // Needed for NetworkServerMBean access (see JMX section above) permission org.apache.derby.security.SystemPermission "server", "control,monitor";