I have a serializable class that extends Servlet
public class FileDownload extends HttpServlet{
@SuppressWarnings("compatibility:6754389671327954013")
private static final long serialVersionUID = 1L;
private ResultSet rset;
......
}
My Question is:
Is the rset object automatically converted as transient at compile- or run-time? or do I have to mark it explicitly as transient? (That is a warning brought up from my IDE JDeveloper).
No, the field is not neglected by serialization – you’ll get a
java.io.NotSerializableExceptionif you try to serialize an instance ofFileDownload. Mark ittransient. Btw, what is aResultSetdoing as a field in aServlet? This is not thread-safe.ResultSetsshould be local variables only, in any context.