We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/spotbugs/spotbugs/blob/master/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/MultipleInstantiationsOfSingletons.java#L218 lists the criteria for recognizing a class as a Singleton. While already quite sophisticated, it wrongly recognizes some non-singleton classes as singleton. E.g. protobuf-generated classes that contain a builder to create an instance like this (GeneratedMessageV3 is Serializable).
GeneratedMessageV3
Serializable
Here's a manually simplified version of such a class generated by the protoc compiler:
protoc
public final class Person extends com.google.protobuf.GeneratedMessageV3 implements PersonOrBuilder { private static final long serialVersionUID = 0L; private static final Person DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new Person(); } public static Person getDefaultInstance() { return DEFAULT_INSTANCE; } private Person(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { super(builder); } private Person() { name_ = com.google.protobuf.LazyStringArrayList.emptyList(); } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( <--- this method should already be an indicator that it is not a singleton UnusedPrivateParameter unused) { return new Person(); } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements PersonOrBuilder { public Person build() { return new Person(this); } } }
The text was updated successfully, but these errors were encountered:
(Related to #2964)
Sorry, something went wrong.
No branches or pull requests
https://github.com/spotbugs/spotbugs/blob/master/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/MultipleInstantiationsOfSingletons.java#L218 lists the criteria for recognizing a class as a Singleton. While already quite sophisticated, it wrongly recognizes some non-singleton classes as singleton. E.g. protobuf-generated classes that contain a builder to create an instance like this (
GeneratedMessageV3
isSerializable
).Here's a manually simplified version of such a class generated by the
protoc
compiler:The text was updated successfully, but these errors were encountered: