thswlsqls opened a new issue, #39134:
URL: https://github.com/apache/shardingsphere/issues/39134
## Bug Report
### Which version of ShardingSphere did you use?
master @ 7568693e8ee
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
Proxy
### Expected behavior
Binding an empty PostgreSQL array literal `{}` as a parameter decodes to a
zero-length array for every array type.
### Actual behavior
Decoding `{}` throws `StringIndexOutOfBoundsException` for all seven array
types (int2/int4/int8/float4/float8/bool/string).
### Reason analyze (If you can)
`PostgreSQLArrayParameterDecoder.decodeText()`
(`database/protocol/dialect/postgresql/.../bind/protocol/PostgreSQLArrayParameterDecoder.java`)
computes the inner content `value.substring(1, value.length() - 1)`, which is
`""` for `{}`. On JDK 8 `"".split(",")` returns `[""]` (length 1), not an empty
array, so the stream calls `decodeElementText("")`, whose first line runs
`"".charAt(0)` and throws. All seven public decode methods delegate to this
shared method, so all crash.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
Through the Proxy PostgreSQL front-end, bind an empty array parameter.
`PostgreSQLStringArrayBinaryProtocolValue.read()` calls the decoder with
`isBinary = '{' != bytes[0]`; for `{}`, `bytes[0] == '{'`, so the text path
runs and crashes.
### Example codes for reproduce this issue (such as a github link).
N/A
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]