Harmony
  1. Harmony
  2. HARMONY-149

java.nio.charset.Charset.forName(name) return different reference value when requiring the same Charset.

    Details

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

      Description

      java.nio.charset.Charset.forName(name) returns different reference value when requiring the same Charset.
      However, RI always returns the same reference for the same Charset, no matter using "alias" or "canonical" name as parameter.
      RI 5.0 passes the following test case, while Harmony fails.

      =============================== Test case ====================
      /*

      • test forName: invoke forName two times with the same canonical name,
      • it should return the same reference.
        */
        public void testForName_TwoSameRef1() { Charset cs1 = Charset.forName("UTF-8"); Charset cs2 = Charset.forName("UTF-8"); assertSame(cs1,cs2); }

      /*

      • test forName: invoke forName two times for the same Charset using canonical name and alias,
      • it should return the same reference.
        */
        public void testForName_TwoSameRef2() { Charset cs1 = Charset.forName("ASCII"); Charset cs2 = Charset.forName("US-ASCII"); assertSame(cs1,cs2); }

        Activity

        Hide
        Tim Ellison added a comment -

        Verified by Richard

        Show
        Tim Ellison added a comment - Verified by Richard
        Hide
        Richard Liang added a comment -

        Hello Tim,

        The fix looks good. Thanks a lot.

        Show
        Richard Liang added a comment - Hello Tim, The fix looks good. Thanks a lot.
        Hide
        Tim Ellison added a comment -

        Richard,

        Fixed in NIO_CHAR module java.nio.charset.Charset at repo revision 383867.

        Take a look at how I changed the test case to fit in with the test naming convention.

        Please check that the patch was applied as you expected.

        Show
        Tim Ellison added a comment - Richard, Fixed in NIO_CHAR module java.nio.charset.Charset at repo revision 383867. Take a look at how I changed the test case to fit in with the test naming convention. Please check that the patch was applied as you expected.
        Hide
        Richard Liang added a comment -

        Would you please have a try and apply the patch on Charset.java ? Thanks a lot!
        To apply patch, simply click "Team"->"Apply patch...".

        Show
        Richard Liang added a comment - Would you please have a try and apply the patch on Charset.java ? Thanks a lot! To apply patch, simply click "Team"->"Apply patch...".

          People

          • Assignee:
            Tim Ellison
            Reporter:
            Richard Liang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development