You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2014/06/12 03:11:18 UTC

svn commit: r1602054 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/io/JarStorageFactory.java testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java

Author: myrnavl
Date: Thu Jun 12 01:11:17 2014
New Revision: 1602054

URL: http://svn.apache.org/r1602054
Log:
DERBY-4381; Connection to Derby database using jar subprotocol doesn't work if the path has round braket  in it
   adding a test and changing search for matching bracket to be from the last occurrence.
   fix suggested by Rafael Soares (rafael dot enq at gmail dot com) 

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarStorageFactory.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarStorageFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarStorageFactory.java?rev=1602054&r1=1602053&r2=1602054&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarStorageFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarStorageFactory.java Thu Jun 12 01:11:17 2014
@@ -25,6 +25,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.zip.ZipFile;
 
+import org.apache.derby.iapi.services.info.JVMInfo;
 import org.apache.derby.io.StorageFile;
 
 /**
@@ -92,7 +93,7 @@ public class JarStorageFactory extends B
         {
             leftParen = dataDirectory.indexOf( '(', offset);
             if( leftParen >= 0)
-                rightParen = dataDirectory.indexOf( ')', leftParen + 1);
+                rightParen = dataDirectory.lastIndexOf( ')' );
         }
         File jarFile = null;
         if( rightParen > 0)

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java?rev=1602054&r1=1602053&r2=1602054&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java Thu Jun 12 01:11:17 2014
@@ -101,6 +101,46 @@ public class DBInJarTest extends BaseJDB
             assertSQLState("08006", se);
         }
     }
+
+    /**
+     * Test for fix of DERBY-4381, by testing the connection to a jar 
+     * with a param in the name. DERBY-4381 describes the problem when
+     * the param is in the path, but the cause is the same
+     */
+    public void testConnectParamDBInJar() throws SQLException
+    {
+        //      Create database to be jarred up.
+        
+        Connection beforejarconn = DriverManager.getConnection("jdbc:derby:testparjardb;create=true");
+        Statement bjstmt = beforejarconn.createStatement();  
+        bjstmt.executeUpdate("CREATE TABLE PARTAB (I INT)");
+        bjstmt.executeUpdate("INSERT INTO PARTAB VALUES(1)");
+        shutdownDB("jdbc:derby:testparjardb;shutdown=true");
+        Statement stmt = createStatement();
+        
+        stmt.executeUpdate(
+                "CALL CREATEARCHIVE('test)jardb.jar', " +
+                "'testparjardb','testparjardb')");
+        Connection jarconn = DriverManager.getConnection(
+                "jdbc:derby:jar:(test)jardb.jar)testparjardb");
+        Statement s = jarconn.createStatement();
+        
+        // try to read from a table.
+        ResultSet rs = s.executeQuery("SELECT * from PARTAB");
+        JDBC.assertSingleValueResultSet(rs, "1");
+        
+       shutdownDB("jdbc:derby:jar:(test)jardb.jar)testparjardb;shutdown=true");
+              
+       // cleanup databases
+      File jarredpardb = new File(System.getProperty("derby.system.home") 
+              + "/test)jardb.jar");
+      assertTrue("failed deleting " +
+              jarredpardb.getPath(),jarredpardb.delete());
+      removeDirectory(new File(System.getProperty("derby.system.home") 
+              + "/testparjardb" ));
+    }
+    
+    
     
     /**
      * Test various queries that use a hash table that may be spilled to disk