Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 47272 invoked from network); 9 Jun 2009 10:56:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Jun 2009 10:56:51 -0000 Received: (qmail 86008 invoked by uid 500); 9 Jun 2009 10:57:03 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 85960 invoked by uid 500); 9 Jun 2009 10:57:03 -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 85951 invoked by uid 99); 9 Jun 2009 10:57:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jun 2009 10:57:03 +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; Tue, 09 Jun 2009 10:57:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2DB90238889C; Tue, 9 Jun 2009 10:56:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r782954 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java Date: Tue, 09 Jun 2009 10:56:41 -0000 To: derby-commits@db.apache.org From: kristwaa@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090609105641.2DB90238889C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kristwaa Date: Tue Jun 9 10:56:40 2009 New Revision: 782954 URL: http://svn.apache.org/viewvc?rev=782954&view=rev Log: DERBY-4171: Connections to on-disk db go to in-memory db if in-memory db with same name is booted. If the storage factory isn't the default one (DIRECTORY), don't allow connections without a subsubprotocol specified. Added a test. Patch file: derby-4171-1b-fix.diff Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java?rev=782954&r1=782953&r2=782954&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java Tue Jun 9 10:56:40 2009 @@ -756,6 +756,11 @@ { String protocolLeadIn = getType() + ":"; int colon = name.indexOf( ':'); + // If no subsubprotocol is specified and the storage factory type isn't + // the default one, abort. + if (colon == -1 && !getType().equals(PersistentService.DIRECTORY)) { + return null; + } if( colon > 1) // Subsubprotocols must be at least 2 characters long { if( ! name.startsWith( protocolLeadIn)) Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java?rev=782954&r1=782953&r2=782954&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java Tue Jun 9 10:56:40 2009 @@ -205,6 +205,37 @@ getConnection(); } + /** + * Verify that booting two databases with the same name but with different + * subsubprotocols doesn't result in two connections to the same database. + * + * @throws SQLException if something goes wrong + */ + public void testBootSameDbDifferentSubSubProtocol() + throws SQLException { + final String dbName = "BSDDSSP"; + // Connect to the in-memory database and create a table. + Connection con1 = DriverManager.getConnection( + "jdbc:derby:memory:" + dbName + ";create=true"); + Statement stmt1 = con1.createStatement(); + stmt1.execute("create table t (text varchar(255))"); + stmt1.execute("insert into t values ('Inserted into in-memory db')"); + // Connect to the on-disk database. The table we created in the + // in-memory database shouldn't exist in the on-disk database. + Connection con2 = DriverManager.getConnection( + "jdbc:derby:" + dbName + ";create=true"); + // Table t should not exist. + Statement stmt2 = con2.createStatement(); + try { + stmt2.executeQuery("select * from t"); + fail("Table 't' should not exist"); + } catch (SQLException sqle) { + assertSQLState("42X05", sqle); + } + con2.close(); + con1.close(); + } + public static Test suite() { // Run only in embedded-mode for now. return new SupportFilesSetup(new TestSuite(BasicInMemoryDbTest.class));