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/10/01 23:45:43 UTC
svn commit: r1628844 - in /db/derby/code/branches/10.10: ./
java/engine/org/apache/derby/impl/io/JarStorageFactory.java
java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java
Author: myrnavl
Date: Wed Oct 1 21:45:43 2014
New Revision: 1628844
URL: http://svn.apache.org/r1628844
Log:
DERBY-4381; Connection to Derby database using jar subprotocol doesn't work if the path has round bracket in it
backport of revision 1602054 and revision 1602232 from trunk.
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/JarStorageFactory.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1602054,1602232
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/JarStorageFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/JarStorageFactory.java?rev=1628844&r1=1628843&r2=1628844&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/JarStorageFactory.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/JarStorageFactory.java Wed Oct 1 21:45:43 2014
@@ -92,7 +92,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/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java?rev=1628844&r1=1628843&r2=1628844&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DBInJarTest.java Wed Oct 1 21:45:43 2014
@@ -101,6 +101,47 @@ public class DBInJarTest extends BaseJDB
assertSQLState("08006", se);
}
}
+
+ /**
+ * Test for fix of DERBY-4381, by testing the connection to a jar
+ * with a closing parenthesis / round bracket in the name.
+ * DERBY-4381 describes the problem when this round bracket
+ * is in the path, but the cause is the same.
+ */
+ public void testConnectParenDBInJar() 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