modernizer-maven-plugin
modernizer-maven-plugin copied to clipboard
RFC: Warn about use of methods that might block indefinitely
This is more of an idea than an actual issue, so by all means shoot me down :)
Basically I'm currently reading through 'Release It' (http://www.amazon.com/dp/0978739213/), and one of the stability anti-patterns there is to not have proper timeouts (and handling of those). At least some of those are caused by the use of methods such as Object#wait(), so I was wondering whether modernizer could not help with that issue by flagging those uses (and suggest to use methods with a timeout).
Now, some issues I see immediately:
- There might be reviewed-and-approved uses of those methods, so there needs to be an easy way to mark those as acceptable. (see https://github.com/andrewgaul/modernizer-maven-plugin/issues/3)
- Not every user of modernizer might want to have those checks, especially since fixing the issues can be quite a bit of work, so it would be good to have those in a separate, optional, rules set (see https://github.com/andrewgaul/modernizer-maven-plugin/issues/22)
- Coming up with a list of those methods will be quite some work as well: It's not just synchronization methods, but for example also things like Sockets, URL connections, Jersey clients ... and for some of those the way to set a timeout is with an additional method call.
What do you think? Is this a realistic use for modernizer, or is it too far out-of-scope?
I think laying the foundation with #22 would be the best way to start this. That way users can experiment with the suggested violations and we can get some feedback on more popular anti-patterns.
@ankon I know this discussion is 4 years old but IMHO the rules you describe should be part of PMD Java Rules