private void writeObject(ObjectOutputStream out) throws IOException { // Temporally replaces the properties to write only serializable values into the stream DefaultMuleSession copy = new DefaultMuleSession(this); copy.removeNonSerializableProperties(); Map<String, TypedValue> backupProperties = properties; try { properties = copy.properties; out.defaultWriteObject(); } finally { properties = backupProperties; } }