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

[2.7] fix memory leak #10231

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@
*/
public class Hessian2ObjectInput implements ObjectInput, Cleanable {

private static ThreadLocal<Hessian2Input> INPUT_TL = ThreadLocal.withInitial(() -> {
Hessian2Input h2i = new Hessian2Input(null);
h2i.setSerializerFactory(Hessian2FactoryInitializer.getInstance().getSerializerFactory());
h2i.setCloseStreamOnClose(true);
return h2i;
});

private final Hessian2Input mH2i;

public Hessian2ObjectInput(InputStream is) {
mH2i = INPUT_TL.get();
mH2i.init(is);
mH2i = new Hessian2Input(is);
mH2i.setSerializerFactory(Hessian2FactoryInitializer.getInstance().getSerializerFactory());
mH2i.setCloseStreamOnClose(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@
*/
public class Hessian2ObjectOutput implements ObjectOutput, Cleanable {

private static ThreadLocal<Hessian2Output> OUTPUT_TL = ThreadLocal.withInitial(() -> {
Hessian2Output h2o = new Hessian2Output(null);
h2o.setSerializerFactory(Hessian2FactoryInitializer.getInstance().getSerializerFactory());
h2o.setCloseStreamOnClose(true);
return h2o;
});

private final Hessian2Output mH2o;

public Hessian2ObjectOutput(OutputStream os) {
mH2o = OUTPUT_TL.get();
mH2o.init(os);
mH2o = new Hessian2Output(os);
mH2o.setSerializerFactory(Hessian2FactoryInitializer.getInstance().getSerializerFactory());
mH2o.setCloseStreamOnClose(true);
}

@Override
Expand Down