解决可能内存泄漏的问题

This commit is contained in:
heavyrian2012
2022-02-22 15:31:50 +08:00
parent 22708caaaa
commit d090244be9
@@ -165,14 +165,17 @@ public class Qos1PublishHandler extends QosPublishHandler {
if (session != null && session.getUsername().equals(fromUser)) { if (session != null && session.getUsername().equals(fromUser)) {
if (data.length > 7*1024 && session.getMqttVersion().protocolLevel() >= MqttVersion.Wildfire_1.protocolLevel()) { if (data.length > 7*1024 && session.getMqttVersion().protocolLevel() >= MqttVersion.Wildfire_1.protocolLevel()) {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip; GZIPOutputStream gzip = null;
try { try {
gzip = new GZIPOutputStream(out); gzip = new GZIPOutputStream(out);
gzip.write(data); gzip.write(data);
gzip.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Utility.printExecption(LOG, e); Utility.printExecption(LOG, e);
} finally {
if(gzip != null) {
gzip.close();
}
} }
data = out.toByteArray(); data = out.toByteArray();
code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code; code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code;