I have a class MyGenericException
that extends Exception
:
public class MyGenericException extends Exception {
private static final long serialVersionUID = 7332351790980555724L;
private final String code;
public MyGenericException(final String code, final String message) {
super(message);
this.code = code;
}
public MyGenericException(final String message) {
super(message);
this.code = "MY ERROR";
}
}
Then I have another class, called MyBusinessException
that extends MyGenericException
:
public class MyBusinessException extends MyGenericException {
private static final long serialVersionUID = 7332567890980555724L;
public MyBusinessException() {
super("MY_BUSINESS_EXCEPTION_ERROR", "Throwing MyBusinessException!");
}
public MyBusinessException(String code) {
super(code, "Throwing MyBusinessException!");
}
}
I have a warning from Sonarlint on both classes that says: "Remove this serialVersionUID: "serialVersionUID" should not be declared blindly
Why should I remove the serialVersionUID?