-
Bug
-
Resolution: Cannot Reproduce
-
P2
-
5.0
-
sparc
-
solaris_2.6
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2080086 | 5.0 | Amit Handa | P2 | Closed | Cannot Reproduce | |
JDK-2080085 | 1.0 | Amit Handa | P2 | Closed | Cannot Reproduce |
Name: ssR10000 Date: 02/09/2004
Filed By : SPB JCK team (###@###.###)
JDK :
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Problem description
===================
1. The following method is wrong:
public long position(byte[] pattern, long start) throws SerialException, SQLException {
...
int pos = (int)(start - 1); int i = 0;
long beginpos; long patlen = pattern.length;
while (pos < len) {
i = 0;
beginpos = pos + 1;
while (pattern[i++] == buf[pos++]) {
if (i == patlen) {
return beginpos;
}
}
}
it it looks like this method return -1 if buf='AAAB' and pattern='AAB' because there is no rollback for pos in the internal loop.
2. Some methods declare that first positon is 0 another that 1. Moreover some methods accept first position as 0:
------------------------------------------
public long position(Blob pattern,
long start)
throws SerialException,
SQLException
....
start - the position of the byte in this SerialBlob object from which to begin the search; the first position is 0; must not be less than 0 nor greater than the length of this SerialBlob object
------------------------------------------
but same method return 1-based position:
------------------------------------------
Returns:
...starting position is out of bounds; position numbering for the return value starts at 1
------------------------------------------
3. public int setBytes(long pos, byte[] bytes, int offset, int length)
...
if ((long)(length) > origLen) {
throw new SerialException
("Buffer is not sufficient to hold the value");
}
for (i = 0; i < length; i++) {
buf[(int)pos+i] = bytes[offset+i];
}
...
Unfortunelly this is correct only in case pos=0 otherwise we will recieve an exception due to wrong index.
4. public java.io.OutputStream setBinaryStream(long pos) throws SerialException
Spec says:
Retrieves a stream that can be used to write to the <code>BLOB</code>
value that this Blob object represents. The stream begins at position pos.
...
but as I wrote before (4923253) following method it is just a factory to retrieve an ByteArrayOutputStream. Returned stream CANNOT be used to write to the current SerialBLOB object.
public java.io.OutputStream setBinaryStream(long pos) throws SerialException { ByteArrayOutputStream baostream =
new ByteArrayOutputStream((int)((buf.length)-pos));
return (java.io.OutputStream)baostream;
}
5. There is a lot of another problems due to 0-based\1-based arrays mixing.
======================================================================
Filed By : SPB JCK team (###@###.###)
JDK :
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Problem description
===================
1. The following method is wrong:
public long position(byte[] pattern, long start) throws SerialException, SQLException {
...
int pos = (int)(start - 1); int i = 0;
long beginpos; long patlen = pattern.length;
while (pos < len) {
i = 0;
beginpos = pos + 1;
while (pattern[i++] == buf[pos++]) {
if (i == patlen) {
return beginpos;
}
}
}
it it looks like this method return -1 if buf='AAAB' and pattern='AAB' because there is no rollback for pos in the internal loop.
2. Some methods declare that first positon is 0 another that 1. Moreover some methods accept first position as 0:
------------------------------------------
public long position(Blob pattern,
long start)
throws SerialException,
SQLException
....
start - the position of the byte in this SerialBlob object from which to begin the search; the first position is 0; must not be less than 0 nor greater than the length of this SerialBlob object
------------------------------------------
but same method return 1-based position:
------------------------------------------
Returns:
...starting position is out of bounds; position numbering for the return value starts at 1
------------------------------------------
3. public int setBytes(long pos, byte[] bytes, int offset, int length)
...
if ((long)(length) > origLen) {
throw new SerialException
("Buffer is not sufficient to hold the value");
}
for (i = 0; i < length; i++) {
buf[(int)pos+i] = bytes[offset+i];
}
...
Unfortunelly this is correct only in case pos=0 otherwise we will recieve an exception due to wrong index.
4. public java.io.OutputStream setBinaryStream(long pos) throws SerialException
Spec says:
Retrieves a stream that can be used to write to the <code>BLOB</code>
value that this Blob object represents. The stream begins at position pos.
...
but as I wrote before (4923253) following method it is just a factory to retrieve an ByteArrayOutputStream. Returned stream CANNOT be used to write to the current SerialBLOB object.
public java.io.OutputStream setBinaryStream(long pos) throws SerialException { ByteArrayOutputStream baostream =
new ByteArrayOutputStream((int)((buf.length)-pos));
return (java.io.OutputStream)baostream;
}
5. There is a lot of another problems due to 0-based\1-based arrays mixing.
======================================================================
- backported by
-
JDK-2080085 The class javax.sql.rowset.serial.SerialBlob is too buggy
-
- Closed
-
-
JDK-2080086 The class javax.sql.rowset.serial.SerialBlob is too buggy
-
- Closed
-
- relates to
-
JDK-4991036 The class javax.sql.rowset.serial.SerialClob is too buggy
-
- Closed
-