opensearch-project / opensearch-project/sql-jdbc
[BUG] [JDBC] GetColumns fails with StringIndexOutOfBoundsException
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 28
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
What is the bug?
Listing columns from index ending with hyphen (example: people-detection-poc-) throws StringIndexOutOfBoundsException.
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 42
at java.lang.String.charAt(String.java:658) ~[?:1.8.0_322]
at com.amazon.opendistroforelasticsearch.jdbc.internal.util.SqlParser.locateCommentEnd(SqlParser.java:59) ~[SpaceNeedleOpendistroforelasticsearchJdbcDriver-1.x.jar:?]
at com.amazon.opendistroforelasticsearch.jdbc.internal.util.SqlParser.countParameterMarkers(SqlParser.java:46) ~[SpaceNeedleOpendistroforelasticsearchJdbcDriver-1.x.jar:?]
at com.amazon.opendistroforelasticsearch.jdbc.PreparedStatementImpl.<init>(PreparedStatementImpl.java:67) ~[SpaceNeedleOpendistroforelasticsearchJdbcDriver-1.x.jar:?]
at com.amazon.opendistroforelasticsearch.jdbc.DatabaseMetaDataImpl$ColumnMetadataStatement.<init>(DatabaseMetaDataImpl.java:1220) ~[SpaceNeedleOpendistroforelasticsearchJdbcDriver-1.x.jar:?]
at com.amazon.opendistroforelasticsearch.jdbc.DatabaseMetaDataImpl.getColumns(DatabaseMetaDataImpl.java:773) ~[SpaceNeedleOpendistroforelasticsearchJdbcDriver-1.x.jar:?]
What is the expected behavior?
Driver should have handled it and return column details.
What is your host/environment?
- OS: [e.g. iOS]
- Version [e.g. 22]
- Plugins
Do you have any screenshots?
If applicable, add screenshots to help explain your problem.
Do you have any additional context?
Add any other context about the problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at SqlParser.locateCommentEnd and countParameterMarkers, then trace the getColumns entry point in DatabaseMetaDataImpl and the PreparedStatementImpl constructor shown in the stack trace. Reproduce the hyphen-terminated index case and verify that getColumns returns column details without StringIndexOutOfBoundsException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100