SonarQubeCommunity/sonar-jira

java.lang.ClassCastException thrown after making squid:S1612 changes.

MadAboutProgramming opened this issue · 0 comments

squid:S1612 (Lambdas should be replaced with method references)

I have something called (value -> (value != null) in my project, But sonarQube recommended to change (Objects::nonNull).

After making above changes application stop working by throwing the java.lang.ClassCastException.

Example:

DataStream configurations = env
.addSource(createConfigurations(kafkaProps))
.uid(Constants.KAFKA_SOURCE)
.filter(value -> (value != null));

Made the changes to

DataStream configurations = env
.addSource(createConfigurations(kafkaProps))
.uid(Constants.KAFKA_SOURCE)
.filter(Objects::nonNull));

Exception: java.lang.ClassCastException