Serializing/deserializing a SIPDIalog


Serializing/deserializing a SIPDIalog

I was trying to serialize and deserialize a gov.nist.javax.sip.stack.SIPDialog object into Cassandra. But the equals comparison on the deserialized object fails when I compare it with the original SIPDialog object I serialized. SO looks like I am missing something here in serialisation. I am using a ByteArraySerializer to read/write the bytes into Cassandra.
//Saving Dialog
MutationBatch mutationBatch = createMutator();
byte[] dialogBytes = SIPDialogEntity.serializeDialog(dialog);

mutationBatch.withRow(SIPDIALOGS, dialogId)

public static byte[] serializeDialog(SIPDialog dialog) throws IOException {

ByteArrayOutputStream bStream = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bStream);
byte[] bytes = bStream.toByteArray();

return bytes;

//Reading Dialog
Column result;
result = getKeySpace().prepareQuery(SIPDIALOGS).getKey(dialogId).getColumn(“dialog”).execute().getResult();
sipDialog = SIPDialogEntity.deserializeDialog(result.getByteArrayValue());

public static SIPDialog deserializeDialog(byte[] byteArrayDialog) throws IOException, ClassNotFoundException {
System.out.println(“DEBUG Reading Dialog Bytes:” + byteArrayDialog );
ByteArrayInputStream bStream = new ByteArrayInputStream(byteArrayDialog);
ObjectInputStream ois = new ObjectInputStream(bStream);
SIPDialog dialog = (SIPDialog) ois.readObject();
return dialog;


Solution 1:

The SIPDialog class doesn’t override the equals method which is why it fails the comparison. Please open an issue in jain sip at

Solution 2:

hmmmm, If SipDialog is your class, you could just skip all the work and use PlayOrm for cassandra ;). Then you don’t need to deal with serializing/deserializing.

If it is not your class, I think I will get them to add a way to add 3rd party beans to be converted to an entity much like Guice does in a binding file so it can bind to an entity that can be saved by PlayOrm. IF you open a ticket on PlayOrm with a request, we could get the feature in probably in as little as 1 week.