False positive on squid:S864


(JimB) #1

SonarQube 6.7.3
also SonarLint

“::” is reported as an operator which needs parens to clarify precedence.

import java.util.concurrent.Executor;

public class S864 {
    private Executor executor;

    public S864(Executor exParm) {
        executor = (exParm == null) ? Runnable::run : exParm;
    public Executor getExecutor() {
        return executor;

This resolves the issue, but should not be necessary.

        executor = (exParm == null) ? (Runnable::run) : exParm;

Edited: originally reported with wrong squid code. Fixed.

(Nicolas Peru) #2

Hi, thanks a lot for the reproducer, this is indeed a false positive IMO as well : ticket created to handle the issue : https://jira.sonarsource.com/browse/SONARJAVA-2932