Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Positive for SSD_DO_NOT_USE_INSTANCE_LOCK_ON_SHARED_STATIC_DATA #1978

Closed
jpschewe opened this issue Mar 12, 2022 · 3 comments
Closed
Labels

Comments

@jpschewe
Copy link

When locking on the class object the bug SSD_DO_NOT_USE_INSTANCE_LOCK_ON_SHARED_STATIC_DATA is reported. Locking on the class object should be the same as creating a static object to lock on as there is only a single instance of the class object.

public class StaticMethodLock {
  
  private static int importdbCount = 0;

  public static int getNextDBCount() {
    synchronized (StaticMethodLock.class) {
      return importdbCount++;
    }
  }  

}

Reports

M C SSD: Static field "StaticMethodLock.getNextDBCount()" is modified by an instance level StaticMethodLock.getNextDBCount().  At StaticMethodLock.java:[line 7]

Using SpogBugs 4.6.0 with gradle plugin 5.0.5.

java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.2+8-Ubuntu-120.04, mixed mode, sharing)
jpschewe added a commit to jpschewe/fll-sw that referenced this issue Mar 12, 2022
@KengoTODA
Copy link
Member

refs #1926

@gonczmisi could you check this?

@KengoTODA KengoTODA added the bug label Mar 14, 2022
@gonczmisi
Copy link
Contributor

Sure, will take a look into it.

@KengoTODA
Copy link
Member

closed by #1984

jpschewe added a commit to jpschewe/fll-sw that referenced this issue Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants