sofastack/sofa-registry

remove redundant volatile

Closed this issue · 0 comments

Your question

There are some volatile variables in the project, but all of its assignment methods use the synchronized keyword.

Your scenes

com.alipay.sofa.registry.common.model.store.Watcher#pushedVersion

image

  public synchronized boolean updatePushedVersion(long v) {
    if (pushedVersion < v) {
      this.pushedVersion = v;
      return true;
    }
    return false;
  }

Your advice

For such variables, the volatile modifier can be removed.

Environment

  • SOFARegistry version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version: