Harmony
  1. Harmony
  2. HARMONY-1244

[classlib][text] AttributedString.addAttribute(null, ...) throws nothing while RI throws NPE

    Details

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

      Description

      Harmony implementation of AttributedString.addAttribute(null, ...) throws nothing while RI throws NPE.

      =============== Spec ======================
      public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value)
      Throws:
      IllegalArgumentException - if the AttributedString has length 0 (attributes cannot be applied to a 0-length range).

      public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value, int beginIndex, int endIndex)
      Throws:
      IllegalArgumentException - if beginIndex is less then 0, endIndex is greater than the length of the string, or beginIndex and endIndex together don't define a non-empty subrange of the string.
      ===================== Test =====================

      import java.text.*;
      import java.util.*;

      public class bug9291 {
      public static void main (String[] args) {
      try

      { new AttributedString("123", new WeakHashMap()).addAttribute(null, new TreeSet()); }

      catch (Exception e)

      { e.printStackTrace(); }

      try

      { new AttributedString("123", new WeakHashMap()).addAttribute(null, new TreeSet(), 0, 1); }

      catch (Exception e)

      { e.printStackTrace(); }

      }
      }

      =============== Output =====================

      RI
      java.lang.NullPointerException
      at java.text.AttributedString.addAttribute(AttributedString.java:286)
      at bug9291.main(bug9291.java:8)
      java.lang.NullPointerException
      at java.text.AttributedString.addAttribute(AttributedString.java:311)
      at bug9291.main(bug9291.java:13)

      Harmony
      <nothing>

      1. 1244-AttributeString.patch
        0.9 kB
        Denis Kishenko
      2. 1244-AttributeStringTest.patch
        1 kB
        Denis Kishenko
      3. 1244.diff
        3 kB
        spark shen

        Activity

        Hide
        Denis Kishenko added a comment -

        patch+test

        Show
        Denis Kishenko added a comment - patch+test
        Hide
        spark shen added a comment -

        The old patch of JIRA 1244 is outdated. I update the patch
        for this JIRA. Would you please try this patch and change the component from none to classlib

        Best regards

        Show
        spark shen added a comment - The old patch of JIRA 1244 is outdated. I update the patch for this JIRA. Would you please try this patch and change the component from none to classlib Best regards
        Hide
        Paulex Yang added a comment -

        Spark and Denis, updated patch applied at revision r, thanks a lot for this enhancement, please verify that the problem is resolved as you expected.

        Show
        Paulex Yang added a comment - Spark and Denis, updated patch applied at revision r, thanks a lot for this enhancement, please verify that the problem is resolved as you expected.
        Hide
        spark shen added a comment -

        Verified at r447694.

        Show
        spark shen added a comment - Verified at r447694.
        Hide
        Denis Kishenko added a comment -

        Verified, thanks

        Show
        Denis Kishenko added a comment - Verified, thanks
        Hide
        Paulex Yang added a comment -

        Verified by Spark and Denis.

        Show
        Paulex Yang added a comment - Verified by Spark and Denis.

          People

          • Assignee:
            Paulex Yang
            Reporter:
            Denis Kishenko
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development