db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1183503 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
Date Fri, 14 Oct 2011 21:12:33 GMT
Author: kmarsden
Date: Fri Oct 14 21:12:33 2011
New Revision: 1183503

URL: http://svn.apache.org/viewvc?rev=1183503&view=rev
Log:
DERBY-5427  Unauthorized shutdown should not generate thread dump and javacore. AuthenticationTest
dumps over 20 javacores with IBM JVM for normal user errors


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java?rev=1183503&r1=1183502&r2=1183503&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java
Fri Oct 14 21:12:33 2011
@@ -336,7 +336,12 @@ public final class TransactionResourceIm
 			// it was already removed.  all that's left to cleanup is
 			// JDBC objects.
 			if (cm!=null) {
-				boolean isShutdown = cleanupOnError(thrownException, database != null ? database.isActive()
: false);
+			    //diagActive should be passed to cleanupOnError
+			    //only if a session is active, Login errors are a special case where
+			    // the database is active but the session is not.
+				boolean sessionActive = (database != null) && database.isActive() &&

+					!isLoginException(thrownException);
+				boolean isShutdown = cleanupOnError(thrownException, sessionActive);
 				if (checkForShutdown && isShutdown) {
 					// Change the error message to be a known shutdown.
 					thrownException = shutdownDatabaseException();
@@ -368,6 +373,25 @@ public final class TransactionResourceIm
 	}
 
     /**
+     * Determine if the exception thrown is a login exception.
+     * Needed for DERBY-5427 fix to prevent inappropriate thread dumps
+     * and javacores. This exception is special because it is 
+     * SESSION_SEVERITY and database.isActive() is true, but the 
+     * session hasn't started yet,so it is not an actual crash and 
+     * should not report extended diagnostics.
+     * 
+     * @param thrownException
+     * @return true if this is a login failure exception
+     */
+    private boolean isLoginException(Throwable thrownException) {
+       if (thrownException instanceof StandardException) {
+           ((StandardException) thrownException).getSQLState().equals(SQLState.LOGIN_FAILED);
+           return true;
+       }
+       return false;
+    }
+    
+    /**
      * Wrap a <code>Throwable</code> in an <code>SQLException</code>.
      *
      * @param thrownException a <code>Throwable</code>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java?rev=1183503&r1=1183502&r2=1183503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
Fri Oct 14 21:12:33 2011
@@ -172,8 +172,6 @@ public class AuthenticationTest extends 
         Properties sysprops = new Properties();
         sysprops.put("derby.user.system", "admin");
         sysprops.put("derby.user.mickey", "mouse");
-        //Derby-4856,set the property to avoid thread dump and diagnostic info
-        sysprops.put("derby.stream.error.extendedDiagSeverityLevel","50000");
         test = DatabasePropertyTestSetup.builtinAuthentication(test,
             USERS, PASSWORD_SUFFIX);
         test = new DatabasePropertyTestSetup (test, props, true);



Mime
View raw message