Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2827

TextProviderHelper cause a NPE if there is TextProvider object on the stack .

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 2.1.2, 2.1.3
    • 2.1.8
    • None
    • Websphere Portal 6.1

    • Patch

    Description

      <s:text> tag is blowing up if there is a TextProvider on the stack. Seems like bug was introduced by the change in revision 647647. The fix is instead of calling getText with null as default message pattern use the passed in defaultMessage.

      StackTrace
      Uncaught exception thrown in one of the service methods of the servlet: /WEB-INF/jsp/xxxx/xxxx.jsp. Exception thrown : java.lang.NullPointerException
      at java.text.MessageFormat.applyPattern(MessageFormat.java:434)
      at java.text.MessageFormat.<init>(MessageFormat.java:365)
      at com.opensymphony.xwork2.DefaultTextProvider.getText(DefaultTextProvider.java:70)
      at com.opensymphony.xwork2.DefaultTextProvider.getText(DefaultTextProvider.java:111)
      at org.apache.struts2.util.TextProviderHelper.getText(TextProviderHelper.java:62)
      at org.apache.struts2.components.Text.end(Text.java:153)
      at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)

      Patch:

          1. Eclipse Workspace Patch 1.0
            #P struts2
            Index: core/src/main/java/org/apache/struts2/util/TextProviderHelper.java
            ===================================================================
          • core/src/main/java/org/apache/struts2/util/TextProviderHelper.java (revision 702254)
            +++ core/src/main/java/org/apache/struts2/util/TextProviderHelper.java (working copy)
            @@ -60,7 +60,7 @@

      if (o instanceof TextProvider)

      { tp = (TextProvider) o; - msg = tp.getText(key, null, args, stack); + msg = tp.getText(key, defaultMessage, args, stack); break; }

      Attachments

        Activity

          People

            Unassigned Unassigned
            daniel.becheanu Daniel Becheanu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: