Menu

#348 Support a @WaitLike attribute on methods

3.x
closed-rejected
nobody
5
2017-10-22
2015-09-23
No

Given the backlog of new features, I doubt this would be implemented soon, but I wanted to add it since I couldn't find a duplicate.

I have a couple of methods that are wrappers for Object.wait and Condition.wait, respectively. They do not synchronize or loop themselves, so FindBugs diagnoses bug code "Wa". However, these wrappers have most (if not all) the restrictions of the standard wait methods: they need to be called in a loop, can throw interrupted exceptions, etc. So, preferred behavior would be to check the callers of my wrappers and, if applicable, diagnose "Wa" bugs on the callers.

Of course, I would not expect FindBugs to be able to detect these methods are wait-like itself. Instead, I would like to be able to use an annotation (e.g. @WaitLike) to indicate these methods are wait-like and have the anaylsis behind "Wa" and other bugs applied to them.

I'm manually verified all the current uses of these methods, so the current diagnostics are currently "false positives". I now have the choice of filtering these diagnostics as false positives or leaving these diagnostics on the report and training humans to ignore them. Both risk undiagnosed bugs entering my code base in the future. A @WaitLike attribute would be a great advantage, though it may indirectly depend on other features (like some parts of understanding @Generated annotations).

Thanks for your time, I know it is precious.

Related

Feature Requests: #348

Discussion

  • Tagir Valeev

    Tagir Valeev - 2015-10-04

    Seems that too specific problem. If you have only couple of such methods, you may use @SuppressFBWarning annotation or filter them using XML exclude filter. If you want to process custom annotation, probably you may consider writing your own FindBugs plugin...

     
    • Boyd Stephen Smith Jr.

      I've already suppressed the warnings with an XML file. However, I want to
      propogate all the wait() restrictions outward. My wrappers, must be called in
      a loop, with the appropriate object locked/monitor held, etc. (The wrappers
      "just" adjust the wait time.)

      In particular, I want FindBugs to check new code I write that uses the
      wrappers, and I don't see a way to do that.

      Thanks for taking a look at the bugs though.

      On Sunday, October 04, 2015 10:00:17 you wrote:

      Seems that too specific problem. If you have only couple of such methods, you
      may use @SuppressFBWarning annotation or filter them using XML exclude
      filter. If you want to process custom annotation, probably you may consider
      writing your own FindBugs plugin...


      ** [feature-requests:#348] Support a @WaitLike attribute on methods**

      Status: open
      Group: 3.x
      Labels: attributes
      Created: Wed Sep 23, 2015 09:07 PM UTC by Boyd Stephen Smith Jr.
      Last Updated: Wed Sep 23, 2015 09:07 PM UTC
      Owner: nobody

      Given the backlog of new features, I doubt this would be implemented soon,
      but I wanted to add it since I couldn't find a duplicate.

      I have a couple of methods that are wrappers for Object.wait and
      Condition.wait, respectively. They do not synchronize or loop themselves,
      so FindBugs diagnoses bug code "Wa". However, these wrappers have most (if
      not all) the restrictions of the standard wait methods: they need to be
      called in a loop, can throw interrupted exceptions, etc. So, preferred
      behavior would be to check the callers of my wrappers and, if applicable,
      diagnose "Wa" bugs on the callers.

      Of course, I would not expect FindBugs to be able to detect these methods are
      wait-like itself. Instead, I would like to be able to use an annotation
      (e.g. @WaitLike) to indicate these methods are wait-like and have the
      anaylsis behind "Wa" and other bugs applied to them.

      I'm manually verified all the current uses of these methods, so the current
      diagnostics are currently "false positives". I now have the choice of
      filtering these diagnostics as false positives or leaving these diagnostics
      on the report and training humans to ignore them. Both risk undiagnosed
      bugs entering my code base in the future. A @WaitLike attribute would be a
      great advantage, though it may indirectly depend on other features (like
      some parts of understanding @Generated annotations).

      Thanks for your time, I know it is precious.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/findbugs/feature-requests/348/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Boyd Stephen Smith Jr. ,= ,--. =.
      bss@iguanasuicide.net ((
      /)o o(_))
      ICQ: 514984 YM/AIM: DaTwinkDaddy -'(. .)-'
      http://iguanasuicide.net/ _/

       

      Related

      Feature Requests: #348

  • Andrey Loskutov

    Andrey Loskutov - 2017-10-22
    • Labels: attributes --> attributes, report on spotbugs
    • Status: open --> closed-rejected
     

Log in to post a comment.