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

                 Key: WW-2827
                 URL: https://issues.apache.org/struts/browse/WW-2827
             Project: Struts 2
          Issue Type: Bug
         Environment: Websphere Portal 6.1
            Reporter: Daniel Becheanu


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

### 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;
             }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to