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 2007/02/13 17:54:46 UTC

svn commit: r507093 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java

Author: djd
Date: Tue Feb 13 08:54:45 2007
New Revision: 507093

URL: http://svn.apache.org/viewvc?view=rev&rev=507093
Log:
DERBY-2318 Cleaned up the code that gets the stack trace, but didn't change anything that would change the behaviour.
I don't see any failure on WEME 6.1 though.

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java?view=diff&rev=507093&r1=507092&r2=507093
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java Tue Feb 13 08:54:45 2007
@@ -21,6 +21,13 @@
 
 package org.apache.derbyTesting.functionTests.tests.lang;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStream;
+import java.io.PrintWriter;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -294,30 +301,11 @@
     
     private void whereAmI() {
         if (count == 0) {
-            readerStackLevel = -1;
-            try {
-                throw new Throwable();
-            } catch (Throwable e) {
-                try {
-                    readerStackLevel = e.getStackTrace().length;
-                    // System.out.println("================= stack array length
-                    // is: " + readerStackLevel);
-                    // e.printStackTrace();
-                } catch (NoSuchMethodError nme) {
-                    DummyOutputStream dos = new DummyOutputStream();
-                    DummyPrintStream dps = new DummyPrintStream(dos);
-                    e.printStackTrace(dps);
-                    dps.flush();
-                    // System.out.println("================= print to dop level
-                    // num is: " + dps.lines);
-                    readerStackLevel = dps.lines;
-                    // e.printStackTrace();
-                }
-            }
+            readerStackLevel = new Throwable().getStackTrace().length;
         }
     }
     
-    public int read() {
+    public int read() throws IOException {
         if (count == 0)
             return -1;
         
@@ -359,26 +347,9 @@
         this.count = length;
     }
     
-    private void whereAmI() {
+    private void whereAmI()  {
         if (count == 0) {
-            readerStackLevel = -1;
-            try {
-                throw new Throwable();
-            } catch (Throwable e) {
-                try {
-                    readerStackLevel = e.getStackTrace().length;
-                    //	System.out.println("================= stack array length is: " + readerStackLevel);
-                    //	e.printStackTrace();
-                } catch (NoSuchMethodError nme) {
-                    DummyOutputStream dos = new DummyOutputStream();
-                    DummyPrintStream dps = new DummyPrintStream(dos);
-                    e.printStackTrace(dps);
-                    dps.flush();
-                    //	System.out.println("================= print to dop level num is: " + dps.lines);
-                    readerStackLevel = dps.lines;
-                    //	e.printStackTrace();
-                }
-            }
+            readerStackLevel = new Throwable().getStackTrace().length;
         }
     }
     
@@ -391,7 +362,7 @@
         return content++;
     }
     
-    public int read(byte[] buf, int offset, int length) {
+    public int read(byte[] buf, int offset, int length)  {
         
         if (count == 0)
             return -1;
@@ -410,69 +381,4 @@
     
     public void close() {
     }
-}
-
-class DummyOutputStream extends java.io.OutputStream {
-    public void close() {
-    }
-    
-    public void flush() {
-    }
-    
-    public void write(byte[] b) {
-    }
-    
-    public void write(byte[] b, int off, int len) {
-    }
-    
-    public void write(int b) {
-    }
-}
-
-class DummyPrintStream extends java.io.PrintStream {
-    int lines;
-    
-    public DummyPrintStream(DummyOutputStream dos) {
-        super(dos);
-    }
-    
-    public void println() {
-        lines++;
-    }
-    
-    public void println(String x) {
-        lines++;
-    }
-    
-    public void println(Object x) {
-        lines++;
-    }
-    
-    public void println(char[] x) {
-        lines++;
-    }
-    
-    public void println(double x) {
-        lines++;
-    }
-    
-    public void println(float x) {
-        lines++;
-    }
-    
-    public void println(long x) {
-        lines++;
-    }
-    
-    public void println(int x) {
-        lines++;
-    }
-    
-    public void println(char x) {
-        lines++;
-    }
-    
-    public void println(boolean x) {
-        lines++;
-    }
-}
+}
\ No newline at end of file