Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJ-236] correction on using resultset.getInt on a preparedStatemen…
…t on an signed smallInt negative value.
  • Loading branch information
rusher committed Dec 26, 2015
1 parent 988e83c commit 88c9f30
Show file tree
Hide file tree
Showing 3 changed files with 446 additions and 8 deletions.
Expand Up @@ -334,9 +334,10 @@ private int getTinyInt() throws SQLException {
private int getSmallInt() throws SQLException {
int value = ((rawBytes[0] & 0xff) | ((rawBytes[1] & 0xff) << 8));
if (!columnInfo.isSigned()) {
value = value & 0xffff;
return value & 0xffff;
}
return value;
//short cast here is important : -1 will be received as -1, -1 -> 65535
return (short) value;
}

private long getMediumInt() throws SQLException {
Expand Down Expand Up @@ -1253,7 +1254,7 @@ public boolean getBoolean() {
return false;
}
final String rawVal = new String(rawBytes, StandardCharsets.UTF_8);
return rawVal.equalsIgnoreCase("true") || rawVal.equals("1") || (rawBytes[0] & 0x1) == 1;
return rawVal.equalsIgnoreCase("true") || rawVal.equals("1") || (rawBytes[0] & 0xff) == 1;
}

/**
Expand Down

0 comments on commit 88c9f30

Please sign in to comment.