[EMAIL PROTECTED] wrote:

cziegeler 2003/07/28 23:28:55

Modified: src/java/org/apache/cocoon/components/treeprocessor/sitemap
SwitchSelectNode.java
Log:
Fixing NPE. Thanks to Volker!
Revision Changes Path
1.2 +9 -3 cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SwitchSelectNode.java
Index: SwitchSelectNode.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SwitchSelectNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SwitchSelectNode.java 9 Mar 2003 00:09:22 -0000 1.1
+++ SwitchSelectNode.java 29 Jul 2003 06:28:54 -0000 1.2
@@ -128,6 +128,9 @@
if (this.threadSafeSelector != null) {
Object ctx = this.threadSafeSelector.getSelectorContext(objectModel, resolvedParams);
+ if ( ctx == null ) {
+ return false;
+ }
for (int i = 0; i < this.whenTests.length; i++) {
if (this.threadSafeSelector.select(whenTests[i].resolve(context, objectModel), ctx)) {
@@ -145,9 +148,12 @@
SwitchSelector selector = (SwitchSelector)this.selector.select(this.componentName);
Object ctx = selector.getSelectorContext(objectModel, resolvedParams);
-
+ try {
-
+ if ( ctx == null ) {
+ return false;
+ }
+ for (int i = 0; i < this.whenTests.length; i++) {
if (selector.select(whenTests[i].resolve(context, objectModel), ctx)) {
return invokeNodes(this.whenNodes[i], env, context);



Carsten,


I couldn't find Volker's report, but I think it's the selector's responsibility to handle the case when it returns a null context object and that the sitemap should not enforce a failure in that case. Furthermore, this modification prevents execution of the statements in <map:otherwise> when the context object is null.

What do you think ?

Sylvain

--
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com




Reply via email to