Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-2836

[classlib][sql] RI's SerialBlob.setBytes throws ArrayIndexOutOfBoundsException when array index parameters are invalid.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      As discussed in the mailing list, it's more reasonable to throw SerialException instead. Consider following code:
      public void testSetBytes() throws Exception {
      byte[] buf =

      { 1, 2, 3, 4, 5, 6, 7, 8 }

      ;
      byte[] theBytes =

      { 9, 9, 9 }

      ;
      SerialBlob serialBlob = new SerialBlob(buf);
      serialBlob.setBytes (7, theBytes); // ArrayIndexOutOfBoundsException
      serialBlob.setBytes(7, theBytes, 0, 3); // ArrayIndexOutOfBoundsException
      serialBlob.setBytes(7, theBytes, 0, 10); // SerialException
      }
      RI throws ArrayIndexOutOfBoundsException, but according to spec and consistency, it's better throw SerialException.
      Harmony won't follow RI's behaviour for this issue. For Harmony implementation details, please refer to Harmony-2835.
      The tests are also included in Harmony-2835. Thanks!

      Best regards,
      Andrew

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zhanghuangzhu Zhang Huang Zhu
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: