You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2003/07/29 08:28:55 UTC

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap SwitchSelectNode.java

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);
  
  
  

Re: cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap SwitchSelectNode.java

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Carsten Ziegeler wrote:

>Sylvain Wallez wrote:
>  
>
>>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 ?
>>    
>>
>Ok, Volker wrote it to me privately :) and I haven't thought about it
>when committing.
>  
>

Volker, please report bugs on the list. More eyes on a problem never 
cause harm ;-)

>After thinking, I don't have an idea why the context of a selector could
>be null, so I think this is the error.
>As I'm currently in the release process I will revert the change and release
>the version with the old behaviour.
>
>We can then discuss what's the correct approach.
>  
>

Ok. Preparing the champagne ;-)

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



RE: cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap SwitchSelectNode.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Sylvain Wallez wrote:
> 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 ?
>
Ok, Volker wrote it to me privately :) and I haven't thought about it
when committing.

After thinking, I don't have an idea why the context of a selector could
be null, so I think this is the error.
As I'm currently in the release process I will revert the change and release
the version with the old behaviour.

We can then discuss what's the correct approach.

Thanks
Carsten


Re: cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap SwitchSelectNode.java

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
cziegeler@apache.org 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