Skip to content

Commit

Permalink
增加了安全内存回收检测
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Aug 12, 2016
1 parent 99bdf8e commit 9f8953a
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ public class HproseSerialization implements Serialization {

@Override
public byte[] serialize(Object data) throws IOException {
ByteBufferStream stream = new ByteBufferStream();
HproseWriter writer = new HproseWriter(stream.getOutputStream());
writer.serialize(data);
byte[] result = stream.toArray();
stream.close();
return result;
ByteBufferStream stream = null;
try {
stream = new ByteBufferStream();
HproseWriter writer = new HproseWriter(stream.getOutputStream());
writer.serialize(data);
byte[] result = stream.toArray();
return result;
}
finally {
if (stream != null) {
stream.close();
}
}
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit 9f8953a

Please sign in to comment.