Non-thread-safe 'static' field access
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:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
AccessToNonThreadSafeStaticField- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
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.
Inspection options
Here you can find the description of settings available for the Non-thread-safe 'static' field access inspection, and the reference of their default values.
- Non-thread-safe classes
Default value:
[java.text.Format, java.text.DateFormat, java.text.SimpleDateFormat, java.text.MessageFormat, java.text.DecimalFormat, java.text.ChoiceFormat, java.util.Calendar]
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |