db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r678388 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/
Date Mon, 21 Jul 2008 11:12:32 GMT
Author: kahatlen
Date: Mon Jul 21 04:12:32 2008
New Revision: 678388

URL: http://svn.apache.org/viewvc?rev=678388&view=rev
Log:
DERBY-3783: Added utility method that wraps a Throwable in an IOException

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/AutoPositioningStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUpdatableReader.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUtf8Writer.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdatableBlobStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/AutoPositioningStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/AutoPositioningStream.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/AutoPositioningStream.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/AutoPositioningStream.java
Mon Jul 21 04:12:32 2008
@@ -156,9 +156,7 @@
             }
         }
         catch (StandardException se) {
-            IOException ioe = new IOException (se.getMessage());
-            ioe.initCause (se);
-            throw ioe;
+            throw Util.newIOException(se);
         }
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUpdatableReader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUpdatableReader.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUpdatableReader.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUpdatableReader.java Mon
Jul 21 04:12:32 2008
@@ -222,9 +222,7 @@
                     stream = clob.getInternalClob().getRawByteStream();
                 }
                 catch (SQLException e) {
-                    IOException ioe = new IOException (e.getMessage());
-                    ioe.initCause (e);
-                    throw ioe;
+                    throw Util.newIOException(e);
                 }
                 init ((LOBInputStream) stream, pos);
                 materialized = true;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUtf8Writer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUtf8Writer.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUtf8Writer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobUtf8Writer.java Mon Jul
21 04:12:32 2008
@@ -104,9 +104,7 @@
                 pos += ret;
         }
         catch (SQLException e) {
-            IOException ioe = new IOException (e.getMessage());
-            ioe.initCause (e);
-            throw ioe;
+            throw Util.newIOException(e);
         }
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBInputStream.java Mon Jul
21 04:12:32 2008
@@ -131,7 +131,7 @@
                                             SQLState.BLOB_INVALID_OFFSET))) {
                 throw new ArrayIndexOutOfBoundsException(se.getMessage());
             } else {
-                throw new IOException(se.getMessage());
+                throw Util.newIOException(se);
             }
         }
     }
@@ -173,7 +173,7 @@
                 pos += 1;
             return ret;
         } catch (StandardException se) {
-            throw new IOException (se.getMessage());
+            throw Util.newIOException(se);
         }
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBOutputStream.java Mon Jul
21 04:12:32 2008
@@ -68,7 +68,7 @@
         try {
             pos = control.write(b, pos);
         } catch (StandardException se) {
-            throw new IOException (se.getMessage());
+            throw Util.newIOException(se);
         }
     }
 
@@ -113,7 +113,7 @@
                                             SQLState.BLOB_INVALID_OFFSET))) {
                 throw new ArrayIndexOutOfBoundsException(se.getMessage());
             }
-            throw new IOException (se.getMessage());
+            throw Util.newIOException(se);
         }
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStreamControl.java Mon Jul
21 04:12:32 2008
@@ -114,9 +114,7 @@
                 throw (StandardException)e;
             if (e instanceof IOException)
                 throw (IOException) e;
-            IOException ioe = new IOException (e.getMessage());
-            ioe.initCause (e);
-            throw ioe;
+            throw Util.newIOException(e);
         }
         isBytes = false;
         //now this call will write into the file
@@ -397,9 +395,7 @@
                 throw (IOException) e;
             if (e instanceof RuntimeException)
                 throw (RuntimeException) e;
-            IOException ioe = new IOException(e.getMessage());
-            ioe.initCause(e);
-            throw ioe;
+            throw Util.newIOException(e);
         }
     }
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java Mon Jul 21
04:12:32 2008
@@ -142,9 +142,7 @@
                     try {
                         this.positionedIn.resetStream();
                     } catch (StandardException se) {
-                        IOException ioe = new IOException(se.getMessage());
-                        ioe.initCause(se);
-                        throw ioe;
+                        throw Util.newIOException(se);
                     }
                 } else {
                     this.positionedIn = null;
@@ -567,10 +565,7 @@
             parent.restoreContextStack();
         }
         } catch (SQLException sqle) {
-            IOException ioe =
-                new IOException(sqle.getSQLState() + ": " + sqle.getMessage());
-            ioe.initCause(sqle);
-            throw ioe;
+            throw Util.newIOException(sqle);
         }
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdatableBlobStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdatableBlobStream.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdatableBlobStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdatableBlobStream.java Mon
Jul 21 04:12:32 2008
@@ -110,9 +110,7 @@
             try {
                 stream = blob.getBinaryStream();
             } catch (SQLException ex) {
-                IOException ioe = new IOException (ex.getMessage());
-                ioe.initCause (ex);
-                throw ioe;
+                throw Util.newIOException(ex);
             }
             long leftToSkip = pos;
             while (leftToSkip > 0) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?rev=678388&r1=678387&r2=678388&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Mon Jul 21 04:12:32
2008
@@ -282,6 +282,18 @@
 	}
 
     /**
+     * Create an {@code IOException} that wraps another {@code Throwable}.
+     *
+     * @param cause the underlying cause of the error
+     * @return an {@code IOException} linked to {@code cause}
+     */
+    static IOException newIOException(Throwable cause) {
+        IOException ioe = new IOException(cause.getMessage());
+        ioe.initCause(cause);
+        return ioe;
+    }
+
+    /**
      * this method is called to replace the exception factory to be 
      * used to generate the SQLException or the subclass
      */



Mime
View raw message