| Bug #69452 | memory size connection property doesn't support large values well | ||
|---|---|---|---|
| Submitted: | 12 Jun 2013 15:53 | Modified: | 23 Oct 2013 15:48 |
| Reporter: | Jess Balint | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 5.1 | OS: | Any |
| Assigned to: | Filipe Silva | CPU Architecture: | Any |
[12 Jun 2013 15:54]
Jess Balint
test case
Attachment: MemorySizeParsingBug.java (text/x-java), 666 bytes.
[12 Jun 2013 15:55]
Jess Balint
expected output: locatorFetchBufferSize is 2147483648 locatorFetchBufferSize is 1073741824
[23 Oct 2013 15:48]
Daniel So
Added the following entry to the Connector/J 5.1.27 changelog: When setting a connection property with a value for blobSendChuckSize, largeRowSizeThreshold, or locatorFetchBufferSize, the suffix “G” was not recognized and caused an error to be thrown. With this fix, Connector/J now supports using “GB” for gigabyte for the purpose.

Description: Setting a connection property with a memory size value can be done for blobSendChuckSize, largeRowSizeThreshold, or locatorFetchBufferSize A suffix of K,M,G is allowed to specify a memory size. Capital "G" doesn't work: Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1768) at com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty.initializeFrom(ConnectionPropertiesImpl.java:539) Values of 2g will overflow signed integer, resulting in a value of -2147483648 How to repeat: see testcase Suggested fix: If gigabyte size values are to be supported, they should work - class MemorySizeConnectionProperty extends IntegerConnectionProperty implements Serializable { + class MemorySizeConnectionProperty extends LongConnectionProperty implements Serializable { @@ -513,7 +529,6 @@ extractedValue = extractedValue.substring(0, indexOfK); } else if (extractedValue.endsWith("m") //$NON-NLS-1$ || extractedValue.endsWith("M") //$NON-NLS-1$ - || extractedValue.endsWith("G") //$NON-NLS-1$ || extractedValue.endsWith("mb") //$NON-NLS-1$ || extractedValue.endsWith("Mb") //$NON-NLS-1$ || extractedValue.endsWith("mB")) { //$NON-NLS-1$