I need a deep copy of List<BaseModelData> . This method is supposed to create it:
Code:
@SuppressWarnings("unchecked")
public static <T> T cloneSerializable(T o) {
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bout);
out.writeObject(o);
out.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream in = new ObjectInputStream(bin);
Object copy = in.readObject();
in.close();
return (T)copy;
} catch (IOException e) {
throw new RuntimeException("Unexpected error", e);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected error", e);
}
}
But when I try to access the model, I get this:
Code:
java.lang.NullPointerException
at com.extjs.gxt.ui.client.data.RpcMap.get(RpcMap.java:132)
at com.extjs.gxt.ui.client.data.BaseModelData.get(BaseModelData.java:65)
Question 1: If you have RpcMap_CustomFieldSerializer, do you still need to declare RpcMap.map as transient?
Question 2: How to modify my method so it correctly clones RpcMap ?