Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4113018

java.text.MessageFormat.applyPattern works wrong with illegal patterns

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: dfC67450 Date: 02/18/98



      java.text.MessageFormat.applyPattern(String newPattern) changes old pattern
      setting if newPattern is incorrect.

      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.text.*;

      public class Test {
          public static void main (String args[]){
              MessageFormat mf = new MessageFormat("initial pattern");
              String illegalPattern = "format: {0, xxxYYY}";
              System.out.println("pattern before: \"" + mf.toPattern() + "\"");
              System.out.println("illegal pattern: \"" + illegalPattern + "\"");
              try {
                mf.applyPattern(illegalPattern);
              } catch (IllegalArgumentException e) {
              }
              System.out.println("pattern after: \"" + mf.toPattern() + "\"");
          }
      }

      ---------Output from the test---------------------
      pattern before: "initial pattern"
      illegal pattern: "format: {0, xxxYYY}"
      pattern after: "initial {0}pattern"
      --------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            duke J. Duke (Inactive)
            Reporter:
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: