Commons Lang
  1. Commons Lang
  2. LANG-578

Problem while using simple quotes in ExtendedMessageFormat when a registry is specified

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.4
    • Fix Version/s: 2.5
    • Component/s: lang.text.*
    • Labels:
      None

      Description

      This runs successfully :

      ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''");
      System.out.println(templateFormat.format(new String[] { "MESSAGE" })); 
      

      The result is 'MESSAGE'.

      This raises an error :

      Map<String, FormatFactory> formatFactory = new HashMap<String, FormatFactory>();
              formatFactory.put("formatDate", new FormatFactory() {
      
                  @SuppressWarnings("all")
                  public Format getFormat(String name, String arguments, Locale locale) {
      
                      return new SimpleDateFormat();
                  }
              });
      ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''", , formatFactory);
      System.out.println(templateFormat.format(new String[] { "MESSAGE" })); 
      

      The result is an exception (java heap space).

      way : In appendQuotedString method the code above doesn't seem to increment the index pos before returning

        Activity

        Olivier TERRIEN created issue -
        Olivier TERRIEN made changes -
        Field Original Value New Value
        Description This runs successfully :

        {code:java}
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''");
        System.out.println(templateFormat.format(new String[] { "toto" }));
        {code}

        This raises an error :

        {code:java}
        Map<String, FormatFactory> formatFactory = new HashMap<String, FormatFactory>();
                formatFactory.put("formatDate", new FormatFactory() {

                    @SuppressWarnings("all")
                    public Format getFormat(String name, String arguments, Locale locale) {

                        return new SimpleDateFormat();
                    }
                });
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''", , formatFactory);
        System.out.println(templateFormat.format(new String[] { "toto" }));
        {code}

        *way* : In _appendQuotedString_ method the code bellow doesn't seem to increment the index pos before returning
        This runs successfully :

        {code:java}
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''");
        System.out.println(templateFormat.format(new String[] { "MESSAGE" }));
        {code}

        The result is 'MESSAGE'.

        This raises an error :

        {code:java}
        Map<String, FormatFactory> formatFactory = new HashMap<String, FormatFactory>();
                formatFactory.put("formatDate", new FormatFactory() {

                    @SuppressWarnings("all")
                    public Format getFormat(String name, String arguments, Locale locale) {

                        return new SimpleDateFormat();
                    }
                });
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''", , formatFactory);
        System.out.println(templateFormat.format(new String[] { "MESSAGE" }));
        {code}

        The result is an exception (java heap space).

        *way* : In _appendQuotedString_ method the code bellow doesn't seem to increment the index pos before returning
        Olivier TERRIEN made changes -
        Description This runs successfully :

        {code:java}
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''");
        System.out.println(templateFormat.format(new String[] { "MESSAGE" }));
        {code}

        The result is 'MESSAGE'.

        This raises an error :

        {code:java}
        Map<String, FormatFactory> formatFactory = new HashMap<String, FormatFactory>();
                formatFactory.put("formatDate", new FormatFactory() {

                    @SuppressWarnings("all")
                    public Format getFormat(String name, String arguments, Locale locale) {

                        return new SimpleDateFormat();
                    }
                });
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''", , formatFactory);
        System.out.println(templateFormat.format(new String[] { "MESSAGE" }));
        {code}

        The result is an exception (java heap space).

        *way* : In _appendQuotedString_ method the code bellow doesn't seem to increment the index pos before returning
        This runs successfully :

        {code:java}
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''");
        System.out.println(templateFormat.format(new String[] { "MESSAGE" }));
        {code}

        The result is 'MESSAGE'.

        This raises an error :

        {code:java}
        Map<String, FormatFactory> formatFactory = new HashMap<String, FormatFactory>();
                formatFactory.put("formatDate", new FormatFactory() {

                    @SuppressWarnings("all")
                    public Format getFormat(String name, String arguments, Locale locale) {

                        return new SimpleDateFormat();
                    }
                });
        ExtendedMessageFormat templateFormat = new ExtendedMessageFormat("''{0}''", , formatFactory);
        System.out.println(templateFormat.format(new String[] { "MESSAGE" }));
        {code}

        The result is an exception (java heap space).

        *way* : In _appendQuotedString_ method the code above doesn't seem to increment the index pos before returning
        Olivier TERRIEN made changes -
        Summary Problem with using of simple quotes in ExtendedMessageFormat when a registry is specified Problem while using simple quotes in ExtendedMessageFormat when a registry is specified
        Olivier TERRIEN made changes -
        Resolution Duplicate [ 3 ]
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 3.0 [ 12311714 ]
        Niall Pemberton made changes -
        Fix Version/s 2.5 [ 12314743 ]
        Fix Version/s 3.0 [ 12311714 ]
        Mark Thomas made changes -
        Workflow jira [ 12485741 ] Default workflow, editable Closed status [ 12602436 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Olivier TERRIEN
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development