New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert. #4001
Conversation
…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.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 reached 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.
👋 Welcome back kariya-mitsuru! A progress list of the required criteria for merging this PR into |
@kariya-mitsuru The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
Mailing list message from Lance Andersen on core-libs-dev: I won?t have time to look at this today, might not be until over the weekend. On May 12, 2021, at 2:07 PM, Mitsuru Kariya <github.com+2217224+kariya-mitsuru at openjdk.java.net<mailto:github.com+2217224+kariya-mitsuru at openjdk.java.net>> 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()` 2. `pos - 1 + length > this.length()` 3. `pos == this.length() + 1` Additionally, fix `SerialClob.setString(long pos, String str, int offset, int length)` in the following cases: 1. `offset > str.length()` 2. `pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= this.length()` 3. `pos - 1 + length > this.length()` 4. `pos == this.length() + 1` The javadoc has also been modified according to the above. The items below should would change the spec change, require a CSR and should be looked at separately *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." *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." ------------- Commit messages: Changes: https://git.openjdk.java.net/jdk/pull/4001/files PR: https://git.openjdk.java.net/jdk/pull/4001 [cid:E1C4E2F0-ECD0-4C9D-ADB4-B16CA7BCB7FC at home] Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the changes look reasonable. As mentioned in the comments, a CSR will be required due to some of the wordsmithing cleanup
@@ -305,13 +305,12 @@ public long position(Blob pattern, long start) | |||
* @param pos the position in the SQL <code>BLOB</code> value at which | |||
* to start writing. The first position is <code>1</code>; | |||
* must not be less than <code>1</code> nor greater than | |||
* the length of this <code>SerialBlob</code> object. | |||
* the length+1 of this {@code SerialBlob} object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes such as this require a CSR. I think I have convinced myself that it is OK to move forward with the CSR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please create a CSR for me?
Or should I register a CSR at https://bugreport.java.com/bugreport/ ?
@@ -305,13 +305,12 @@ public long position(Blob pattern, long start) | |||
* @param pos the position in the SQL <code>BLOB</code> value at which | |||
* to start writing. The first position is <code>1</code>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When updating the javadoc to use @code, please update all instances for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
* @param bytes the array of bytes to be written to the <code>BLOB</code> | ||
* value that this <code>Blob</code> object represents | ||
* @return the number of bytes written | ||
* @throws SerialException if there is an error accessing the | ||
* <code>BLOB</code> value; or if an invalid position is set; if an | ||
* invalid offset value is set; | ||
* {@code BLOB} value; or if an invalid position is set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this addresses a typo, this will require a CSR
/csr |
I have run the JCK tests in addition to to the JTREG Tess to validate there are no additional failures due to these changes |
@LanceAndersen has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
Thanks a lot! |
@kariya-mitsuru This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
I hope to get to the CSR this week. Sorry for the delay |
@kariya-mitsuru This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
This is waiting on the CSR which I have to pull together so please keep this open |
@kariya-mitsuru This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
In process |
@kariya-mitsuru This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
* to start reading the bytes. The first offset position is | ||
* <code>0</code>; must not be less than <code>0</code> nor greater | ||
* than the length of the <code>byte</code> array | ||
* @param offset the offset into the array {@code bytes} at which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change all occurrences of {@code bytes}
to {@code byte}s
as this was caught as part of the CSR review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my very slow response.
These {@code bytes}
point to the bytes
argument, but should I change it to {@code byte}s
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my very slow response.
No problem at all. I was delayed in getting the CSR created and finalized.
These
{@code bytes}
point to thebytes
argument, but should I change it to{@code byte}s
?
Yes please make that minor change. Thank you
@kariya-mitsuru This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
/open |
@kariya-mitsuru This pull request is now open |
@kariya-mitsuru This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 46 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@LanceAndersen) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
The pre-submit test seems to have failed because the compiler was not found in some environments. |
You should be OK. Just as an extra sanity check, I will run those tiers internally tomorrow so please stay tuned |
Any chance you can sync up your workspace with master? I am getting errors when I fetch and try to run our internal tests. |
Mach5 tiers 1-3 are clean so you should be OK to integrate your fix |
Thanks a lot! |
/integrate |
@kariya-mitsuru |
/sponsor |
Going to push as commit 63b9f8c.
Your commit was automatically rebased without conflicts. |
@LanceAndersen @kariya-mitsuru Pushed as commit 63b9f8c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Thank you for your cooperation! |
Fix
SerialBlob.setBytes(long pos, byte[] bytes, int offset, int length)
in the following cases:pos - 1 + bytes.length - offset > this.length() && pos - 1 + length <= this.length()
The original implementation throws
ArrayIndexOutOfBoundsException
but this case should end successfully.(test31)
pos - 1 + length > this.length()
The original implementation throws
ArrayIndexOutOfBoundsException
but this case should end successfully. *1(test32)
pos == this.length() + 1
The original implementation throws
SerialException
but this case should end successfully. *2(test33)
length < 0
The original implementation throws
ArrayIndexOutOfBoundsException
but this case should throwSerialException
.(test34)
offset + length > Integer.MAX_VALUE
The original implementation throws
ArrayIndexOutOfBoundsException
(orOutOfMemoryError
in most cases) but this case should throwSerialException
.(test35)
Additionally, fix
SerialClob.setString(long pos, String str, int offset, int length)
in the following cases:offset > str.length()
The original implementaion throws
StringIndexOutOfBoundsException
but this case should throwSerialException
.(test39)
pos - 1 + str.length() - offset > this.length() && pos - 1 + length <= this.length()
The original implementation throws
ArrayIndexOutOfBoundsException
but this case should end successfully.(test32)
pos - 1 + length > this.length()
The original implementaion throws
SerialException
but this case should end successfully. *3(test40)
pos == this.length() + 1
The original implementaion throws
SerialException
but this case should end successfully. *4(test41)
length < 0
The original implementation throws
StringIndexOutOfBoundsException
but this case should throwSerialException
.(test42)
offset + length > Integer.MAX_VALUE
The original implementation throws
ArrayIndexOutOfBoundsException
(orOutOfMemoryError
in most cases) but this case should throwSerialException
.(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.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4001/head:pull/4001
$ git checkout pull/4001
Update a local copy of the PR:
$ git checkout pull/4001
$ git pull https://git.openjdk.java.net/jdk pull/4001/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4001
View PR using the GUI difftool:
$ git pr show -t 4001
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4001.diff