public class RegisterRequest implements Serializable {
@NotNull(message = "Register may not be null")
private Object register;
}
I got codeSmell from sonarLing SonarLint: Make "data" transient or serializable.
Because I have Object.class
I can't add in this class implements Serializable
also I can't transient
because I need this object serialize.
How I can fix this codeSmeel by sonar lint?
The thing with Object fields is, those do not implement the
Serializable
interface. SonarQube is saying that you're trying to serialize a field, in this caseObject register
which does not implement the interface. For yourregister
field you should use a custom class which implements theSerializable
interface.Because of this SonarQube is telling you that you should either let
Object
implement theSerializable
interface (which you can't) or mark it withtransient
.