I am using fortify web app, it's pointing an issue for the following code as the method addToSession()
in stores a non-serializable object as an HttpSession
attribute, which can damage application reliability.
public class DataGlob {
String globName;
String globValue;
public void addToSession(HttpSession session) {
session.setAttribute("glob", this);
}
}
and it's recommending me to do the following.
public class DataGlob implements java.io.Serializable {
String globName;
String globValue;
public void addToSession(HttpSession session) {
session.setAttribute("glob", this);
}
}
Do I need the code change as it recommended to me or it's good without change?