-
Notifications
You must be signed in to change notification settings - Fork 14
Hessian serializer #4
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
base: master
Are you sure you want to change the base?
Conversation
2131854
to
88b50c7
Compare
bcabd3a
to
ad42513
Compare
According to this, "The efficiency of Hessian 2.0 is about twice that of java.io serialization." |
My company has been using this in production for months without issue. |
That being said, this does add an extra Maven dependency. If that is problematic, it could be split to another project or we could just demonstrate how to use it in the docs. |
Ideally, we'd have to generate another jar with the serializer so that people could decide whether or not to include that dependency. In the first place, I could live if we simply include the serializer in the main library. |
public byte[] serialize(Object obj) { | ||
try { | ||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||
Hessian2Output out = new Hessian2Output(bos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Hessian2Output implements java.lang.AutoCloseable, could you please use a try-with-reource block?
It not, you should add another try block and close the stream in case an exception is raised.
Hessian2Input in = new Hessian2Input(bin); | ||
in.startMessage(); | ||
|
||
toReturn = in.readObject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should close the stream once it has been read. Please also consider the comment made on the serialize() part.
@danielprplt I've added code to make sure that the input and output streams are closed. |
d59bb4b
to
5ba03fa
Compare
5ba03fa
to
8d27dfb
Compare
@danomatic Could you resolve the conflicts present in your branch? In any case, thank you for your work. |
Based on the
custom-serializer
branch. Adds an additional serializer,HessianSerializer
, that should be more performant and avoid some of the issues we experienced withJavaSerializer
.