-
Notifications
You must be signed in to change notification settings - Fork 628
Closed
Description
After #2934 was fixed, most problems with singletons seem to be solved. There still is one left. I don't know if there's an easy way to fix this - if not, I'll add an exclusion rule in my code.
I have the following record class where SpotBugs still reports a false positive SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR:
record RowInfo(int firstRow, int lastRow) {
private static final RowInfo NONE = new RowInfo(0, -1);
public static RowInfo none() {
return NONE;
}
}
The problem I think is that it's not easy to tell if something should be a singleton or not. And you could implement a singleton as a record, but it is rather usual IMHO. I this example, the static final member is not intended as a singleton instance, but is used as a guard value.
Metadata
Metadata
Assignees
Labels
No labels