Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export hessian InputStream & OutputStream for serialization extension #5781

Closed
2 tasks done
haiyang1985 opened this issue Feb 24, 2020 · 0 comments
Closed
2 tasks done
Milestone

Comments

@haiyang1985
Copy link
Member

haiyang1985 commented Feb 24, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.3
  • Operating System version: macOs
  • Java version: JDK 1.8

Steps to reproduce this issue

We are going to serialize direct to Hessian OutputStream for protobuf extension, and read directly from InputStream. The change is going to export the Hessian InputStream & OutputStream for direct write.

private final Hessian2ObjectOutput delegate;

protected ProtobufObjectOutput(OutputStream os) {
  this.delegate = new Hessian2ObjectOutput(os);
}

void writeBytesForPBObject(Object obj, Class clazz) throws IOException {
  try (OutputStream os = delegate.getOutputStream()) {
    if (obj instanceof MessageLite) {
      try {
        ((MessageLite) obj).writeTo(os);
      } catch (IOException e) {
        throw new RuntimeException("Google PB序列化失败,序列化对象的类型为" + obj.getClass().getName(), e);
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants