[ 
https://issues.apache.org/struts/browse/WW-2827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46577#action_46577
 ] 

Daniel Becheanu commented on WW-2827:
-------------------------------------

Is not about the fact that you can reproduce it. Is the fact that that code can 
never work. 

"tp.getText(key, null, args, stack)" will always throw an NPE no matter what. 
So the code is wrong. If no one is suppose to go through code path i think 
removal of that code is necessary.

Daniel

> 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
>          Components: Plugin - Portlet, Plugin - Tags
>    Affects Versions: 2.1.2, 2.1.3
>         Environment: Websphere Portal 6.1
>            Reporter: Daniel Becheanu
>             Fix For: 2.1.8
>
>
> <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