-
Bug
-
Resolution: Unresolved
-
P4
-
8, 11, 13, 15, 16, 17
SonarCloud reports the following problem:
The return value of "setScale" must be used.
public void updateObject(int columnIndex, Object x, int scale) throws SQLException {
// sanity check.
checkIndex(columnIndex);
// make sure the cursor is on a valid row
checkCursor();
int type = RowSetMD.getColumnType(columnIndex);
if (type == Types.DECIMAL || type == Types.NUMERIC) {
((java.math.BigDecimal)x).setScale(scale); // <--- here
}
getCurrentRow().setColumnObject(columnIndex, x);
}
BigDecimal.setScale returns the updated BigDecimal, and it should be used instead. I.e. with:
x = ((java.math.BigDecimal)x).setScale(scale);
This bug predates OpenJDK history.
The return value of "setScale" must be used.
public void updateObject(int columnIndex, Object x, int scale) throws SQLException {
// sanity check.
checkIndex(columnIndex);
// make sure the cursor is on a valid row
checkCursor();
int type = RowSetMD.getColumnType(columnIndex);
if (type == Types.DECIMAL || type == Types.NUMERIC) {
((java.math.BigDecimal)x).setScale(scale); // <--- here
}
getCurrentRow().setColumnObject(columnIndex, x);
}
BigDecimal.setScale returns the updated BigDecimal, and it should be used instead. I.e. with:
x = ((java.math.BigDecimal)x).setScale(scale);
This bug predates OpenJDK history.