Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2118870 | 5.0 | Jonathan Bruce | P1 | Resolved | Fixed | rc |
Name: ygR10224 Date: 07/22/2004
Filed By : SPB JCK team
JDK : java full version "1.5.0-beta3-b58"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
api/javax_sql/rowset/serial/SerialArray/index.html#Main[SerialArray2003]
api/javax_sql/rowset/serial/SerialArray/serial/index.html#Constructor[serial2003]
api/javax_sql/rowset/serial/SerialClob/serial/index.html#Constructor[serial2001]
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public SerialClob(Clob clob)
throws SerialException,
SQLException
Constructs a SerialClob object that is a serialized version of the given Clob
object.
The new SerialClob object is initialized with the data from the Clob object;
therefore,
the Clob object should have previously brought the SQL CLOB value's data over
to the client
from the database. Otherwise, the new SerialClob object object will contain no
data.
Note: The Clob object supplied to this constructor cannot return null for
the Clob.getCharacterStream() and Clob.getAsciiStream methods. This SerialClob
constructor
cannot serialize a Clob object in this instance and will throw an SQLException
object.
Parameters:
clob - the Clob object from which this SerialClob object is to be constructed;
cannot be null
Throws:
SerialException - if an error occurs during serialization
SQLException - if a SQL error occurs in capturing the CLOB; if the Clob object
is a null; or
if both the Clob.getCharacterStream() and Clob.getAsciiStream() methods on the
Clob return a null
...
---------- end-of-excerpt ---------------
Problem description
===================
After fix of 5063284 the designated constructor throws java.sql.SQLException
if ONE
of clob.getCharacterStream() and clob.getAsciiStream() returns null.
But the spec says that SQLException should be thrown
"if both the Clob.getCharacterStream() and Clob.getAsciiStream() methods on
the Clob return a null".
^^^^
Minimized test:
===============
------- Test.java --------------
import javax.sql.rowset.serial.*;
import java.io.*;
import java.sql.*;
class MyClob implements Clob {
public long length()
throws SQLException {
return 3;
}
public String getSubString(long pos, int length)
throws SQLException {
return "abd";
}
public Reader getCharacterStream()
throws SQLException {
// Note - if you uncomment next line and comment next after it then
test passed
//return new StringReader("The test string 0123456789");
return null;
}
public InputStream getAsciiStream()
throws SQLException {
return new ByteArrayInputStream(new byte[] {'a', 'b', 'c'});
}
public long position(String searchstr,
long start)
throws SQLException {
return 0;
}
public long position(Clob searchstr,
long start)
throws SQLException {
return 0;
}
public int setString(long pos,
String str)
throws SQLException {
return 0;
}
public int setString(long pos,
String str,
int offset,
int len)
throws SQLException {
return 0;
}
public OutputStream setAsciiStream(long pos)
throws SQLException {
return null;
}
public Writer setCharacterStream(long pos)
throws SQLException {
return null;
}
public void truncate(long len)
throws SQLException {
}
}
public class Test {
public static void main(String args[]) {
try {
MyClob myClob = new MyClob();
SerialClob sClob = new SerialClob(myClob);
} catch (Exception e) {
e.printStackTrace();
}
}
}
------- end-of-Test.java -------
Minimized test output:
======================
<gyi@orion> java -showversion Test
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b58)
Java HotSpot(TM) Server VM (build 1.5.0-beta3-b58, mixed mode)
java.sql.SQLException: Invalid Clob object. Calls to getCharacterStream and
getAsciiStream return null which cannot be serialized.
at javax.sql.rowset.serial.SerialClob.<init>(SerialClob.java:132)
at Test.main(Test.java:64)
======================================================================
======================================================================
Filed By : SPB JCK team
JDK : java full version "1.5.0-beta3-b58"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
api/javax_sql/rowset/serial/SerialArray/index.html#Main[SerialArray2003]
api/javax_sql/rowset/serial/SerialArray/serial/index.html#Constructor[serial2003]
api/javax_sql/rowset/serial/SerialClob/serial/index.html#Constructor[serial2001]
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public SerialClob(Clob clob)
throws SerialException,
SQLException
Constructs a SerialClob object that is a serialized version of the given Clob
object.
The new SerialClob object is initialized with the data from the Clob object;
therefore,
the Clob object should have previously brought the SQL CLOB value's data over
to the client
from the database. Otherwise, the new SerialClob object object will contain no
data.
Note: The Clob object supplied to this constructor cannot return null for
the Clob.getCharacterStream() and Clob.getAsciiStream methods. This SerialClob
constructor
cannot serialize a Clob object in this instance and will throw an SQLException
object.
Parameters:
clob - the Clob object from which this SerialClob object is to be constructed;
cannot be null
Throws:
SerialException - if an error occurs during serialization
SQLException - if a SQL error occurs in capturing the CLOB; if the Clob object
is a null; or
if both the Clob.getCharacterStream() and Clob.getAsciiStream() methods on the
Clob return a null
...
---------- end-of-excerpt ---------------
Problem description
===================
After fix of 5063284 the designated constructor throws java.sql.SQLException
if ONE
of clob.getCharacterStream() and clob.getAsciiStream() returns null.
But the spec says that SQLException should be thrown
"if both the Clob.getCharacterStream() and Clob.getAsciiStream() methods on
the Clob return a null".
^^^^
Minimized test:
===============
------- Test.java --------------
import javax.sql.rowset.serial.*;
import java.io.*;
import java.sql.*;
class MyClob implements Clob {
public long length()
throws SQLException {
return 3;
}
public String getSubString(long pos, int length)
throws SQLException {
return "abd";
}
public Reader getCharacterStream()
throws SQLException {
// Note - if you uncomment next line and comment next after it then
test passed
//return new StringReader("The test string 0123456789");
return null;
}
public InputStream getAsciiStream()
throws SQLException {
return new ByteArrayInputStream(new byte[] {'a', 'b', 'c'});
}
public long position(String searchstr,
long start)
throws SQLException {
return 0;
}
public long position(Clob searchstr,
long start)
throws SQLException {
return 0;
}
public int setString(long pos,
String str)
throws SQLException {
return 0;
}
public int setString(long pos,
String str,
int offset,
int len)
throws SQLException {
return 0;
}
public OutputStream setAsciiStream(long pos)
throws SQLException {
return null;
}
public Writer setCharacterStream(long pos)
throws SQLException {
return null;
}
public void truncate(long len)
throws SQLException {
}
}
public class Test {
public static void main(String args[]) {
try {
MyClob myClob = new MyClob();
SerialClob sClob = new SerialClob(myClob);
} catch (Exception e) {
e.printStackTrace();
}
}
}
------- end-of-Test.java -------
Minimized test output:
======================
<gyi@orion> java -showversion Test
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b58)
Java HotSpot(TM) Server VM (build 1.5.0-beta3-b58, mixed mode)
java.sql.SQLException: Invalid Clob object. Calls to getCharacterStream and
getAsciiStream return null which cannot be serialized.
at javax.sql.rowset.serial.SerialClob.<init>(SerialClob.java:132)
at Test.main(Test.java:64)
======================================================================
======================================================================
- backported by
-
JDK-2118870 Ctor of SerialClob throws SQLException incorrectly
- Resolved
- relates to
-
JDK-5063284 javax.sql.rowset.serial.SerialClob throws unexpected NPE
- Resolved