Closed ghost closed 1 year ago
From SpotBugs:
The offending method:
@Override public boolean equals(Object _o) { return _o.getClass().equals(MethodTuple.class) && ((MethodTuple) _o).name.equals(this.name) && ((MethodTuple) _o).sig.equals(this.sig); }
SpotBugs is correct, _o needs a null guard (by convention). The IDE generates the following code for hashCode, equals, and the constructor:
_o
null
hashCode
equals
public MethodTuple(final String _name, final String _sig) { name = _name; sig = Objects.requireNonNullElse(_sig, ""); logger.trace("new MethodTuple({}, {})", name, sig); } @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final MethodTuple that = (MethodTuple) o; return Objects.equals(name, that.name) && Objects.equals(sig, that.sig); } @Override public int hashCode() { return Objects.hash(name, sig); }
From SpotBugs:
The offending method:
SpotBugs is correct,
_o
needs anull
guard (by convention). The IDE generates the following code forhashCode
,equals
, and the constructor: