7077451: SerialLob, SerialClob have the wrong checks for setStream methods
Reviewed-by: alanb
Contributed-by: Patrick Reinhart <patrick@reini.net>
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java Wed Aug 10 12:30:29 2011 +0100
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java Wed Aug 10 16:23:56 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -382,7 +382,7 @@
*/
public java.io.OutputStream setBinaryStream(long pos)
throws SerialException, SQLException {
- if (this.blob.setBinaryStream(pos) != null) {
+ if (this.blob != null) {
return this.blob.setBinaryStream(pos);
} else {
throw new SerialException("Unsupported operation. SerialBlob cannot " +
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java Wed Aug 10 12:30:29 2011 +0100
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java Wed Aug 10 16:23:56 2011 -0400
@@ -436,7 +436,7 @@
*/
public java.io.OutputStream setAsciiStream(long pos)
throws SerialException, SQLException {
- if (this.clob.setAsciiStream(pos) != null) {
+ if (this.clob != null) {
return this.clob.setAsciiStream(pos);
} else {
throw new SerialException("Unsupported operation. SerialClob cannot " +
@@ -466,7 +466,7 @@
*/
public java.io.Writer setCharacterStream(long pos)
throws SerialException, SQLException {
- if (this.clob.setCharacterStream(pos) != null) {
+ if (this.clob != null) {
return this.clob.setCharacterStream(pos);
} else {
throw new SerialException("Unsupported operation. SerialClob cannot " +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/rowset/serial/SerialBlob/SetBinaryStream.java Wed Aug 10 16:23:56 2011 -0400
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import javax.sql.rowset.serial.SerialBlob;
+import javax.sql.rowset.serial.SerialException;
+
+/**
+ * @test
+ * @bug 7077451
+ * @summary tests if the correct exception is thrown when calling method setBinaryStream() on SerialBlob
+ */
+public class SetBinaryStream {
+
+ public static void main(String[] args) throws Exception {
+ SerialBlob blob = new SerialBlob(new byte[0]);
+ try {
+ blob.setBinaryStream(0);
+ } catch (SerialException e) {
+ System.out.println("Test PASSED");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/rowset/serial/SerialClob/SetAsciiStream.java Wed Aug 10 16:23:56 2011 -0400
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import javax.sql.rowset.serial.SerialClob;
+import javax.sql.rowset.serial.SerialException;
+
+/**
+ * @test
+ * @bug 7077451
+ * @summary tests if the correct exception is thrown when calling method setAsciiStream() on SerialClob
+ */
+public class SetAsciiStream {
+
+ public static void main(String[] args) throws Exception {
+ SerialClob clob = new SerialClob(new char[0]);
+ try {
+ clob.setAsciiStream(0);
+ } catch (SerialException e) {
+ System.out.println("Test PASSED");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/rowset/serial/SerialClob/SetCharacterStream.java Wed Aug 10 16:23:56 2011 -0400
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import javax.sql.rowset.serial.SerialClob;
+import javax.sql.rowset.serial.SerialException;
+
+/**
+ * @test
+ * @bug 7077451
+ * @summary tests if the correct exception is thrown when calling method setCharacterStream() on SerialClob
+ */
+public class SetCharacterStream {
+
+ public static void main(String[] args) throws Exception {
+ SerialClob clob = new SerialClob(new char[0]);
+ try {
+ clob.setCharacterStream(0);
+ } catch (SerialException e) {
+ System.out.println("Test PASSED");
+ }
+ }
+
+}