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 pb stream #5780

Merged
merged 1 commit into from
Feb 24, 2020

Conversation

haiyang1985
Copy link
Member

@haiyang1985 haiyang1985 commented Feb 24, 2020

For Issue: #5781

What is the purpose of the change

Once we are going to extend the serialization, write direct to Hessian InputStream/OutputStream is high efficient on the memroy.

Brief changelog

Currently, the InputStream/OutputStream is not exported. The change is going to export the InputStream/OutputStream from Hessian2ObjectInput and Hessian2ObjectOutput.

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);
      }
    }
  }
}

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@codecov-io
Copy link

codecov-io commented Feb 24, 2020

Codecov Report

Merging #5780 into master will decrease coverage by 0.13%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #5780      +/-   ##
============================================
- Coverage     61.49%   61.36%   -0.14%     
+ Complexity      497      495       -2     
============================================
  Files           979      979              
  Lines         38871    38873       +2     
  Branches       5602     5602              
============================================
- Hits          23905    23853      -52     
- Misses        12351    12394      +43     
- Partials       2615     2626      +11
Impacted Files Coverage Δ Complexity Δ
...ommon/serialize/hessian2/Hessian2ObjectOutput.java 96.55% <0%> (-3.45%) 0 <0> (ø)
...common/serialize/hessian2/Hessian2ObjectInput.java 94.11% <0%> (-5.89%) 0 <0> (ø)
...rg/apache/dubbo/remoting/utils/PayloadDropper.java 46.15% <0%> (-30.77%) 0% <0%> (ø)
...ache/dubbo/remoting/transport/AbstractChannel.java 75% <0%> (-12.5%) 0% <0%> (ø)
...va/org/apache/dubbo/remoting/TimeoutException.java 22.22% <0%> (-11.12%) 0% <0%> (ø)
...che/dubbo/remoting/transport/mina/MinaChannel.java 39.47% <0%> (-10.53%) 15% <0%> (-1%)
...dubbo/remoting/exchange/support/DefaultFuture.java 79.27% <0%> (-9.91%) 0% <0%> (ø)
.../apache/dubbo/rpc/protocol/AsyncToSyncInvoker.java 79.16% <0%> (-8.34%) 0% <0%> (ø)
...ng/transport/dispatcher/all/AllChannelHandler.java 62.06% <0%> (-6.9%) 0% <0%> (ø)
...ng/exchange/support/header/HeartbeatTimerTask.java 73.68% <0%> (-5.27%) 0% <0%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 56f1c18...340fd4f. Read the comment docs.

@chickenlj chickenlj merged commit cca798c into apache:master Feb 24, 2020
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

Successfully merging this pull request may close these issues.

3 participants