解决可能内存泄漏的问题
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user