Bug #73163 | IndexOutOfBoundsException thrown preparing statement | ||
---|---|---|---|
Submitted: | 1 Jul 2014 14:57 | Modified: | 12 Sep 2014 16:54 |
Reporter: | Johnathan Crawford (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | 5.1.31 | OS: | Linux |
Assigned to: | Filipe Silva | CPU Architecture: | Any |
Tags: | jdbc, StringUtils |
[1 Jul 2014 14:57]
Johnathan Crawford
[1 Jul 2014 14:58]
Johnathan Crawford
Test case
Attachment: insert-bug.zip (application/x-zip-compressed, text), 3.16 KiB.
[1 Jul 2014 15:00]
Johnathan Crawford
Please contact me if further information is required.
[2 Jul 2014 19:58]
Andrej Golovnin
Hi, Johnathan is right. The fix for the issue 72008 introduced a bug in line 2067 in the class StringUtils: ByteBuffer buf = cs.encode(CharBuffer.wrap(value.toCharArray(), offset, offset + length)); It should be: ByteBuffer buf = cs.encode(CharBuffer.wrap(value, offset, offset + length)); As far as I can tell this change was not a part of my patch for 72008. I will attach a patch to fix this issue. Best regards, Andrej Golovnin
[2 Jul 2014 19:59]
Andrej Golovnin
Fixes this issue. (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: StringUtils_bug73163.patch (application/octet-stream, text), 533 bytes.
[6 Jul 2014 10:23]
Filipe Silva
Hi Johnathan, Thank you for this bug report.
[8 Jul 2014 0:34]
Filipe Silva
Hi, This bug was verified as described. And yes, Andrej. It was introduced in the patch for Bug#72008 and for that we apologize. However, as far as I can tell, to fix this we should replace the line you referred by: ByteBuffer buf = cs.encode(CharBuffer.wrap(value.toCharArray(), offset, length)); Regarding the encoding capabilities of the different Java versions there are a few inconsistencies and bugs. That's why this method turned out to be implemented as it is. If you find out something else that is relevant for this issue, please, let us know. Thank you.
[9 Jul 2014 6:54]
Andrej Golovnin
Hi Filipe, > ByteBuffer buf = cs.encode(CharBuffer.wrap(value.toCharArray(), offset, length)); > Regarding the encoding capabilities of the different Java versions there are a few inconsistencies and > bugs. That's why this method turned out to be implemented as it is. If you find out something else that > is relevant for this issue, please, let us know. Thank you. Could please explain, why it is needed to create a char array? As far as I know the Charset#encode(CharBuffer) method does not care about the backend of the used CharBuffer. Please post more information about the problems in the encoding capabilities of the different Java versions, e.g. Java version numbers, example code, links to the bug reports in the Oracle bug database etc. Best regards, Andrej Golovnin
[29 Jul 2014 18:18]
Filipe Silva
Hi Andrej, As you may understand, I cannot delve into an issue not related with the Connector/J or MySQL in here. If you wish, we can discuss this a little further by other means. Thank you, Filipe Silva
[12 Sep 2014 16:54]
Daniel So
Added the following entry to the Connector/J 5.1.33 changelog: "Using Java 6 or later, running LOAD DATA INFILE with a prepared statement resulted in an IndexOutOfBoundsException. This was a regression introduced by an issue in the patch for an old bug, which has now been fixed. (Bug #19171665, Bug #73163) References: This bug is a regression of Bug #72008."