Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
/** This class is not thread-safe */
public final class CountHits {
  private static int counter;

  public void incrementCounter() {
    counter++;
  }
}

...

Code Block
bgColor#ccccff
/** This class is thread-safe */
public final class CountHits {
  private static int counter;
  private static final Object lock = new Object();

  public void incrementCounter() {
    synchronized (lock) {
      counter++;
    }
  }
}

...

Failure to internally synchronize access to static fields that can be modified by untrusted code risks incorrect synchronization because the author of the untrusted code can inadvertently or maliciously ignore the synchronization policy (whether inadvertently or maliciously).

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

LCK05-J

low

probable

medium

P4

L3

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ec17eb2cfefaf0b6-1996e7d2-46504d5f-8d529155-38ff08d63039854c412c3f14"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8a104662defd4fc4-104d0c7b-45ff4c0b-89a8b1e2-de7a0a4cfd60880aab0034f1"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 67. Avoid excessive synchronization

]]></ac:plain-text-body></ac:structured-macro>

...