提交 f40d1f5d 编写于 作者: L lancea

7077451: SerialLob, SerialClob have the wrong checks for setStream methods

Reviewed-by: alanb
Contributed-by: NPatrick Reinhart <patrick@reini.net>
上级 557da3e0
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -382,7 +382,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable { ...@@ -382,7 +382,7 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
*/ */
public java.io.OutputStream setBinaryStream(long pos) public java.io.OutputStream setBinaryStream(long pos)
throws SerialException, SQLException { throws SerialException, SQLException {
if (this.blob.setBinaryStream(pos) != null) { if (this.blob != null) {
return this.blob.setBinaryStream(pos); return this.blob.setBinaryStream(pos);
} else { } else {
throw new SerialException("Unsupported operation. SerialBlob cannot " + throw new SerialException("Unsupported operation. SerialBlob cannot " +
......
...@@ -436,7 +436,7 @@ public class SerialClob implements Clob, Serializable, Cloneable { ...@@ -436,7 +436,7 @@ public class SerialClob implements Clob, Serializable, Cloneable {
*/ */
public java.io.OutputStream setAsciiStream(long pos) public java.io.OutputStream setAsciiStream(long pos)
throws SerialException, SQLException { throws SerialException, SQLException {
if (this.clob.setAsciiStream(pos) != null) { if (this.clob != null) {
return this.clob.setAsciiStream(pos); return this.clob.setAsciiStream(pos);
} else { } else {
throw new SerialException("Unsupported operation. SerialClob cannot " + throw new SerialException("Unsupported operation. SerialClob cannot " +
...@@ -466,7 +466,7 @@ public class SerialClob implements Clob, Serializable, Cloneable { ...@@ -466,7 +466,7 @@ public class SerialClob implements Clob, Serializable, Cloneable {
*/ */
public java.io.Writer setCharacterStream(long pos) public java.io.Writer setCharacterStream(long pos)
throws SerialException, SQLException { throws SerialException, SQLException {
if (this.clob.setCharacterStream(pos) != null) { if (this.clob != null) {
return this.clob.setCharacterStream(pos); return this.clob.setCharacterStream(pos);
} else { } else {
throw new SerialException("Unsupported operation. SerialClob cannot " + throw new SerialException("Unsupported operation. SerialClob cannot " +
......
/*
* 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");
}
}
}
/*
* 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");
}
}
}
/*
* 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");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册