title: Sonarlint is giving error on volatile object reference when using double locking for Singleton class in updated 4.1 version
body: <p>I have a already implemented Singleton class earlier which was using double locking mechanism for Singleton instance but we got an SonarLint error of <code>Double-checked locking should not be used (squid:S2168)</code> on double locking code.</p>
  
  <pre><code>public class Singleton {
  
  private static Singleton singleton;
  
  private Singleton() {
  }
  
  public static Singleton getInstance() {
      if (singleton == null) {
          synchronized (Singleton.class) {
              if (singleton == null) {
                  singleton = new Singleton();
              }
          }
      }
      return singleton;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>As a fix of this issue, I thought of putting <code>volatile</code> keyword before Singleton object reference like below.</p>
  
  <pre><code>private static volatile Singleton singleton;
  </code></pre>
  
  <p>But after making this field as volatile SonarLint is giving error <code>Non-primitive fields should not be "volatile" (squid:S3077)</code></p>
  
  <p>Does this mean now it is not good practice to make object reference as volatile as most of the example of singleton available are like mentioned code example?</p>