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 rh...@apache.org on 2014/03/06 16:48:24 UTC
svn commit: r1574927 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java
testing/org/apache/derbyTesting/functionTests/tests/lang/Test_6496.java
Author: rhillegas
Date: Thu Mar 6 15:48:24 2014
New Revision: 1574927
URL: http://svn.apache.org/r1574927
Log:
DERBY-6496: Fix NPE in loading of the optimizer tracing tool; tests passed cleanly on derby-6496-02-aa-optimizerTracer.diff.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Test_6496.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java?rev=1574927&r1=1574926&r2=1574927&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java Thu Mar 6 15:48:24 2014
@@ -31,7 +31,7 @@ import org.apache.derby.iapi.reference.S
import org.apache.derby.iapi.services.context.ContextService;
import org.apache.derby.iapi.services.i18n.MessageService;
import org.apache.derby.iapi.services.loader.ClassFactory;
-import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.services.loader.ClassFactoryContext;
import org.apache.derby.iapi.sql.compile.OptTrace;
import org.apache.derby.iapi.sql.dictionary.OptionalTool;
@@ -107,8 +107,8 @@ public class OptimizerTracer implemen
String customOptTraceName = configurationParameters[ 1 ];
try {
- CompilerContext cc = (CompilerContext) ContextService.getContext( CompilerContext.CONTEXT_ID );
- ClassFactory classFactory = cc.getClassFactory();
+ ClassFactoryContext cfc = (ClassFactoryContext) ContextService.getContext( ClassFactoryContext.CONTEXT_ID );
+ ClassFactory classFactory = cfc.getClassFactory();
tracer = (OptTrace) classFactory.loadApplicationClass( customOptTraceName ).newInstance();
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Test_6496.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Test_6496.java?rev=1574927&r1=1574926&r2=1574927&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Test_6496.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Test_6496.java Thu Mar 6 15:48:24 2014
@@ -21,24 +21,10 @@
package org.apache.derbyTesting.functionTests.tests.lang;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.DriverManager;
-import java.util.ArrayList;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.derbyTesting.junit.BaseJDBCTestCase;
-import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
-import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.SecurityManagerSetup;
import org.apache.derbyTesting.junit.TestConfiguration;
-import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
-import org.apache.derbyTesting.junit.JDBC;
/**
* <p>
@@ -56,8 +42,11 @@ public class Test_6496 extends Generated
private static final String TEST_DBO = "TEST_DBO";
- private static final String LOAD_TOOL = "call syscs_util.syscs_register_tool( 'databaseMetaData', true )";
- private static final String UNLOAD_TOOL = "call syscs_util.syscs_register_tool( 'databaseMetaData', false )";
+ private static final String LOAD_METADATA_TOOL = "call syscs_util.syscs_register_tool( 'databaseMetaData', true )";
+ private static final String UNLOAD_METADATA_TOOL = "call syscs_util.syscs_register_tool( 'databaseMetaData', false )";
+
+ private static final String LOAD_OPTIMIZER_TOOL = "call syscs_util.syscs_register_tool('optimizerTracing', true, 'custom', 'org.apache.derbyTesting.functionTests.tests.lang.DummyOptTrace')";
+ private static final String UNLOAD_OPTIMIZER_TOOL = "call syscs_util.syscs_register_tool('optimizerTracing', false)";
///////////////////////////////////////////////////////////////////////////////////
//
@@ -105,30 +94,54 @@ public class Test_6496 extends Generated
/**
* <p>
- * Test baseline permissions where no grants are made.
+ * Test that we can load the metadata tool twice without popping an NPE.
* </p>
*/
- public void test_001()
+ public void test_001_metadata()
throws Exception
{
- Connection dboConnection = openUserConnection( TEST_DBO );
+ metadataTester();
+ }
- goodStatement( dboConnection, LOAD_TOOL );
- goodStatement( dboConnection, UNLOAD_TOOL );
+ /**
+ * <p>
+ * Test that we can load the metadata tool twice without popping an NPE.
+ * </p>
+ */
+ public void test_002_metadata()
+ throws Exception
+ {
+ metadataTester();
+ }
+ private void metadataTester() throws Exception
+ {
+ toolTester( LOAD_METADATA_TOOL, UNLOAD_METADATA_TOOL );
}
/**
* <p>
- * Test that a user can grant access to her indexes.
+ * Test that we can load the optimizer tool twice without popping an NPE.
* </p>
*/
- public void test_002()
+ public void test_003_optimizer()
throws Exception
{
- Connection dboConnection = openUserConnection( TEST_DBO );
+ optimizerTester();
+ }
- goodStatement( dboConnection, LOAD_TOOL );
- goodStatement( dboConnection, UNLOAD_TOOL );
+ /**
+ * <p>
+ * Test that we can load the optimizer tool twice without popping an NPE.
+ * </p>
+ */
+ public void test_004_optimizer()
+ throws Exception
+ {
+ optimizerTester();
+ }
+ private void optimizerTester() throws Exception
+ {
+ toolTester( LOAD_OPTIMIZER_TOOL, UNLOAD_OPTIMIZER_TOOL );
}
///////////////////////////////////////////////////////////////////////////////////
@@ -137,4 +150,11 @@ public class Test_6496 extends Generated
//
///////////////////////////////////////////////////////////////////////////////////
+ private void toolTester( String loadTool, String unloadTool ) throws Exception
+ {
+ Connection dboConnection = openUserConnection( TEST_DBO );
+
+ goodStatement( dboConnection, loadTool );
+ goodStatement( dboConnection, unloadTool );
+ }
}