public void writeObject()

in 3-extensions/serialization/dubbo-samples-protobuf-json/protobuf-json-serialization-implement/src/main/java/org/apache/dubbo/sample/protobuf/serialization/ProtobufObjectOutput.java [45:59]


    public void writeObject(Object obj) {
        try {
            Class clazz = obj.getClass();
            writeUTF(clazz.getName());
            if (protobufUtil.canSerializeWithProtobuf(clazz)) {
                writeBytes(serializeToBytes(obj));
            } else {
                delegate.writeObject(obj);
            }
        } catch (Throwable ex) {
            String message =
                    obj == null ? "Unable to serialize object" : "Unable to serialize object for " + obj.getClass().getName();
            throw new ProtobufSerializationException(message, ex);
        }
    }