harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548565 - in /harmony/enhanced/classlib/trunk/modules/sql/src: main/java/javax/sql/rowset/serial/ test/java/org/apache/harmony/sql/tests/java/sql/ test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/
Date Tue, 19 Jun 2007 02:49:52 GMT
Author: tonywu
Date: Mon Jun 18 19:49:51 2007
New Revision: 548565

URL: http://svn.apache.org/viewvc?view=rev&rev=548565
Log:
Apply patch HARMONY-4224 ([classlib][sql]SerialClob.setAsciiStream does not throw SerialException
when its internal Clob.setAsciiStream returns null)

Modified:
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java?view=diff&rev=548565&r1=548564&r2=548565
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
Mon Jun 18 19:49:51 2007
@@ -60,12 +60,10 @@
         if (clob == null) {
             throw new SQLException(Messages.getString("sql.19"));//$NON-NLS-1$
         }
-
-        characterStream = clob.getCharacterStream();
-        asciiStream = clob.getAsciiStream();
-        if (characterStream == null || asciiStream == null) {
-            throw new SQLException(Messages.getString("sql.20"));//$NON-NLS-1$
-        }
+        if ((characterStream = clob.getCharacterStream()) == null
+				&& (asciiStream = clob.getAsciiStream()) == null) {
+			throw new SQLException(Messages.getString("sql.20"));//$NON-NLS-1$
+		}
 
         this.clob = clob;
         origLen = clob.length();
@@ -83,10 +81,12 @@
     }
 
     public long length() throws SerialException {
+        checkValidation();
         return len;
     }
 
     public InputStream getAsciiStream() throws SerialException, SQLException {
+        checkValidation();
         if (clob == null) {
             throw new SerialException(Messages.getString("sql.25")); // $NON-NLS-1$
         }
@@ -94,6 +94,7 @@
     }
 
     public Reader getCharacterStream() throws SerialException {
+        checkValidation();
         return new CharArrayReader(buf);
     }
 
@@ -114,12 +115,14 @@
 
     public long position(Clob searchClob, long start) throws SerialException,
             SQLException {
+        checkValidation();
         String searchString = searchClob.getSubString(1, (int)searchClob.length());
         return position(searchString, start);
     }
 
     public long position(String searchString, long start) throws SerialException,
             SQLException {
+        checkValidation();
         if (start < 1 || len - (start - 1) < searchString.length()) {
             return -1;
         }
@@ -148,26 +151,38 @@
 
     public OutputStream setAsciiStream(long pos) throws SerialException,
             SQLException {
+        checkValidation();
         if (clob == null) {
             throw new SerialException(Messages.getString("sql.25")); // $NON-NLS-1$
         }
-        return clob.setAsciiStream(pos);
+        OutputStream os = clob.setAsciiStream(pos);
+        if(os == null){
+            throw new SerialException(Messages.getString("sql.46")); // $NON-NLS-1$
+        }
+        return os;
     }
 
     public Writer setCharacterStream(long pos) throws SerialException,
             SQLException {
+        checkValidation();
         if (clob == null) {
             throw new SerialException(Messages.getString("sql.25")); // $NON-NLS-1$
         }
-        return clob.setCharacterStream(pos);
+        Writer writer = clob.setCharacterStream(pos);
+        if(writer == null){
+            throw new SerialException(Messages.getString("sql.45")); // $NON-NLS-1$
+        }
+        return writer;
     }
 
     public int setString(long pos, String str) throws SerialException {
+        checkValidation();
         return setString(pos, str, 0, str.length());
     }
 
     public int setString(long pos, String str, int offset, int length)
             throws SerialException {
+        checkValidation();
         if (pos < 1 || length < 0 || pos > (len - length + 1)) {
             throw new SerialException(Messages.getString("sql.21")); // $NON-NLS-1$
         }
@@ -182,6 +197,7 @@
     }
 
     public void truncate(long length) throws SerialException {
+        checkValidation();
         if(length > len || length < 0) {
             throw new SerialException(Messages.getString("sql.24"));
         }

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java?view=diff&rev=548565&r1=548564&r2=548565
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
Mon Jun 18 19:49:51 2007
@@ -584,7 +584,7 @@
      * 
      * Registers a driver for multiple times and deregisters it only once.
      * 
-     * Regression for
+     * Regression for HARMONY-4205
      */
     public void test_registerDriver_MultiTimes() throws SQLException {
         int register_count = 10;

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java?view=diff&rev=548565&r1=548564&r2=548565
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
Mon Jun 18 19:49:51 2007
@@ -62,22 +62,8 @@
 
         mockClob.characterStreamReader = null;
         mockClob.asciiInputStream = new ByteArrayInputStream(new byte[] { 1 });
-        try {
-            new SerialClob(mockClob);
-            fail("should throw SQLException");
-        } catch (SQLException e) {
-            // expected
-        }
-
         mockClob.characterStreamReader = new CharArrayReader(new char[] { 1 });
         mockClob.asciiInputStream = null;
-        try {
-            new SerialClob(mockClob);
-            fail("should throw SQLException");
-        } catch (SQLException e) {
-            // expected
-        }
-
         mockClob.characterStreamReader = new MockAbnormalReader();
         mockClob.asciiInputStream = new ByteArrayInputStream(new byte[] { 1 });
         try {
@@ -261,9 +247,17 @@
         MockSerialClob mockClob = new MockSerialClob();
         mockClob.characterStreamReader = new CharArrayReader(mockClob.buf);
         mockClob.asciiInputStream = new ByteArrayInputStream(new byte[] { 1 });
-        mockClob.asciiOutputStream = new ByteArrayOutputStream();
         SerialClob serialClob = new SerialClob(mockClob);
-        OutputStream os = serialClob.setAsciiStream(1);
+        OutputStream os = null;
+        try {
+            os = serialClob.setAsciiStream(1);
+            fail("should throw SerialException");
+        } catch (SerialException e) {
+            // expected
+        }
+        mockClob.asciiOutputStream = new ByteArrayOutputStream();
+        os = serialClob.setAsciiStream(1);
+        assertNotNull(os);
         assertTrue(mockClob.isSetAsciiStreamInvoked);
         assertEquals(mockClob.asciiOutputStream, os);
         



Mime
View raw message