I spent some time looking and... came out empty. I can find docs on how to apply NullAway and CheckerFramework, but nothing for the Spotbugs one... however it seems all that's needed is annotating the methods, see here: https://github.com/spotbugs/spotbugs/issues/954
Cheers Andrea On Sun, Jun 13, 2021 at 10:26 AM Roar Brænden <roar.brenden...@gmail.com> wrote: > Hi, > > My experience with NullPointerExceptions in Geotools suggest that better > Javadocs could make a huge difference. > > The hard part isn't to find why or where you get an NullPointerException. > That will be clear from the stack trace. The hard part is often to figure > out how to properly set the value of a variable to avoid it being null. > "Where did that come from?", is a question that often pop up. > > This would be easier to answer if the documentation expressly says what to > expect for the different parameters, especially when null is disallowed. > Also when a method are using instance variable that shouldn't be null. It > would be nice if the documentation says something about how to set it. > > I do see that a approach with annotation and a library that check the code > at compilation, would be as good as using Optionals. As Geotools are using > SpotBugs, I suppose that would be the best candidate to look into. At first > glance I couldn't figure out how to do to though. If anyone could give me > some directions, I wouldn't mind having a deeper look at it. > > Best regards, > Roar Brænden > > > > 12. jun. 2021 kl. 19:04 skrev Andrea Aime <andrea.a...@geo-solutions.it>: > > Hi, > I'm starting a new thread as Roar raised some interest was raised in null > handling/elimination > in the "cognitive complexity" thread (to avoid derailing it, and giving a > good place to this discussion). > > Roar suggestd the usage of Optional... it's a way, has some drawbacks, > like API break, > using it in the right place, cost of wrapper creation, and so on. Again, > some references: > - > https://medium.com/@yassinhajaj/optionals-are-bad-practices-still-bad-practices-if-everyone-practices-them-6ec5a66c30aa > - https://dzone.com/articles/using-optional-correctly-is-not-optional > > I was wondering about other tools too, like: > - NullAway, a dedicated library by Uber, which builds on top of ErrorProne > and adds null checks (nothing is nullable unless expressly annotated): > https://github.com/uber/NullAway > - SpotBugs CheckForNull annotation > <https://github.com/spotbugs/spotbugs/blob/master/spotbugs-annotations/src/main/java/edu/umd/cs/findbugs/annotations/CheckForNull.java#L26> > (not > 100% sure how it's supposed to be used) > - Some discussion about non null checkers, along with more about Optional > usage, here <https://checkerframework.org/manual/#nullness-related-work> > > The reason I'd suggest looking at those, is that they would not cause an > API break, > actually detect at least some of the issues, and avoid some of the issues > with Optional > > Anyways, just thinking out loud, won't commit my time on this (at least in > the short term). > Hope that somebody else will though :-D > > Cheers > Andrea > > == GeoServer Professional Services from the experts! Visit > http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf > Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa > (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 > http://www.geo-solutions.it http://twitter.com/geosolutions_it > ------------------------------------------------------- *Con riferimento > alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - > Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni > circostanza inerente alla presente email (il suo contenuto, gli eventuali > allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i > destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per > errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le > sarei comunque grato se potesse darmene notizia. This email is intended > only for the person or entity to which it is addressed and may contain > information that is privileged, confidential or otherwise protected from > disclosure. We remind that - as provided by European Regulation 2016/679 > “GDPR” - copying, dissemination or use of this e-mail or the information > herein by anyone other than the intended recipient is prohibited. If you > have received this email by mistake, please notify us immediately by > telephone or e-mail.* > _______________________________________________ > GeoTools-Devel mailing list > GeoTools-Devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-devel > > > -- Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- *Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.*
_______________________________________________ GeoTools-Devel mailing list GeoTools-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel