Inspectopedia
 
2024.3

Non-thread-safe 'static' field access

Warning
New
Last modified: 03 December 2024

Reports access to static fields that are of a non-thread-safe type.

When a static field is accessed from an instance method or a non-synchronized block, multiple threads can access that field. This can lead to unspecified side effects, like exceptions and incorrect results.

Example:

You can specify which types should be considered not thread-safe. Only fields with these exact types or initialized with these exact types are reported, because there may exist thread-safe subclasses of these types.