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 8EA9D9F60 for ; Fri, 9 Dec 2011 01:56:51 +0000 (UTC) Received: (qmail 41375 invoked by uid 500); 9 Dec 2011 01:56:51 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 41350 invoked by uid 500); 9 Dec 2011 01:56:51 -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 41343 invoked by uid 99); 9 Dec 2011 01:56:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Dec 2011 01:56:51 +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; Fri, 09 Dec 2011 01:56:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7D212238897F; Fri, 9 Dec 2011 01:56:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1212214 - in /db/derby/code/branches/10.6: ./ java/drda/org/apache/derby/impl/drda/ java/engine/org/apache/derby/impl/io/ java/engine/org/apache/derby/impl/services/monitor/ java/engine/org/apache/derby/io/ java/testing/org/apache/derbyTes... Date: Fri, 09 Dec 2011 01:56:25 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111209015625.7D212238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Fri Dec 9 01:56:24 2011 New Revision: 1212214 URL: http://svn.apache.org/viewvc?rev=1212214&view=rev Log: DERBY-5096 DisconnectException: "Connection was refused because the database DB was not found" when creating db for first time Modified: db/derby/code/branches/10.6/ (props changed) db/derby/code/branches/10.6/java/drda/org/apache/derby/impl/drda/ClientThread.java db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/VFMemoryStorageFactory.java db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java db/derby/code/branches/10.6/java/engine/org/apache/derby/io/StorageFactory.java db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/util/corruptio/CorruptBaseStorageFactory.java Propchange: db/derby/code/branches/10.6/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Dec 9 01:56:24 2011 @@ -1,3 +1,4 @@ /db/derby/code/branches/10.7:1140196 -/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,966393,967201,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1028716,1030043,1033485,1033864,1035164,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1078461,1081455,1097247,1103681,1103718,1136363,1138341,1138444,1141924,1164370 +/db/derby/code/branches/10.8:1209227-1209228,1209284 +/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,966393,967201,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1028716,1030043,1033485,1033864,1035164,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1078461,1081455,1097247,1103681,1103718,1136363,1138341,1138444,1141924,1164370,1203050,1207729,1208775 /db/derby/docs/trunk:954344 Modified: db/derby/code/branches/10.6/java/drda/org/apache/derby/impl/drda/ClientThread.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/drda/org/apache/derby/impl/drda/ClientThread.java?rev=1212214&r1=1212213&r2=1212214&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/drda/org/apache/derby/impl/drda/ClientThread.java (original) +++ db/derby/code/branches/10.6/java/drda/org/apache/derby/impl/drda/ClientThread.java Fri Dec 9 01:56:24 2011 @@ -57,22 +57,15 @@ final class ClientThread extends Thread try { // Check for underlying InterruptedException, // SSLException and IOException - try{ // Check for PrivilegedActionException - - clientSocket = - (Socket) AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws IOException - { - return serverSocket.accept(); - } - } - ); + try { // Check for PrivilegedActionException + clientSocket = + acceptClientWithRetry(); // Server may have been shut down. If so, close this // client socket and break out of the loop. // DERBY-3869 if (parent.getShutdown()) { - clientSocket.close(); + if (clientSocket != null) + clientSocket.close(); return; } @@ -149,6 +142,52 @@ final class ClientThread extends Thread } // end for(;;) }// end run() + + /** + * Perform a server socket accept. Allow three attempts with a one second + * wait between each + * + * @return client socket or null if accept failed. + * + */ + private Socket acceptClientWithRetry() { + return (Socket) AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + for (int trycount = 1; trycount <= 3; trycount++) { + try { + // DERBY-5347 Need to exit if + // accept fails with IOException + // Cannot just aimlessly loop + // writing errors + return serverSocket.accept(); + } catch (IOException acceptE) { + // If not a normal shutdown, + // log and shutdown the server + if (!parent.getShutdown()) { + parent + .consoleExceptionPrintTrace(acceptE); + if (trycount == 3) { + // give up after three tries + parent.directShutdownInternal(); + } else { + // otherwise wait 1 second and retry + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + parent + .consoleExceptionPrintTrace(ie); + } + } + } + } + } + return null; // no socket to return after three tries + } + } + + ); + } } Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java?rev=1212214&r1=1212213&r2=1212214&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java (original) +++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java Fri Dec 9 01:56:24 2011 @@ -111,6 +111,15 @@ abstract class BaseStorageFactory implem } /** + * Set the canonicalName. May need adjustment due to DERBY-5096 + * + * @param name uniquely identifiable name for this database + */ + public void setCanonicalName(String name) { + canonicalName = name; + } + + /** * Construct a StorageFile from a path name. * * @param path The path name of the file Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/VFMemoryStorageFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/VFMemoryStorageFactory.java?rev=1212214&r1=1212213&r2=1212214&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/VFMemoryStorageFactory.java (original) +++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/io/VFMemoryStorageFactory.java Fri Dec 9 01:56:24 2011 @@ -189,6 +189,15 @@ public class VFMemoryStorageFactory } /** + * Set the canonicalName. May need adjustment due to DERBY-5096 + * + * @param name uniquely identifiable name for this database + */ + public void setCanonicalName(String name) { + canonicalName = name; + } + + /** * Returns a handle to the specific storage file. * * @param path the path of the file or directory Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java?rev=1212214&r1=1212213&r2=1212214&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java (original) +++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java Fri Dec 9 01:56:24 2011 @@ -665,6 +665,11 @@ final class StorageFactoryService implem if (serviceDirectory.mkdirs()) { + // DERBY-5096. The storageFactory canonicalName may need to be adjusted + // for casing after the directory is created. Just reset it after making the + // the directory to make sure. + String serviceDirCanonicalPath = serviceDirectory.getCanonicalPath(); + storageFactory.setCanonicalName(serviceDirCanonicalPath); try { return storageFactory.getCanonicalName(); Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/io/StorageFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/io/StorageFactory.java?rev=1212214&r1=1212213&r2=1212214&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/engine/org/apache/derby/io/StorageFactory.java (original) +++ db/derby/code/branches/10.6/java/engine/org/apache/derby/io/StorageFactory.java Fri Dec 9 01:56:24 2011 @@ -231,4 +231,12 @@ public interface StorageFactory */ public StorageFile createTemporaryFile (String prefix, String suffix) throws IOException; + + /** + * Set the canonicalName. May need adjustment due to DERBY-5096 + * + * @param name uniquely identifiable name for this database + */ + public void setCanonicalName(String name); + } Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/util/corruptio/CorruptBaseStorageFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/util/corruptio/CorruptBaseStorageFactory.java?rev=1212214&r1=1212213&r2=1212214&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/util/corruptio/CorruptBaseStorageFactory.java (original) +++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/util/corruptio/CorruptBaseStorageFactory.java Fri Dec 9 01:56:24 2011 @@ -118,6 +118,15 @@ abstract class CorruptBaseStorageFactory } /** + * Set the canonicalName. May need adjustment due to DERBY-5096 + * + * @param name uniquely identifiable name for this database + */ + public void setCanonicalName(String name) { + realStorageFactory.setCanonicalName(name); + } + + /** * Construct a StorageFile from a path name. * * @param path The path name of the file