You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Carsten Ziegeler <cz...@apache.org> on 2007/01/31 14:40:21 UTC

Strange code in JXPathBindingBase

While looking at our code I came across this rather strange looking
implementation in org.apache.cocoon.forms.binding.JXPathBindingBase

    public boolean isValid() {
        if (this.enclosingLibrary != null) {
            if (parent != null) {
                return parent.isValid();
            }
            return true; // no library used
        }

        try {
            return !this.enclosingLibrary.dependenciesHaveChanged();
        } catch (Exception e) {
            getLogger().error("Error checking dependencies!", e);
            throw new NestableRuntimeException("Error checking
dependencies!", e);
        }
    }

If the try-catch block is reached, this.enclosingLibrary is null! And
this clearly results in an NPE!
So what is wrong here? I guess that the "if" should read:
if ( this.enclosingLibrary == null)
but that's just a guess.

Carsten
-- 
Carsten Ziegeler
http://www.osoco.org/weblogs/rael/