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

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

XMLWordPrintable

    • 1.2beta4
    • sparc
    • solaris_2.5
    • Verified



      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"
      --------------------------------------------------

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: