Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v6]

2021-10-28 Thread Mitsuru Kariya
On Sun, 24 Oct 2021 07:55:01 GMT, Mitsuru Kariya  wrote:

>> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
>> the following cases:
>> 
>> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
>> this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully.
>>(test31)
>> 
>> 2. `pos - 1 + length > this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully. *1
>>(test32)
>> 
>> 3. `pos == this.length() + 1`
>>The original implementation throws `SerialException` but this case should 
>> end successfully. *2
>>(test33)
>> 
>> 4. `length < 0`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test34)
>> 
>> 5. `offset + length > Integer.MAX_VALUE`
>>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
>> `OutOfMemoryError` in most cases) but this case should throw 
>> `SerialException`.
>>(test35)
>> 
>> Additionally, fix `SerialClob.setString(long pos, String str, int offset, 
>> int length)` in the following cases:
>> 
>> 1. `offset > str.length()`
>>The original implementaion throws `StringIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test39)
>> 
>> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
>> this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully.
>>(test32)
>> 
>> 3. `pos - 1 + length > this.length()`
>>The original implementaion throws `SerialException` but this case should 
>> end successfully. *3
>>(test40)
>> 
>> 4. `pos == this.length() + 1`
>>The original implementaion throws `SerialException` but this case should 
>> end successfully. *4
>>(test41)
>> 
>> 5. `length < 0`
>>The original implementation throws `StringIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test42)
>> 
>> 6. `offset + length > Integer.MAX_VALUE`
>>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
>> `OutOfMemoryError` in most cases) but this case should throw 
>> `SerialException`.
>>(test43)
>> 
>> 
>> The javadoc has also been modified according to the above.
>> 
>> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob 
>> value is reached while writing the array of bytes, then the length of the 
>> Blob value will be increased to accommodate the extra bytes."
>> 
>> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
>> pos is greater than the length+1 of the BLOB value then the behavior is 
>> undefined."
>>So, it should work correctly when pos == length+1 of the BLOB value.
>> 
>> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
>> value is eached while writing the given string, then the length of the Clob 
>> value will be increased to accommodate the extra characters."
>> 
>> *4 The documentation of `Clob.setString()` says, "If the value specified for 
>> pos is greater than the length+1 of the CLOB value then the behavior is 
>> undefined."
>>So, it should work correctly when pos == length+1 of the CLOB value.
>
> Mitsuru Kariya has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains six additional 
> commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8153490
>  - Follow the comment
>  - Modify javadoc for consistency
>  - Fix for length + offset > Integer.MAX_VALUE case
>  - Add check: ensure length >= 0
>  - 8153490:Cannot setBytes() if incoming buffer's length is bigger than 
> number of elements we want to insert.
>
>Fix SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length) in 
> the
>following cases:
>
>1. pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()
>   The original implementation throws ArrayIndexOutOfBoundsException but 
> this case
>   should

Integrated: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert.

2021-10-28 Thread Mitsuru Kariya
On Wed, 12 May 2021 17:48:50 GMT, Mitsuru Kariya  wrote:

> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
> the following cases:
> 
> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test31)
> 
> 2. `pos - 1 + length > this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully. *1
>(test32)
> 
> 3. `pos == this.length() + 1`
>The original implementation throws `SerialException` but this case should 
> end successfully. *2
>(test33)
> 
> 4. `length < 0`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test34)
> 
> 5. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test35)
> 
> Additionally, fix `SerialClob.setString(long pos, String str, int offset, int 
> length)` in the following cases:
> 
> 1. `offset > str.length()`
>The original implementaion throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test39)
> 
> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test32)
> 
> 3. `pos - 1 + length > this.length()`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *3
>(test40)
> 
> 4. `pos == this.length() + 1`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *4
>(test41)
> 
> 5. `length < 0`
>The original implementation throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test42)
> 
> 6. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test43)
> 
> 
> The javadoc has also been modified according to the above.
> 
> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob value 
> is reached while writing the array of bytes, then the length of the Blob 
> value will be increased to accommodate the extra bytes."
> 
> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
> pos is greater than the length+1 of the BLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the BLOB value.
> 
> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
> value is eached while writing the given string, then the length of the Clob 
> value will be increased to accommodate the extra characters."
> 
> *4 The documentation of `Clob.setString()` says, "If the value specified for 
> pos is greater than the length+1 of the CLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the CLOB value.

This pull request has now been integrated.

Changeset: 63b9f8c0
Author:Mitsuru Kariya 
Committer: Lance Andersen 
URL:   
https://git.openjdk.java.net/jdk/commit/63b9f8c0da2ed3634002f0f67b18555826aeddc4
Stats: 262 lines in 4 files changed: 168 ins; 9 del; 85 mod

8153490: Cannot setBytes() if incoming buffer's length is bigger than number of 
elements we want to insert.

Reviewed-by: lancea

-

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v6]

2021-10-27 Thread Mitsuru Kariya
On Sun, 24 Oct 2021 07:55:01 GMT, Mitsuru Kariya  wrote:

>> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
>> the following cases:
>> 
>> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
>> this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully.
>>(test31)
>> 
>> 2. `pos - 1 + length > this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully. *1
>>(test32)
>> 
>> 3. `pos == this.length() + 1`
>>The original implementation throws `SerialException` but this case should 
>> end successfully. *2
>>(test33)
>> 
>> 4. `length < 0`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test34)
>> 
>> 5. `offset + length > Integer.MAX_VALUE`
>>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
>> `OutOfMemoryError` in most cases) but this case should throw 
>> `SerialException`.
>>(test35)
>> 
>> Additionally, fix `SerialClob.setString(long pos, String str, int offset, 
>> int length)` in the following cases:
>> 
>> 1. `offset > str.length()`
>>The original implementaion throws `StringIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test39)
>> 
>> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
>> this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully.
>>(test32)
>> 
>> 3. `pos - 1 + length > this.length()`
>>The original implementaion throws `SerialException` but this case should 
>> end successfully. *3
>>(test40)
>> 
>> 4. `pos == this.length() + 1`
>>The original implementaion throws `SerialException` but this case should 
>> end successfully. *4
>>(test41)
>> 
>> 5. `length < 0`
>>The original implementation throws `StringIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test42)
>> 
>> 6. `offset + length > Integer.MAX_VALUE`
>>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
>> `OutOfMemoryError` in most cases) but this case should throw 
>> `SerialException`.
>>(test43)
>> 
>> 
>> The javadoc has also been modified according to the above.
>> 
>> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob 
>> value is reached while writing the array of bytes, then the length of the 
>> Blob value will be increased to accommodate the extra bytes."
>> 
>> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
>> pos is greater than the length+1 of the BLOB value then the behavior is 
>> undefined."
>>So, it should work correctly when pos == length+1 of the BLOB value.
>> 
>> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
>> value is eached while writing the given string, then the length of the Clob 
>> value will be increased to accommodate the extra characters."
>> 
>> *4 The documentation of `Clob.setString()` says, "If the value specified for 
>> pos is greater than the length+1 of the CLOB value then the behavior is 
>> undefined."
>>So, it should work correctly when pos == length+1 of the CLOB value.
>
> Mitsuru Kariya has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains six additional 
> commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8153490
>  - Follow the comment
>  - Modify javadoc for consistency
>  - Fix for length + offset > Integer.MAX_VALUE case
>  - Add check: ensure length >= 0
>  - 8153490:Cannot setBytes() if incoming buffer's length is bigger than 
> number of elements we want to insert.
>
>Fix SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length) in 
> the
>following cases:
>
>1. pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()
>   The original implementation throws ArrayIndexOutOfBoundsException but 
> this case
>   should

Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v6]

2021-10-24 Thread Mitsuru Kariya
> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
> the following cases:
> 
> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test31)
> 
> 2. `pos - 1 + length > this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully. *1
>(test32)
> 
> 3. `pos == this.length() + 1`
>The original implementation throws `SerialException` but this case should 
> end successfully. *2
>(test33)
> 
> 4. `length < 0`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test34)
> 
> 5. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test35)
> 
> Additionally, fix `SerialClob.setString(long pos, String str, int offset, int 
> length)` in the following cases:
> 
> 1. `offset > str.length()`
>The original implementaion throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test39)
> 
> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test32)
> 
> 3. `pos - 1 + length > this.length()`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *3
>(test40)
> 
> 4. `pos == this.length() + 1`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *4
>(test41)
> 
> 5. `length < 0`
>The original implementation throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test42)
> 
> 6. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test43)
> 
> 
> The javadoc has also been modified according to the above.
> 
> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob value 
> is reached while writing the array of bytes, then the length of the Blob 
> value will be increased to accommodate the extra bytes."
> 
> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
> pos is greater than the length+1 of the BLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the BLOB value.
> 
> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
> value is eached while writing the given string, then the length of the Clob 
> value will be increased to accommodate the extra characters."
> 
> *4 The documentation of `Clob.setString()` says, "If the value specified for 
> pos is greater than the length+1 of the CLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the CLOB value.

Mitsuru Kariya has updated the pull request with a new target base due to a 
merge or a rebase. The incremental webrev excludes the unrelated changes 
brought in by the merge/rebase. The pull request contains six additional 
commits since the last revision:

 - Merge branch 'master' into JDK-8153490
 - Follow the comment
 - Modify javadoc for consistency
 - Fix for length + offset > Integer.MAX_VALUE case
 - Add check: ensure length >= 0
 - 8153490:Cannot setBytes() if incoming buffer's length is bigger than number 
of elements we want to insert.
   
   Fix SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length) in 
the
   following cases:
   
   1. pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
this.length()
  The original implementation throws ArrayIndexOutOfBoundsException but 
this case
  should end successfully.
  (test31)
   
   2. pos - 1 + length > this.length()
  The original implementation throws ArrayIndexOutOfBoundsException but 
this case
  should end successfully. *1
  (test32)
   
   3. pos == this.length() + 1
  The original implementation throws SerialException but this case should 
end
  successfully. *2
  (test33)
   
   Additionally, fix SerialClob.setString(long pos, String str, int offset, int 
length)
   in the following cases:
   
   1. offset > str.leng

Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v5]

2021-10-18 Thread Mitsuru Kariya
On Fri, 15 Oct 2021 09:30:18 GMT, Mitsuru Kariya  wrote:

>> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
>> the following cases:
>> 
>> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
>> this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully.
>>(test31)
>> 
>> 2. `pos - 1 + length > this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully. *1
>>(test32)
>> 
>> 3. `pos == this.length() + 1`
>>The original implementation throws `SerialException` but this case should 
>> end successfully. *2
>>(test33)
>> 
>> 4. `length < 0`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test34)
>> 
>> 5. `offset + length > Integer.MAX_VALUE`
>>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
>> `OutOfMemoryError` in most cases) but this case should throw 
>> `SerialException`.
>>(test35)
>> 
>> Additionally, fix `SerialClob.setString(long pos, String str, int offset, 
>> int length)` in the following cases:
>> 
>> 1. `offset > str.length()`
>>The original implementaion throws `StringIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test39)
>> 
>> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
>> this.length()`
>>The original implementation throws `ArrayIndexOutOfBoundsException` but 
>> this case should end successfully.
>>(test32)
>> 
>> 3. `pos - 1 + length > this.length()`
>>The original implementaion throws `SerialException` but this case should 
>> end successfully. *3
>>(test40)
>> 
>> 4. `pos == this.length() + 1`
>>The original implementaion throws `SerialException` but this case should 
>> end successfully. *4
>>(test41)
>> 
>> 5. `length < 0`
>>The original implementation throws `StringIndexOutOfBoundsException` but 
>> this case should throw `SerialException`.
>>(test42)
>> 
>> 6. `offset + length > Integer.MAX_VALUE`
>>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
>> `OutOfMemoryError` in most cases) but this case should throw 
>> `SerialException`.
>>(test43)
>> 
>> 
>> The javadoc has also been modified according to the above.
>> 
>> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob 
>> value is reached while writing the array of bytes, then the length of the 
>> Blob value will be increased to accommodate the extra bytes."
>> 
>> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
>> pos is greater than the length+1 of the BLOB value then the behavior is 
>> undefined."
>>So, it should work correctly when pos == length+1 of the BLOB value.
>> 
>> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
>> value is eached while writing the given string, then the length of the Clob 
>> value will be increased to accommodate the extra characters."
>> 
>> *4 The documentation of `Clob.setString()` says, "If the value specified for 
>> pos is greater than the length+1 of the CLOB value then the behavior is 
>> undefined."
>>So, it should work correctly when pos == length+1 of the CLOB value.
>
> Mitsuru Kariya has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Follow the comment

The pre-submit test seems to have failed because the compiler was not found in 
some environments.
Should I take any action?
Or should I issue the /integrate pull request command?

-

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v5]

2021-10-15 Thread Mitsuru Kariya
> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
> the following cases:
> 
> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test31)
> 
> 2. `pos - 1 + length > this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully. *1
>(test32)
> 
> 3. `pos == this.length() + 1`
>The original implementation throws `SerialException` but this case should 
> end successfully. *2
>(test33)
> 
> 4. `length < 0`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test34)
> 
> 5. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test35)
> 
> Additionally, fix `SerialClob.setString(long pos, String str, int offset, int 
> length)` in the following cases:
> 
> 1. `offset > str.length()`
>The original implementaion throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test39)
> 
> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test32)
> 
> 3. `pos - 1 + length > this.length()`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *3
>(test40)
> 
> 4. `pos == this.length() + 1`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *4
>(test41)
> 
> 5. `length < 0`
>The original implementation throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test42)
> 
> 6. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test43)
> 
> 
> The javadoc has also been modified according to the above.
> 
> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob value 
> is reached while writing the array of bytes, then the length of the Blob 
> value will be increased to accommodate the extra bytes."
> 
> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
> pos is greater than the length+1 of the BLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the BLOB value.
> 
> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
> value is eached while writing the given string, then the length of the Clob 
> value will be increased to accommodate the extra characters."
> 
> *4 The documentation of `Clob.setString()` says, "If the value specified for 
> pos is greater than the length+1 of the CLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the CLOB value.

Mitsuru Kariya has updated the pull request incrementally with one additional 
commit since the last revision:

  Follow the comment

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/4001/files
  - new: https://git.openjdk.java.net/jdk/pull/4001/files/69fb2f4a..c5d8056b

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=04
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=03-04

  Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4001.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4001/head:pull/4001

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v4]

2021-10-13 Thread Mitsuru Kariya
On Wed, 15 Sep 2021 17:57:35 GMT, Lance Andersen  wrote:

>> Mitsuru Kariya has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Modify javadoc for consistency
>
> src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialBlob.java 
> line 337:
> 
>> 335:  * @param bytes the array of bytes to be written to the {@code BLOB}
>> 336:  * value
>> 337:  * @param offset the offset into the array {@code bytes} at which
> 
> Please change all occurrences of  `{@code bytes}` to `{@code byte}s` as this 
> was caught as part of the CSR review.

Sorry for my very slow response.
These `{@code bytes}` point to the `bytes` argument, but should I change it to 
`{@code byte}s`?

-

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v3]

2021-05-24 Thread Mitsuru Kariya
On Tue, 18 May 2021 19:06:56 GMT, Lance Andersen  wrote:

> I have run the JCK tests in addition to to the JTREG Tess to validate there 
> are no additional failures due to these changes

Thanks a lot!

> src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialBlob.java 
> line 308:
> 
>> 306:  * to start writing. The first position is 1;
>> 307:  * must not be less than 1 nor greater than
>> 308:  * the length+1 of this {@code SerialBlob} object.
> 
> Changes such as this require a CSR.  I think I have convinced myself that it 
> is OK to move forward with the CSR.

Would you please create a CSR for me?
Or should I register a CSR at https://bugreport.java.com/bugreport/ ?

-

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v4]

2021-05-24 Thread Mitsuru Kariya
> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
> the following cases:
> 
> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test31)
> 
> 2. `pos - 1 + length > this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully. *1
>(test32)
> 
> 3. `pos == this.length() + 1`
>The original implementation throws `SerialException` but this case should 
> end successfully. *2
>(test33)
> 
> 4. `length < 0`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test34)
> 
> 5. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test35)
> 
> Additionally, fix `SerialClob.setString(long pos, String str, int offset, int 
> length)` in the following cases:
> 
> 1. `offset > str.length()`
>The original implementaion throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test39)
> 
> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test32)
> 
> 3. `pos - 1 + length > this.length()`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *3
>(test40)
> 
> 4. `pos == this.length() + 1`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *4
>(test41)
> 
> 5. `length < 0`
>The original implementation throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test42)
> 
> 6. `offset + length > Integer.MAX_VALUE`
>The original implementation throws `ArrayIndexOutOfBoundsException` (or 
> `OutOfMemoryError` in most cases) but this case should throw 
> `SerialException`.
>(test43)
> 
> 
> The javadoc has also been modified according to the above.
> 
> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob value 
> is reached while writing the array of bytes, then the length of the Blob 
> value will be increased to accommodate the extra bytes."
> 
> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
> pos is greater than the length+1 of the BLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the BLOB value.
> 
> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
> value is eached while writing the given string, then the length of the Clob 
> value will be increased to accommodate the extra characters."
> 
> *4 The documentation of `Clob.setString()` says, "If the value specified for 
> pos is greater than the length+1 of the CLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the CLOB value.

Mitsuru Kariya has updated the pull request incrementally with one additional 
commit since the last revision:

  Modify javadoc for consistency

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/4001/files
  - new: https://git.openjdk.java.net/jdk/pull/4001/files/e4346738..69fb2f4a

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=02-03

  Stats: 38 lines in 2 files changed: 0 ins; 0 del; 38 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4001.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4001/head:pull/4001

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v3]

2021-05-24 Thread Mitsuru Kariya
On Tue, 18 May 2021 18:44:32 GMT, Lance Andersen  wrote:

>> Mitsuru Kariya has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Fix for length + offset > Integer.MAX_VALUE case
>
> src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialBlob.java 
> line 306:
> 
>> 304:  *
>> 305:  * @param pos the position in the SQL BLOB value at 
>> which
>> 306:  * to start writing. The first position is 1;
> 
> When updating the javadoc to use @code, please update all instances for 
> consistency

Sure.

-

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v3]

2021-05-17 Thread Mitsuru Kariya
> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
> the following cases:
> 
> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test31)
> 
> 2. `pos - 1 + length > this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully. *1
>(test32)
> 
> 3. `pos == this.length() + 1`
>The original implementation throws `SerialException` but this case should 
> end successfully. *2
>(test33)
> 
> 4. `length < 0`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test34)
> 
> Additionally, fix `SerialClob.setString(long pos, String str, int offset, int 
> length)` in the following cases:
> 
> 1. `offset > str.length()`
>The original implementaion throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test39)
> 
> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test32)
> 
> 3. `pos - 1 + length > this.length()`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *3
>(test40)
> 
> 4. `pos == this.length() + 1`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *4
>(test41)
> 
> 5. `length < 0`
>The original implementation throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test42)
> 
> 
> The javadoc has also been modified according to the above.
> 
> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob value 
> is reached while writing the array of bytes, then the length of the Blob 
> value will be increased to accommodate the extra bytes."
> 
> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
> pos is greater than the length+1 of the BLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the BLOB value.
> 
> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
> value is eached while writing the given string, then the length of the Clob 
> value will be increased to accommodate the extra characters."
> 
> *4 The documentation of `Clob.setString()` says, "If the value specified for 
> pos is greater than the length+1 of the CLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the CLOB value.

Mitsuru Kariya has updated the pull request incrementally with one additional 
commit since the last revision:

  Fix for length + offset > Integer.MAX_VALUE case

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/4001/files
  - new: https://git.openjdk.java.net/jdk/pull/4001/files/6a0cc1ad..e4346738

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=01-02

  Stats: 26 lines in 4 files changed: 24 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4001.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4001/head:pull/4001

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. [v2]

2021-05-13 Thread Mitsuru Kariya
> Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
> the following cases:
> 
> 1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test31)
> 
> 2. `pos - 1 + length > this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully. *1
>(test32)
> 
> 3. `pos == this.length() + 1`
>The original implementation throws `SerialException` but this case should 
> end successfully. *2
>(test33)
> 
> 4. `length < 0`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test34)
> 
> Additionally, fix `SerialClob.setString(long pos, String str, int offset, int 
> length)` in the following cases:
> 
> 1. `offset > str.length()`
>The original implementaion throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test39)
> 
> 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
> this.length()`
>The original implementation throws `ArrayIndexOutOfBoundsException` but 
> this case should end successfully.
>(test32)
> 
> 3. `pos - 1 + length > this.length()`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *3
>(test40)
> 
> 4. `pos == this.length() + 1`
>The original implementaion throws `SerialException` but this case should 
> end successfully. *4
>(test41)
> 
> 5. `length < 0`
>The original implementation throws `StringIndexOutOfBoundsException` but 
> this case should throw `SerialException`.
>(test42)
> 
> 
> The javadoc has also been modified according to the above.
> 
> *1 The documentation of `Blob.setBytes()` says, "If the end of the Blob value 
> is reached while writing the array of bytes, then the length of the Blob 
> value will be increased to accommodate the extra bytes."
> 
> *2 The documentation of `Blob.setBytes()` says, "If the value specified for 
> pos is greater than the length+1 of the BLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the BLOB value.
> 
> *3 The documentation of `Clob.setString()` says, "If the end of the Clob 
> value is eached while writing the given string, then the length of the Clob 
> value will be increased to accommodate the extra characters."
> 
> *4 The documentation of `Clob.setString()` says, "If the value specified for 
> pos is greater than the length+1 of the CLOB value then the behavior is 
> undefined."
>So, it should work correctly when pos == length+1 of the CLOB value.

Mitsuru Kariya has updated the pull request incrementally with one additional 
commit since the last revision:

  Add check: ensure length >= 0

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/4001/files
  - new: https://git.openjdk.java.net/jdk/pull/4001/files/8849de96..6a0cc1ad

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=00-01

  Stats: 30 lines in 4 files changed: 30 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4001.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4001/head:pull/4001

PR: https://git.openjdk.java.net/jdk/pull/4001


RFR: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert.

2021-05-12 Thread Mitsuru Kariya
Fix `SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)` in 
the following cases:

1. `pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= 
this.length()`
   The original implementation throws `ArrayIndexOutOfBoundsException` but this 
case should end successfully.
   (test31)

2. `pos - 1 + length > this.length()`
   The original implementation throws `ArrayIndexOutOfBoundsException` but this 
case should end successfully. *1
   (test32)

3. `pos == this.length() + 1`
   The original implementation throws `SerialException` but this case should 
end successfully. *2
   (test33)

Additionally, fix `SerialClob.setString(long pos, String str, int offset, int 
length)` in the following cases:

1. `offset > str.length()`
   The original implementaion throws `StringIndexOutOfBoundsException` but this 
case should throw `SerialException`.
   (test39)

2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= 
this.length()`
   The original implementation throws `ArrayIndexOutOfBoundsException` but this 
case should end successfully.
   (test32)

3. `pos - 1 + length > this.length()`
   The original implementaion throws `SerialException` but this case should end 
successfully. *3
   (test40)

4. `pos == this.length() + 1`
   The original implementaion throws `SerialException` but this case should end 
successfully. *4
   (test41)

The javadoc has also been modified according to the above.

*1 The documentation of `Blob.setBytes()` says, "If the end of the Blob value 
is reached while writing the array of bytes, then the length of the Blob value 
will be increased to accommodate the extra bytes."

*2 The documentation of `Blob.setBytes()` says, "If the value specified for pos 
is greater than the length+1 of the BLOB value then the behavior is undefined."
   So, it should work correctly when pos == length+1 of the BLOB value.

*3 The documentation of `Clob.setString()` says, "If the end of the Clob value 
is eached while writing the given string, then the length of the Clob value 
will be increased to accommodate the extra characters."

*4 The documentation of `Clob.setString()` says, "If the value specified for 
pos is greater than the length+1 of the CLOB value then the behavior is 
undefined."
   So, it should work correctly when pos == length+1 of the CLOB value.

-

Commit messages:
 - 8153490:Cannot setBytes() if incoming buffer's length is bigger than number 
of elements we want to insert.

Changes: https://git.openjdk.java.net/jdk/pull/4001/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4001&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8153490
  Stats: 179 lines in 4 files changed: 122 ins; 17 del; 40 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4001.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4001/head:pull/4001

PR: https://git.openjdk.java.net/jdk/pull/4001


Re: Would anyone please reopen JDK-4991002?

2021-05-12 Thread Mitsuru Kariya

Thank you for your quick reply and precise advice.


Once you have signed your OCA and have generated your proposed patch,
feel free to create your PR.


I already have signed the OCA, so I'll start with a PR for an open 
issue, JDK-8153490.


Thanks,

On 2021-05-12 02:59, Lance Andersen wrote:

Hi Mitsuru,

Thank you for your interest in contributing to the OpenJDK project

If you are not an Author, you can file bugs via
https://bugreport.java.com/bugreport/

To contribute fixes,  you will need to sign an Oracle Committer
Agreement(OCA).  Please see https://openjdk.java.net/contribute/ for
more info

Please enter a new issue which you can use to address your
SerialBlob/Clob fixes.  You will also need to  add the tests to verify
the fix to the relevant tests in open/test/jdk/javax/sql/testng/test

 RowSets, in particular the Serialxxx classes, are seldom used (if at
all) as there are better alternatives for an API.

Once you have signed your OCA and have generated your proposed patch,
feel free to create your PR.

Best
Lance


On May 11, 2021, at 9:11 AM, Mitsuru Kariya
 wrote:

Hi,

While reading the source for SerialBlob, I found that
SerialBlob.position() does not work correctly.
So, I searched JBS and found the description in JDK-4991002 point 1,
but it was closed by Cannot Reproduce.

It can be reproduced easily like below.

SerialBlob sb = new SerialBlob(new byte[]{1, 2, 3, 4, 5});
System.out.println(sb.position(new byte[]{1, 3, 5}, 1));

It should output "-1"(not found) but the current implementation
outputs "3"(found at position 3).

So, would anyone please reopen JDK-4991002 for me?
(I cannot reopen it because I don't have an Author role.)

Furthermore, SerialClob has same problem and JDK-4991036 describes
it.
So, may I fix it together?
Or do I need to separate the PR from JDK-4991002?

JDK-4991002:The class javax.sql.rowset.serial.SerialBlob is too
buggy
https://bugs.openjdk.java.net/browse/JDK-4991002

JDK-4991036:The class javax.sql.rowset.serial.SerialClob is too
buggy
https://bugs.openjdk.java.net/browse/JDK-4991036

Please let me know if there is a better place to do so.

Thanks


Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
lance.ander...@oracle.com


SerialBlob.getBytes() may throw ArrayIndexOutOfBoundsException when pos > 1

2021-05-11 Thread Mitsuru Kariya

Hi,

Please see the sample code below.

SerialBlob sb = new SerialBlob(new byte[]{1, 2, 3});
System.out.println(Arrays.toString(sb.getBytes(3, 3)));

I think that it should output "[3]" but the current implementation 
throws ArrayIndexOutOfBoundsException.


If it's worth changing, could anyone submit this issue to JBS for me?
I'm ready to submit a pull request, but I don't have an Author role.

Please let me know if there is a better place to do so.

Thanks


SerialBlob has an inconsistency between equals() and hashCode()

2021-05-11 Thread Mitsuru Kariya

Hi,

Please see the sample code below.

SerialBlob sb1 = new SerialBlob(new byte[]{1, 2, 3});
SerialBlob sb2 = new SerialBlob(new byte[]{1, 2, 3, 4, 5});
sb2.truncate(3);
System.out.println(sb1.equals(sb2));
System.out.println(sb1.hashCode() == sb2.hashCode());

I think that it should output "true" & "true" but the current 
implementation outputs "true" & "false".


I know the use of SerialBlob.hashCode() is uncommon, but I think it is 
better to be fixed.

If it's worth changing, could anyone submit this issue to JBS for me?
I'm ready to submit a pull request, but I don't have an Author role.

Please let me know if there is a better place to do so.

Thanks


Would anyone please reopen JDK-4991002?

2021-05-11 Thread Mitsuru Kariya

Hi,

While reading the source for SerialBlob, I found that 
SerialBlob.position() does not work correctly.
So, I searched JBS and found the description in JDK-4991002 point 1, but 
it was closed by Cannot Reproduce.


It can be reproduced easily like below.

SerialBlob sb = new SerialBlob(new byte[]{1, 2, 3, 4, 5});
System.out.println(sb.position(new byte[]{1, 3, 5}, 1));

It should output "-1"(not found) but the current implementation outputs 
"3"(found at position 3).


So, would anyone please reopen JDK-4991002 for me?
(I cannot reopen it because I don't have an Author role.)

Furthermore, SerialClob has same problem and JDK-4991036 describes it.
So, may I fix it together?
Or do I need to separate the PR from JDK-4991002?

JDK-4991002:The class javax.sql.rowset.serial.SerialBlob is too buggy
https://bugs.openjdk.java.net/browse/JDK-4991002

JDK-4991036:The class javax.sql.rowset.serial.SerialClob is too buggy
https://bugs.openjdk.java.net/browse/JDK-4991036


Please let me know if there is a better place to do so.

Thanks


May I make a pull request for JDK-8153490?

2021-05-11 Thread Mitsuru Kariya

Hi,

While reading the SerialBlob source, I found that it's been over a year 
and a half since the JDK-8153490 was last updated.


Furthermore, according to the documentation of Blog.setBytes() (not 
SerialBlob.setBytes()), there are the following problems:


1. It says "If the end of the Blob value is reached while writing the 
array of bytes, then the length of the Blob value will be increased to 
accommodate the extra bytes."

But the current implementation throws SerialException.

2. It says "If the value specified for pos is greater than the length+1 
of the BLOB value then the behavior is undefined."
So I think that it should work correctly when pos == length+1 of the 
BLOB value.


May I make a pull request for these problems?

Also, if I may, SerialClob.setString() has the same problem, may I fix 
it together?


JDK-8153490:Cannot setBytes() if incoming buffer's length is bigger than 
number of elements we want to insert.

https://bugs.openjdk.java.net/browse/JDK-8153490

Please let me know if there is a better place to do so.

Thanks