Derby
  1. Derby
  2. DERBY-4738

correct error prompt for nonpositive length in Blob.setBytesX()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: JDBC
    • Labels:
      None

      Description

      In Blob.setBytesX(), when a nonpositive length value (len) is passed in, a SqlException with ClientMessageId of SQLState.BLOB_NONPOSITIVE_LENGTH is created, however, it uses length, a wrong length value, which is still zero here.

      if ( len < 0 )

      { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_NONPOSITIVE_LENGTH), new Integer(length)); }
      1. derby-4738.patch
        0.6 kB
        Yun Lee
      2. derby-4738.stat
        0.1 kB
        Yun Lee
      3. init_length.diff
        0.8 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Hide
          Yun Lee added a comment -

          In the patch, the nonpositive value is set by len.

          Show
          Yun Lee added a comment - In the patch, the nonpositive value is set by len.
          Hide
          Knut Anders Hatlen added a comment -

          Hi Yun. Thanks for the patch. The fix looks correct to me. Did the regression tests run cleanly with patch?

          Perhaps it would also be a good idea to stop setting length to 0 in the beginning of the method, so that the compiler could tell us if someone tries to use the variable before it's initialized.

          Show
          Knut Anders Hatlen added a comment - Hi Yun. Thanks for the patch. The fix looks correct to me. Did the regression tests run cleanly with patch? Perhaps it would also be a good idea to stop setting length to 0 in the beginning of the method, so that the compiler could tell us if someone tries to use the variable before it's initialized.
          Hide
          Knut Anders Hatlen added a comment -

          All the regression tests ran cleanly in my environment.
          Committed revision 961895.

          Show
          Knut Anders Hatlen added a comment - All the regression tests ran cleanly in my environment. Committed revision 961895.
          Hide
          Knut Anders Hatlen added a comment -

          The attached follow-up patch (init_length.diff) removes the initialization of the length variable to 0 from the top of the method, and moves the declaration of the variable down to the point where it's set to its real value. This will make the compiler complain if someone tries to use the length variable before it has been properly initialized.

          Committed revision 961903.

          Show
          Knut Anders Hatlen added a comment - The attached follow-up patch (init_length.diff) removes the initialization of the length variable to 0 from the top of the method, and moves the declaration of the variable down to the point where it's set to its real value. This will make the compiler complain if someone tries to use the length variable before it has been properly initialized. Committed revision 961903.
          Hide
          Yun Lee added a comment -

          Thanks, Knut. Before I attached the patch, I just run BlobAccessTest and it passed. I will run regression tests for a extensive test next time. Thanks for your advice.

          I agree with your patch on moving the declaration of the length variable. More work need to be done on this method, just pointed out in Derby-3898.

          Show
          Yun Lee added a comment - Thanks, Knut. Before I attached the patch, I just run BlobAccessTest and it passed. I will run regression tests for a extensive test next time. Thanks for your advice. I agree with your patch on moving the declaration of the length variable. More work need to be done on this method, just pointed out in Derby-3898.

            People

            • Assignee:
              Yun Lee
              Reporter:
              Yun Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development