Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-703

Check null pointer condition in method convertToByteArray

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-9
    • 1.0-beta-10
    • None
    • None

    Description

      public static byte[] convertToByteArray(Object a) {
      652 byte[] ans = null;
      653
      654 // conservative coding
      655 if (a.getClass().getName().equals("[B"))

      { 656 ans = (byte[]) a; 657 }

      else {
      658 Object[] ia = (Object[]) a;
      659 ans = new byte[ia.length];
      660 for (int i = 0; i < ia.length; i++)

      { in this line a check if ia[i] is null should happen 661 ans[i] = ((Number) ia[i]).byteValue(); 662 }

      663 }
      664 return ans;
      665 }

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            mschaefer mschaefer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: