3
private void runAsyncImport() {
      Runnable task = () -> runImport(); 
      new Thread(task).start();
}

I am getting sonar issue for the above code, Replace this lambda with a method reference. (sonar.java.source not set. Assuming 8 or greater.)

How to fix it

ucMedia
  • 4,105
  • 4
  • 38
  • 46

1 Answers1

4

If your class has a non-static runImport() method, then you can write like this:

Runnable task = this::runImport;

If the runImport() method is static, then instead of this, write the name of the class, for example if the name of the class is MyClass, then:

Runnable task = MyClass::runImport;
janos
  • 120,954
  • 29
  • 226
  • 236