Closed dsmiley closed 1 year ago
This should be possible to achieve with the --racerd-ignore-classes
option or corresponding .inferconfig
setting.
Thank you; this was helpful; I managed to ignore certain classes that are frequent culprits. I'll leave it to you to close or not. Ignoring classes is merely a work-around to the problem I posed. The inability to convey that an external class is thread-safe seems like a big/obvious problem to me; ConcurrentHashMap and other java.util.concurrent structures are used a lot in big software projects, in my experience. There's also the Collections.synchronizedMap(new HashMap())
wrapper.
Another work-around I have not tried is to use a 3rd party cache-like utility that does not implement Map. I suspect RacerD has some built-in knowledge of what a Map is (it's in the JDK) but not something custom.
See also #1733 . Closing for now, feel free to reopen if needed.
Good.
I have a Java class that holds a public static final ConcurrentHashMap. CHM is thread-safe but RacerD does not know this (I also read this was the case in a paper about RacerD). RacerD reports a THREAD_SAFETY_VIOLATION due to mutations to this map.
I think the best way to remedy this is to support a configuration file for Infer/RacerD to allow me to designate classes as thread-safe. I am assuming/hoping that RacerD has a concept of a class being thread-safe in the first place.
This approach could also be used as an alternative to specifying
@ThreadSafe(enableChecks=false)
on source code within the project so that I needn't add Infer's custom annotations.