I've created 

https://issues.apache.org/struts/browse/WW-1648

and attached a patch.


cilquirm wrote:
> 
> 
> 
> Hi, I think I noticed an NPE in Restful2, which is set as my default
> action mapper. I'd like to resolve it but I'm not sure my logic on the
> matter is correct and hopefully someone on the list can set  me straight :
> 
> The error : 
> 
> java.lang.NullPointerException
> org.apache.struts2.dispatcher.mapper.Restful2ActionMapper.getMapping(Restful2ActionMapper.java:97)
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:393)
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)
> 
> 
> The offending code :
> 
>     public ActionMapping getMapping(HttpServletRequest request,
> ConfigurationManager configManager) {
> 
>         ActionMapping mapping = super.getMapping(request, configManager);
> 
>         String actionName = mapping.getName();
> 
> 
> The logic :
> 
> Since restful2 is subclassed from DefaultActionMapper, the super call does
> the work that the defaultactionmapper would do and then runs its own
> checks.
> 
> The problem happens when you use codebehind and restful2 ( as I am ), and
> a mapping is not returned.  Then, the mapping is null, and getName()
> fails.
> 
> So the solution would be to check mapping for null before proceeding.
> 
> 
> Again, I'm not sure of the intrinsic details of it, but I applied such a
> fix locally and it seems to work smoothly ( though I don't have the
> plethora of tests that maybe others have, but the surefire stuff runs ).
> 
> 
> Please let me know if I am of the right mind, and I'll submit an issue and
> patch.
> 
> 
> Thanks,
> -a
> 
> (oh and sorry for not posting in struts-dev. I don't belong to that list
> yet and this was slightly faster.)
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-S2--possible-NPE-in-Restful2--tf3022218.html#a8400651
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to