jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Reschke <julian.resc...@gmx.de>
Subject Re: nullability annotations - https://issues.apache.org/jira/browse/OAK-37
Date Fri, 18 May 2012 17:25:21 GMT
On 2012-05-18 13:58, Michael Dürig wrote:
>
> Hi Julian,
>
> Thanks for setting this up. I think this is of great value and we should
> take these warning very serious.
>
> In case anyone wonders how to integrate this with IntelliJ: just enable
> the inspection called "Constants, conditions & exceptions". Took me a
> while to figure this out.
>
> Michael
> ...

Thanks for that.

Here's an example of the problems we need to take care of -- 
PropertyDelegate has:

     public void remove() {
         getParentTree().removeProperty(getName());
     }

     private Tree getParentTree() {
         resolve();
         return parent;
     }

     private synchronized void resolve() {
         parent = sessionDelegate.getTree(parent.getPath());

         if (parent == null) {
             propertyState = null;
         } else {
             String path = PathUtils.concat(parent.getPath(), 
propertyState.getName());
             propertyState = parent.getProperty(PathUtils.getName(path));
         }
     }

So getParentTree() calls resolve(), which in turn can return with parent 
== null.

Yet, remove() assumes the return value of getParentTree is never null.

Best regards, Julian

Mime
View raw message