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 dj...@apache.org on 2006/03/03 01:05:18 UTC

svn commit: r382578 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java

Author: djd
Date: Thu Mar  2 16:05:17 2006
New Revision: 382578

URL: http://svn.apache.org/viewcvs?rev=382578&view=rev
Log:
DERBY-444 Try to isolate out of memory exceptions from the engine in the ConnectionHandling test.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java?rev=382578&r1=382577&r2=382578&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java Thu Mar  2 16:05:17 2006
@@ -43,30 +43,38 @@
         
         ArrayList list = new ArrayList();
         
-        try {
-            while (true)
-            {
-                Connection c = DriverManager.getConnection("jdbc:derby:wombat");
-                list.add(c);
-                if ((list.size() % 1000) == 0) {
-                    System.out.println(list.size() + " connections ...");
-                    System.out.println("FREE " + Runtime.getRuntime().freeMemory());
+        while (true) {
+            Connection c;
+            try {
+
+                c = DriverManager.getConnection("jdbc:derby:wombat");
+            } catch (SQLException e) {
+                if ("08004".equals(e.getSQLState()))
+                    System.out.println("FIRST OOME: " + e.getSQLState() + " "
+                            + e.getMessage());
+                else {
+                    System.out.println("UNKNOWN ERROR " + e.getSQLState() + " "
+                            + e.getMessage());
+                    e.printStackTrace(System.out);
                 }
+                break;
+            } catch (Throwable t) {
+                System.out.println("UNKNOWN ERROR " + t);
+                t.printStackTrace(System.out);
+                break;
             }
-        } catch (SQLException e) {
-            if ("08004".equals(e.getSQLState()))
-                System.out.println("FIRST OOME: " + e.getSQLState() + " " + e.getMessage());
-            else {
-                System.out.println("UNKNOWN ERROR " + e.getSQLState() + " " + e.getMessage());
-                e.printStackTrace(System.out);
+            list.add(c);
+            if ((list.size() % 1000) == 0) {
+                System.out.println(list.size() + " connections ...");
+                System.out.println("FREE " + Runtime.getRuntime().freeMemory());
             }
-        } catch (Throwable t) {
-            System.out.println("UNKNOWN ERROR " + t);
-            t.printStackTrace(System.out);
         }
+
         
         System.out.println(list.size() + " successful connections");
         
+        list.ensureCapacity(list.size() + 500);
+        
         // try to make 500 more connection requests.
         int fail_sqloome = 0;
         int fail_sql = 0;
@@ -75,12 +83,9 @@
         for (int i = 0; i < 500; i++)
         {
             try {
-                while (true)
-                {
-                    Connection c = DriverManager.getConnection("jdbc:derby:wombat");
-                    list.add(c);
-                    ok++;
-                }
+                  Connection c = DriverManager.getConnection("jdbc:derby:wombat");
+                  list.add(c);
+                  ok++;
             } catch (SQLException e) {
                 if ("08004".equals(e.getSQLState()))
                     fail_sqloome++;