I believe this is false positive. Why is BinaryMessageDecoder treated as an array?
MS: Public static method may expose internal representation by returning array (MS_EXPOSE_REP)
A public static method returns a reference to an array that is part of the static state of the class. Any code that calls this method can freely modify the underlying array. One fix is to return a copy of the array.
[INFO] --- spotbugs-maven-plugin:4.3.0:check (default) @ spotbugs-bug ---
[INFO] BugInstance size is 1
[INFO] Error size is 0
[INFO] Total bugs: 1
[ERROR] Medium: Public static io.github.hejcz.TestClass.getDecoder() may expose internal representation by returning TestClass.DECODER [io.github.hejcz.TestClass] At TestClass.java:[line 16] MS_EXPOSE_REP
package io.github.hejcz;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.specific.SpecificData;
public class TestClass {
private static SpecificData MODEL$ = new SpecificData();
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("");
private static final BinaryMessageDecoder<TestClass> DECODER =
new BinaryMessageDecoder<TestClass>(MODEL$, SCHEMA$);
public static BinaryMessageDecoder<TestClass> getDecoder() {
return DECODER; // spotbugs detects bug in this line
}
}
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<failOnError>true</failOnError>
<includeTests>false</includeTests>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
I believe this is false positive. Why is
BinaryMessageDecodertreated as an array?