db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r542446 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: conn/GenericLanguageConnectionContext.java depend/BasicDependencyManager.java
Date Tue, 29 May 2007 07:45:13 GMT
Author: kahatlen
Date: Tue May 29 00:45:11 2007
New Revision: 542446

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

Fix some unsafe calls to initCause() by catching IllegalStateException.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?view=diff&rev=542446&r1=542445&r2=542446
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Tue May 29 00:45:11 2007
@@ -613,8 +613,23 @@
 				dm.invalidateFor(td, DependencyManager.DROP_TABLE, this);
 				tran.dropConglomerate(td.getHeapConglomerateId());
 			} catch (StandardException e) {
-				e.initCause(topLevelStandardException);
-				topLevelStandardException = e;
+				if (topLevelStandardException == null) {
+					// always keep the first exception unchanged
+					topLevelStandardException = e;
+				} else {
+					try {
+						// Try to create a chain of exceptions. If successful,
+						// the current exception is the top-level exception,
+						// and the previous exception the cause of it.
+						e.initCause(topLevelStandardException);
+						topLevelStandardException = e;
+					} catch (IllegalStateException ise) {
+						// initCause() has already been called on e. We don't
+						// expect this to happen, but if it happens, just skip
+						// the current exception from the chain. This is safe
+						// since we always keep the first exception.
+					}
+				}
 			}
 		}
     
@@ -622,8 +637,15 @@
 		try {
 			internalCommit(true);
 		} catch (StandardException e) {
-			e.initCause(topLevelStandardException);
-			topLevelStandardException = e;
+			// do the same chaining as above
+			if (topLevelStandardException == null) {
+				topLevelStandardException = e;
+			} else {
+				try {
+					e.initCause(topLevelStandardException);
+					topLevelStandardException = e;
+				} catch (IllegalStateException ise) { /* ignore */ }
+			}
 		}
 		if (topLevelStandardException != null) throw topLevelStandardException;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java?view=diff&rev=542446&r1=542445&r2=542446
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
Tue May 29 00:45:11 2007
@@ -382,10 +382,18 @@
 					dep.prepareToInvalidate(p, action, lcc);
 				} catch (StandardException sqle) {
 
-					if (noInvalidate != null)
-						sqle.initCause(noInvalidate);
-
-					noInvalidate = sqle;
+					if (noInvalidate == null) {
+						noInvalidate = sqle;
+					} else {
+						try {
+							sqle.initCause(noInvalidate);
+							noInvalidate = sqle;
+						} catch (IllegalStateException ise) {
+							// We weren't able to chain the exceptions. That's
+							// OK, since we always have the first exception we
+							// caught. Just skip the current exception.
+						}
+					}
 				}
 				if (noInvalidate == null) {
 



Mime
View raw message