public void writeObject(final ObjectDataOutput out, final Object obj) { final boolean isNull = obj == null; try { out.writeBoolean(isNull); if (isNull) { return; } final SerializerAdapter serializer = serializerFor(obj.getClass()); if (serializer == null) { if (active) { throw new HazelcastSerializationException( "There is no suitable serializer for " + obj.getClass()); } throw new HazelcastInstanceNotActiveException(); } out.writeInt(serializer.getTypeId()); if (obj instanceof Portable) { final Portable portable = (Portable) obj; ClassDefinition classDefinition = serializationContext.lookupOrRegisterClassDefinition(portable); classDefinition.writeData(out); } serializer.write(out, obj); } catch (Throwable e) { handleException(e); } }