Commits

Anonymous committed 5aae320

Issue number: ww-1049

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@724e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

src/java/com/opensymphony/xwork/interceptor/ChainingInterceptor.java

 
 import java.util.*;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 
 /**
  * <!-- START SNIPPET: description -->
  *
  * <pre>
  * <!-- START SNIPPET: example -->
+ * 
  * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
  *     &lt;interceptor-ref name="basicStack"/&gt;
  *     &lt;result name="success" type="chain"&gt;otherAction&lt;/result&gt;
  *     &lt;interceptor-ref name="basicStack"/&gt;
  *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
  * &lt;/action&gt;
+ * 
  * <!-- END SNIPPET: example -->
  * </pre>
  *
  * @author $Author$
+ * @author tm_jee ( tm_jee(at)yahoo.co.uk )
  * @version $Revision$
  */
 public class ChainingInterceptor extends AroundInterceptor {
+	
+	private static final Log _log = LogFactory.getLog(ChainingInterceptor.class);
+	
     Collection excludes;
     Collection includes;
 
 
             Map ctxMap = invocation.getInvocationContext().getContextMap();
             Iterator iterator = list.iterator();
+            int index = 1; // starts with 1, 0 has been removed
             while (iterator.hasNext()) {
+            	index = index + 1;
                 Object o = iterator.next();
-                if (!(o instanceof Unchainable)) {
-                    OgnlUtil.copy(o, invocation.getAction(), ctxMap, excludes, includes);
+                if (o != null) {
+                	if (!(o instanceof Unchainable)) {
+                		OgnlUtil.copy(o, invocation.getAction(), ctxMap, excludes, includes);
+                	}
+                }
+                else {
+                	_log.warn("compound root element at index "+index+" is null");
                 }
             }
         }

src/test/com/opensymphony/xwork/interceptor/ChainingInterceptorTest.java

         assertEquals(bean.getName(), action.getName());
         assertEquals(bean.getCount(), action.getCount());
     }
+    
+    
+    public void testNullCompoundRootElementAllowsProcessToContinue() throws Exception {
+    	// we should not get NPE, but instead get a warning logged.
+    	stack.push(null);
+    	stack.push(null);
+    	stack.push(null);
+    	interceptor.intercept(invocation); 
+    }
+    
 
     protected void setUp() throws Exception {
         super.setUp();