You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "Michael Dürig (Created JIRA)" <ji...@apache.org> on 2012/03/22 14:26:22 UTC

[jira] [Created] (OAK-37) Use nullability annotation to enforce/document API contract

Use nullability annotation to enforce/document API contract
-----------------------------------------------------------

                 Key: OAK-37
                 URL: https://issues.apache.org/jira/browse/OAK-37
             Project: Jackrabbit Oak
          Issue Type: Improvement
          Components: core, jcr, mk
            Reporter: Michael Dürig


In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276776#comment-13276776 ] 

Julian Reschke commented on OAK-37:
-----------------------------------

Note that the nullability annotations in edu.umd.cs.findbugs.annotations are marked as deprecated; so maybe we really should use the "JSR305" variant.
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276845#comment-13276845 ] 

Jukka Zitting commented on OAK-37:
----------------------------------

Yes, just go ahead. It doesn't seem to break anything and produces useful information, so no reason to hold back.
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch, nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Stefan Guggisberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Guggisberg updated OAK-37:
---------------------------------

    Component/s:     (was: mk)
    
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch, nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421367#comment-13421367 ] 

Jukka Zitting commented on OAK-37:
----------------------------------

I added the findbugs and checkstyle plugins to the {{pedantic}} profile of our Maven build in revision 1365017. For now they are configured to simply output their findings without causing the build to fail.
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch, nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276834#comment-13276834 ] 

Julian Reschke commented on OAK-37:
-----------------------------------

bq. PS. The Maven dependencies should have a <scope>provided</scope> entry in them. Otherwise they'll show up as transitive dependencies in downstream components. See for example the bndlib dependency for an example of another annotation library we're using.

Done; see attachment. Should I go ahead and commit this, and see how it works in practice once we add more annotations?
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch, nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276668#comment-13276668 ] 

Julian Reschke commented on OAK-37:
-----------------------------------

bq. FindBugs annotations sound good to me as long as they don't introduce a mandatory runtime dependency on the code (which I don't think they do).

For intra-subproject checking they are only needed at compile time. However, I'm not sure how it will work when we use a JAR from another subproject. But let's start simple.

bq. IDE support (IntelliJ, Eclipse, etc.) is nice, but IMHO not essential. The important bit is that we're able to configure our Maven build to check such annotations and fail the build if the explicitly declared rules are broken.

That should be possible but maybe I'll need some hand-holding with that.
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Reschke updated OAK-37:
------------------------------

    Attachment: nullability.patch

Minimal demonstration, showing how to embed the annotations.

Note:

- cross project checking with the FindBugs plugin in Eclipse indeed works

- FindBugs report:
Possible null pointer dereference in org.apache.jackrabbit.oak.jcr.security.user.UserManagerImpl.removeInternalProperty(Node, String) due to return value of called method	UserManagerImpl.java	/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user	line 352	FindBugs Problem (Troubling)

I believe this is something we should do; running FindBugs from the actual Maven build would be the next step
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278684#comment-13278684 ] 

Julian Reschke commented on OAK-37:
-----------------------------------

For Eclipse, I recommend adding the FindBugs plugin. Update site: http://findbugs.cs.umd.edu/eclipse
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch, nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276821#comment-13276821 ] 

Jukka Zitting commented on OAK-37:
----------------------------------

+1 great stuff!

PS. The Maven dependencies should have a <scope>provided</scope> entry in them. Otherwise they'll show up as transitive dependencies in downstream components. See for example the bndlib dependency for an example of another annotation library we're using.
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276780#comment-13276780 ] 

Jukka Zitting commented on OAK-37:
----------------------------------

OK. I'm fine with whatever we can make work reasonably well. We can always adjust things later on if a better solution comes along.
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276649#comment-13276649 ] 

Jukka Zitting commented on OAK-37:
----------------------------------

FindBugs annotations sound good to me as long as they don't introduce a mandatory runtime dependency on the code (which I don't think they do).

IDE support (IntelliJ, Eclipse, etc.) is nice, but IMHO not essential. The important bit is that we're able to configure our Maven build to check such annotations and fail the build if the explicitly declared rules are broken.
                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13271355#comment-13271355 ] 

Julian Reschke commented on OAK-37:
-----------------------------------

I just checked with FindBugs 2.01, and annotating methods with @CheckForNull and @Nonnull seemed to have the desired effect.

That being said, this appears to be a can of worms; JSR-305 is dormant; FindBugs supports the annotation using it's own package + javax.annotation.

IntelliJ is said to support them in "all" packages, but I can't test that.

There's also a Eclipse JDT extension in the works which appears to be configurable with respect to package names (http://wiki.eclipse.org/JDT_Core/Null_Analysis)

In the end we need something that has an acceptable license, and can be automatically checked; FindBugs is probably a candidate for that.

                
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Reschke updated OAK-37:
------------------------------

    Attachment: nullability.patch
    
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Assigned] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Reschke reassigned OAK-37:
---------------------------------

    Assignee: Julian Reschke
    
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Reschke updated OAK-37:
------------------------------

    Attachment: nullability.patch
    
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>         Attachments: nullability.patch, nullability.patch
>
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (OAK-37) Use nullability annotation to enforce/document API contract

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OAK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Reschke updated OAK-37:
------------------------------

    Attachment:     (was: nullability.patch)
    
> Use nullability annotation to enforce/document API contract
> -----------------------------------------------------------
>
>                 Key: OAK-37
>                 URL: https://issues.apache.org/jira/browse/OAK-37
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr, mk
>            Reporter: Michael Dürig
>            Assignee: Julian Reschke
>
> In a discussion about exception handling on the dev list [1] Julian brough up the idea of using nullability annotations in APIs. I think we should decide on which one to use and start using them whereever apropriate. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira