Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D80D10701 for ; Tue, 4 Mar 2014 08:33:31 +0000 (UTC) Received: (qmail 28709 invoked by uid 500); 4 Mar 2014 08:33:31 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 28653 invoked by uid 500); 4 Mar 2014 08:33:26 -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 28548 invoked by uid 99); 4 Mar 2014 08:33:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2014 08:33:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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, 04 Mar 2014 08:33:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8A0B123889BB; Tue, 4 Mar 2014 08:33:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1573934 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc: EmbedConnection.java EmbedResultSet.java TransactionResourceImpl.java Util.java Date: Tue, 04 Mar 2014 08:33:00 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140304083300.8A0B123889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Tue Mar 4 08:32:59 2014 New Revision: 1573934 URL: http://svn.apache.org/r1573934 Log: DERBY-6488: Get rid of the EmbedSQLException class Remove the newEmbedSQLException methods, since they don't produce EmbedSQLExceptions anymore, and use the SQLExceptionFactory methods instead. Add a Throwable parameter to seeNextException() so that the root cause will be shown when printStackTrace() is called on the top-level exception. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=1573934&r1=1573933&r2=1573934&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Tue Mar 4 08:32:59 2014 @@ -2645,8 +2645,7 @@ public class EmbedConnection implements } catch (StandardException mse) { throw Util.seeNextException(SQLState.CREATE_DATABASE_FAILED, - new Object[] { dbname }, - handleException(mse)); + handleException(mse), mse, dbname); } // clear these values as some modules hang onto @@ -2840,8 +2839,8 @@ public class EmbedConnection implements nse = Util.generateCsSQLException(mse); throw Util.seeNextException(SQLState.BOOT_DATABASE_FAILED, - new Object[] { dbname, - (Object) this.getClass().getClassLoader() }, nse); + nse, (ne == null ? mse : ne), + dbname, getClass().getClassLoader()); } // If database exists, getDatabase() will return the database object. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=1573934&r1=1573933&r2=1573934&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Tue Mar 4 08:32:59 2014 @@ -4784,12 +4784,8 @@ public class EmbedResultSet extends Conn private void checkScrollCursor(String methodName) throws SQLException { checkIfClosed(methodName); if (stmt.getResultSetType() == java.sql.ResultSet.TYPE_FORWARD_ONLY) - throw Util - .newEmbedSQLException( - SQLState.NOT_ON_FORWARD_ONLY_CURSOR, - new Object[] { methodName }, - StandardException - .getSeverityFromIdentifier(SQLState.NOT_ON_FORWARD_ONLY_CURSOR)); + throw Util.generateCsSQLException( + SQLState.NOT_ON_FORWARD_ONLY_CURSOR, methodName); } private void checkUpdatableCursor(String operation) throws SQLException { 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=1573934&r1=1573933&r2=1573934&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 Tue Mar 4 08:32:59 2014 @@ -429,7 +429,8 @@ public final class TransactionResourceIm // chain. Therefore, call wrapInSQLException() recursively to // convert the cause chain into a chain of SQLExceptions. return Util.seeNextException(se.getMessageId(), - se.getArguments(), wrapInSQLException(se.getCause())); + wrapInSQLException(se.getCause()), se.getCause(), + se.getArguments()); } // thrownException is a Java exception Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?rev=1573934&r1=1573933&r2=1573934&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Tue Mar 4 08:32:59 2014 @@ -124,35 +124,6 @@ public abstract class Util { errorStringBuilder.reset(); } - - /** - * This looks up the message and sqlstate values and calls - * the SQLExceptionFactory method to generate - * the appropriate exception off of them. - */ - - private static SQLException newEmbedSQLException(String messageId, - Object[] args, SQLException next, int severity, Throwable t) { - String message = MessageService.getTextMessage(messageId, args); - return ExceptionFactory.getInstance().getSQLException( - message, messageId, next, severity, t, args); - } - - public static SQLException newEmbedSQLException(String messageId, - Object[] args, int severity) { - return newEmbedSQLException(messageId, args, (SQLException) null, severity, (Throwable) null); - } - - private static SQLException newEmbedSQLException(String messageId, - Object[] args, int severity, Throwable t) { - return newEmbedSQLException(messageId,args, (SQLException) null, severity, t); - } - - private static SQLException newEmbedSQLException( - String messageId, int severity) { - return newEmbedSQLException(messageId, (Object[]) null, (SQLException) null, severity, (Throwable) null); - } - // class interface @@ -243,22 +214,19 @@ public abstract class Util { ** Its parameters are specific to its message. ** These will throw SQLException when the message repository ** cannot be located. - ** Note that these methods call the static method newEmbedSQLException, + ** Note that these methods use the SQL exception factory, ** they don't directly do a new Util. */ public static SQLException generateCsSQLException( String error, Object... args) { - return newEmbedSQLException(error, - args, - StandardException.getSeverityFromIdentifier(error)); + return generateCsSQLException(error, null, args); } static SQLException generateCsSQLException( String error, Throwable t, Object... args) { - return newEmbedSQLException(error, - args, - StandardException.getSeverityFromIdentifier(error), t); + return ExceptionFactory.getInstance().getSQLException( + error, (SQLException) null, t, args); } public static SQLException generateCsSQLException(StandardException se) { @@ -268,8 +236,7 @@ public abstract class Util { } public static SQLException noCurrentConnection() { - return newEmbedSQLException(SQLState.NO_CURRENT_CONNECTION, - StandardException.getSeverityFromIdentifier(SQLState.NO_CURRENT_CONNECTION)); + return generateCsSQLException(SQLState.NO_CURRENT_CONNECTION); } /** @@ -278,14 +245,15 @@ public abstract class Util { * setNextException(). * * @param messageId message id + * @param next the next SQLException, possibly null + * @param cause the underlying exception, possibly null * @param args the arguments to the message creation - * @param next the next SQLException * @return an SQLException wrapping another SQLException */ - static SQLException seeNextException(String messageId, Object[] args, - SQLException next) { - return newEmbedSQLException(messageId, args, next, - StandardException.getSeverityFromIdentifier(messageId), null); + static SQLException seeNextException(String messageId, SQLException next, + Throwable cause, Object... args) { + return ExceptionFactory.getInstance().getSQLException( + messageId, next, cause, args); } public static SQLException javaException(Throwable t) { @@ -305,9 +273,9 @@ public abstract class Util { next = javaException(cause); } } - SQLException result = newEmbedSQLException(SQLState.JAVA_EXCEPTION, - new Object[] {name, msg}, next, - ExceptionSeverity.NO_APPLICABLE_SEVERITY, t); + + SQLException result = seeNextException( + SQLState.JAVA_EXCEPTION, next, t, name, msg); if ( result.getErrorCode() >= logSeverityLevel ) { logSQLException( result ); } @@ -316,8 +284,8 @@ public abstract class Util { public static SQLException policyNotReloaded( Throwable t ) { - return newEmbedSQLException(SQLState.POLICY_NOT_RELOADED, new Object[] { t.getMessage() }, - StandardException.getSeverityFromIdentifier(SQLState.POLICY_NOT_RELOADED), t); + return generateCsSQLException( + SQLState.POLICY_NOT_RELOADED, t, t.getMessage()); } public static SQLException notImplemented() { @@ -326,10 +294,7 @@ public abstract class Util { } public static SQLException notImplemented(String feature) { - - return newEmbedSQLException(SQLState.NOT_IMPLEMENTED, - new Object[] {feature}, - StandardException.getSeverityFromIdentifier(SQLState.NOT_IMPLEMENTED)); + return generateCsSQLException(SQLState.NOT_IMPLEMENTED, feature); } static SQLException setStreamFailure(IOException e) { @@ -342,9 +307,8 @@ public abstract class Util { } static SQLException typeMisMatch(int targetSQLType) { - return newEmbedSQLException(SQLState.TYPE_MISMATCH, - new Object[] {typeName(targetSQLType)}, - StandardException.getSeverityFromIdentifier(SQLState.TYPE_MISMATCH)); + return generateCsSQLException( + SQLState.TYPE_MISMATCH, typeName(targetSQLType)); } /** Create the correct BatchUpdateException depending on whether this is Java 8 or lower */