db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1412042 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorMessageTest.java
Date Wed, 21 Nov 2012 10:28:48 GMT
Author: kahatlen
Date: Wed Nov 21 10:28:48 2012
New Revision: 1412042

URL: http://svn.apache.org/viewvc?rev=1412042&view=rev
Log:
DERBY-6001: ErrorMessageTest assert failure: Only one of the waiters should be aborted

Improve diagnostics. Print stack traces to the log if both threads fail.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorMessageTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorMessageTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorMessageTest.java?rev=1412042&r1=1412041&r2=1412042&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorMessageTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorMessageTest.java
Wed Nov 21 10:28:48 2012
@@ -200,17 +200,19 @@ public class ErrorMessageTest extends Ba
         // Check that exactly one of the threads failed, and that the failure
         // was caused by a deadlock. It is not deterministic which of the two
         // threads will be terminated.
-        String msg;
-        if (holder[0] != null) {
-            assertSQLState("Not a deadlock", "40001", holder[0]);
-            assertNull("Only one of the waiters should be aborted", holder[1]);
-            msg = holder[0].getMessage();
-        } else {
-            assertSQLState("Not a deadlock", "40001", holder[1]);
-            msg = holder[1].getMessage();
+        assertFalse("No deadlock", holder[0] == null && holder[1] == null);
+        if (holder[0] != null && holder[1] != null) {
+            // Both threads failed. Print some more information to the log
+            // so we can see what's going on.
+            printStackTrace(holder[0]);
+            printStackTrace(holder[1]);
+            fail("Only one of the waiters should be aborted");
         }
 
-        String[] lines = msg.split("\n");
+        SQLException deadlock = holder[0] == null ? holder[1] : holder[0];
+        assertSQLState("Not a deadlock", "40001", deadlock);
+
+        String[] lines = deadlock.getMessage().split("\n");
         assertEquals("Unexpected number of lines in message", 8, lines.length);
 
         Pattern[] patterns = new Pattern[] {



Mime
View raw message