WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c6c2f85

Browse files
committed
fixed boundary check for index column
1 parent 32bbfc8 commit c6c2f85

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/types/ArrayResultSet.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class ArrayResultSet implements ResultSet {
3939

4040
private final Object array;
4141
private final int length;
42-
private Integer pos;
42+
private int pos;
4343
private boolean closed;
4444
private ResultSetMetaDataImpl metadata;
4545

@@ -184,10 +184,10 @@ public boolean getBoolean(int columnIndex) throws SQLException {
184184
@Override
185185
public byte getByte(int columnIndex) throws SQLException {
186186
if (columnIndex == 1) {
187-
if (pos < Byte.MAX_VALUE) {
187+
if (pos + 1 < Byte.MAX_VALUE) {
188188
return (byte) getRow();
189189
} else {
190-
throw new SQLException("INDEX column value too big and cannot be get as byte");
190+
throw new SQLException("INDEX column value too big and cannot be retrieved as byte");
191191
}
192192
}
193193
return ((Number) getValueAsObject(columnIndex, Byte.class, 0)).byteValue();
@@ -196,10 +196,10 @@ public byte getByte(int columnIndex) throws SQLException {
196196
@Override
197197
public short getShort(int columnIndex) throws SQLException {
198198
if (columnIndex == 1) {
199-
if (pos < Short.MAX_VALUE) {
199+
if (pos + 1 < Short.MAX_VALUE) {
200200
return (short) getRow();
201201
} else {
202-
throw new SQLException("INDEX column value too big and cannot be get as short");
202+
throw new SQLException("INDEX column value too big and cannot be retrieved as short");
203203
}
204204
}
205205
return ((Number) getValueAsObject(columnIndex, Short.class, 0)).shortValue();

0 commit comments

Comments
 (0)