db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r537592 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/error/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/jdk16/ testing/org/apa...
Date Sun, 13 May 2007 14:52:16 GMT
Author: kahatlen
Date: Sun May 13 07:52:15 2007
New Revision: 537592

URL: http://svn.apache.org/viewvc?view=rev&rev=537592
Log:
DERBY-2472 (partial) Use Throwable.initCause() to improve error reporting

Let EmbedSQLException use initCause/getCause instead of getJavaException.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/closed.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java?view=diff&rev=537592&r1=537591&r2=537592
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java Sun
May 13 07:52:15 2007
@@ -466,7 +466,7 @@
 		if (t instanceof EmbedSQLException) {
 			EmbedSQLException csqle = (EmbedSQLException) t;
 			if (csqle.isSimpleWrapper()) {
-				Throwable wrapped = csqle.getJavaException();
+				Throwable wrapped = csqle.getCause();
 				if (wrapped instanceof StandardException)
 					return (StandardException) wrapped;
 			}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java?view=diff&rev=537592&r1=537591&r2=537592
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java Sun
May 13 07:52:15 2007
@@ -43,45 +43,30 @@
 	private String messageId;
 
 	/**
-		Java exception that caused this exception, can be null.
-	*/
-    //Because it's transient, it doesn't get sent over to the client
-    //side and hence the classes which needs to be included in the
-    //client.jar file decreases 5 folds.
-	private transient Throwable javaException;
-
-	/**
 	 * Because SQLException does not have settable fields,
 	 * the caller of the constructor must do message lookup,
 	 * and pass the appropriate values here for message, messageId,
 	 * and next exception.
 	 */
 	EmbedSQLException(String message, String messageId,
-		SQLException nextException, int severity, Object[] args) {
+		SQLException nextException, int severity, Throwable t, Object[] args) {
 
 		super(message, StandardException.getSQLStateFromIdentifier(messageId), severity);
 		this.messageId = messageId;
 		arguments = args;
 		if (nextException !=null)
 			this.setNextException(nextException);
-	}
 
-	public EmbedSQLException(String message, String messageId,
-		SQLException nextException, int severity, Throwable t, Object[] args) {
+		// if no cause has been specified, let nextException be the cause (this
+		// improves error reporting since the cause is included in the output
+		// from printStackTrace())
+		if (t == null) {
+			t = nextException;
+		}
 
-		super(message, StandardException.getSQLStateFromIdentifier(messageId), severity);
-		this.messageId = messageId;
-		arguments = args;
-		if (nextException !=null)
-			this.setNextException(nextException);
 		if (t != null) {
-			javaException = t;
-			setStackTrace(t.getStackTrace());
+			initCause(t);
 		}
-	}
-    
-	public Throwable getJavaException() {
-		return javaException;
 	}
 
 	public String getMessageId() {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/closed.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/closed.out?view=diff&rev=537592&r1=537591&r2=537592
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/closed.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/closed.out
Sun May 13 07:52:15 2007
@@ -13,12 +13,14 @@
 ERROR 08003: No current connection.
 Test database shutdown ...
 java.sql.SQLException: Database 'wombat' shutdown.
+Caused by: ERROR 08006: Database 'wombat' shutdown.
 CALL sleep(10000) - 38000, 38000 -- InterruptedException, XJ001 -- InterruptedException
 LOCK TABLE CLOSED.LOCKME IN EXCLUSIVE MODE - 08006, 08006 -- Database 'wombat' shutdown.
 ERROR 08006: Database 'wombat' shutdown.
 Shutdown test completed.
 Test system shutdown ...
 java.sql.SQLException: Database 'wombat' shutdown.
+Caused by: ERROR 08006: Database 'wombat' shutdown.
 CALL sleep(10000) - 38000, 38000 -- InterruptedException, XJ001 -- InterruptedException
 LOCK TABLE CLOSED.LOCKME IN EXCLUSIVE MODE - 08006, 08006 -- Database 'wombat' shutdown.
 ERROR XJ015: Derby system shutdown.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out?view=diff&rev=537592&r1=537591&r2=537592
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out
Sun May 13 07:52:15 2007
@@ -14,6 +14,7 @@
 Test database shutdown ...
 java.sql.SQLException: Database 'wombat' shutdown.
 Caused by: java.sql.SQLException: Database 'wombat' shutdown.
+Caused by: ERROR 08006: Database 'wombat' shutdown.
 CALL sleep(10000) - 38000, 38000 -- InterruptedException, XJ001 -- InterruptedException
 LOCK TABLE CLOSED.LOCKME IN EXCLUSIVE MODE - 08006, 08006 -- Database 'wombat' shutdown.
 ERROR 08006: Database 'wombat' shutdown.
@@ -21,6 +22,7 @@
 Test system shutdown ...
 java.sql.SQLException: Database 'wombat' shutdown.
 Caused by: java.sql.SQLException: Database 'wombat' shutdown.
+Caused by: ERROR 08006: Database 'wombat' shutdown.
 CALL sleep(10000) - 38000, 38000 -- InterruptedException, XJ001 -- InterruptedException
 LOCK TABLE CLOSED.LOCKME IN EXCLUSIVE MODE - 08006, 08006 -- Database 'wombat' shutdown.
 ERROR XJ015: Derby system shutdown.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java?view=diff&rev=537592&r1=537591&r2=537592
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java
Sun May 13 07:52:15 2007
@@ -1152,7 +1152,7 @@
         Throwable cause = getLastSQLException(sqle).getCause();
         assertTrue("Exception not an EmbedSQLException",
                    cause instanceof EmbedSQLException);
-        cause = ((EmbedSQLException)cause).getJavaException();
+        cause = cause.getCause();
         assertTrue("Exception not a DerbyIOException",
                    cause instanceof DerbyIOException);
         DerbyIOException dioe = (DerbyIOException)cause;



Mime
View raw message