Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8263453

CachedRowSetImpl.updateObject ignores the scale

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8, 11, 13, 15, 16, 17
    • Fix Version/s: tbd
    • Component/s: core-libs

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            lancea Lance Andersen
            Reporter:
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: