You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2011/03/08 22:19:17 UTC

svn commit: r1079548 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit: NetworkServerTestSetup.java SpawnedProcess.java

Author: kmarsden
Date: Tue Mar  8 21:19:17 2011
New Revision: 1079548

URL: http://svn.apache.org/viewvc?rev=1079548&view=rev
Log:
DERBY-4319 hang in suites.all with ibm 1.5 on AIX after ttestDefaultProperties

Make sure spawned network server process is destroyed if the hang occurs on SpawnedProcess.complete(). This does not address the core reason for the hang which is still not well understood and currently does not reproduce on the aix machine with the problem. DERBY-4319 will stay open while we wait for the problem to reappear.




Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SpawnedProcess.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java?rev=1079548&r1=1079547&r2=1079548&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java Tue Mar  8 21:19:17 2011
@@ -389,7 +389,7 @@ final public class NetworkServerTestSetu
                 // Destroy the process if a failed shutdown
                 // to avoid hangs running tests as the complete()
                 // waits for the process to complete.
-                spawnedServer.complete(failedShutdown != null);
+                spawnedServer.complete(failedShutdown != null, getWaitTime());
                 spawnedServer = null;
             }
             

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SpawnedProcess.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SpawnedProcess.java?rev=1079548&r1=1079547&r2=1079548&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SpawnedProcess.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SpawnedProcess.java Tue Mar  8 21:19:17 2011
@@ -126,15 +126,47 @@ public final class SpawnedProcess {
        return sb.toString();
     }
 
+    /*Complete the method
+     * @param destroy true to destroy it, false to wait indefinitely to complete 
+     */
+    public int complete(boolean destroy) throws InterruptedException, IOException {
+        return complete(destroy, -1L);
+    }
+    
     /**
      * Complete the method.
-     * @param destroy True to destroy it, false to wait for it to complete.
+     * @param destroy True to destroy it, false to wait for it to complete 
+     * based on timeout.
+     *  
+     * @param timeout milliseconds to wait until finished or else destroy.
+     * -1 don't timeout
+     *  
      */
-    public int complete(boolean destroy) throws InterruptedException, IOException {
+    public int complete(boolean destroy, long timeout) throws InterruptedException, IOException {
+        int exitCode;
+        if (timeout >= 0 ) {
+            long totalwait = -1;
+            while (totalwait < timeout) {
+               try  { 
+               exitCode = javaProcess.exitValue();
+               //if no exception thrown, exited normally
+               destroy = false;
+               break;
+               }catch (IllegalThreadStateException ite) {
+                   if (totalwait >= timeout) {
+                       destroy = true;
+                       break;
+                   } else {
+                       totalwait += 1000;
+                       Thread.sleep(1000);
+                   }
+               }
+            }
+    	}
         if (destroy)
             javaProcess.destroy();
 
-        int exitCode = javaProcess.waitFor();
+        exitCode = javaProcess.waitFor();
         Thread.sleep(500);
         synchronized (this) {