Skip to content

Commit

Permalink
update: 修复一个NPE错误 & 1.0.7-netty
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizzercn committed Nov 27, 2018
1 parent 38f0da3 commit 7dab8e9
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion mqtt-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mqtt-wk</artifactId>
<groupId>cn.wizzer</groupId>
<version>1.0.6-netty</version>
<version>1.0.7-netty</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion mqtt-broker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mqtt-wk</artifactId>
<groupId>cn.wizzer</groupId>
<version>1.0.6-netty</version>
<version>1.0.7-netty</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion mqtt-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mqtt-wk</artifactId>
<groupId>cn.wizzer</groupId>
<version>1.0.6-netty</version>
<version>1.0.7-netty</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion mqtt-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mqtt-wk</artifactId>
<groupId>cn.wizzer</groupId>
<version>1.0.6-netty</version>
<version>1.0.7-netty</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class SessionStoreService implements ISessionStoreService {
public void put(String clientId, SessionStore sessionStore) {
//SessionStore对象不能正常转为JSON,使用工具类类解决
NutMap nutMap = StoreUtil.transPublishToMapBeta(sessionStore);
redisService.set(CACHE_PRE + clientId, JSON.toJSONString(nutMap));
if (nutMap != null)
redisService.set(CACHE_PRE + clientId, JSON.toJSONString(nutMap));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ public static NutMap transPublishToMapBeta(SessionStore store) {
sessionStore.addv("qosLevel", msg.fixedHeader().qosLevel().value());
sessionStore.addv("isRetain", msg.fixedHeader().isRetain());
sessionStore.addv("remainingLength", msg.fixedHeader().remainingLength());

sessionStore.addv("topicName", msg.variableHeader().topicName());
sessionStore.addv("packetId", msg.variableHeader().packetId());
sessionStore.addv("msg", true);
sessionStore.addv("hasWillMessage", true);
}

return sessionStore;
Expand All @@ -43,24 +42,28 @@ public static NutMap transPublishToMapBeta(SessionStore store) {
return null;
}


public static SessionStore mapTransToPublishMsgBeta(NutMap store) {
SessionStore sessionStore = new SessionStore();
String payload = store.getString("payload");
ByteBuf buf = ByteBufUtil.writeUtf8(ByteBufAllocator.DEFAULT, payload);
MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(
MqttMessageType.valueOf(store.getInt("messageType")),
store.getBoolean("isDup"),
MqttQoS.valueOf(store.getInt("qosLevel")),
store.getBoolean("isRetain"),
store.getInt("remainingLength"));
MqttPublishVariableHeader mqttPublishVariableHeader = new MqttPublishVariableHeader(store.getString("topicName"),
store.getInt("packetId"));
MqttPublishMessage mqttPublishMessage = new MqttPublishMessage(mqttFixedHeader, mqttPublishVariableHeader, buf);
if (store.getBoolean("hasWillMessage",false)) {
String payload = store.getString("payload");
ByteBuf buf = ByteBufUtil.writeUtf8(ByteBufAllocator.DEFAULT, payload);
MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(
MqttMessageType.valueOf(store.getInt("messageType")),
store.getBoolean("isDup"),
MqttQoS.valueOf(store.getInt("qosLevel")),
store.getBoolean("isRetain"),
store.getInt("remainingLength"));

MqttPublishVariableHeader mqttPublishVariableHeader = new MqttPublishVariableHeader(store.getString("topicName"),
store.getInt("packetId"));

MqttPublishMessage mqttPublishMessage = new MqttPublishMessage(mqttFixedHeader, mqttPublishVariableHeader, buf);
sessionStore.setWillMessage(mqttPublishMessage);
}
sessionStore.setChannelId(store.getString("channelId"));
sessionStore.setClientId(store.getString("clientId"));
sessionStore.setCleanSession(store.getBoolean("cleanSession"));
sessionStore.setWillMessage(mqttPublishMessage);
return sessionStore;
}

}
4 changes: 2 additions & 2 deletions mqtt-zoo/mqtt-test-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>cn.wizzer</groupId>
<artifactId>mqtt-test-kafka</artifactId>
<version>1.0.3-netty</version>
<version>1.0.7-netty</version>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<properties>
<mqttwk.version>1.0.3-netty</mqttwk.version>
<mqttwk.version>1.0.7-netty</mqttwk.version>
<nutzboot.version>2.3-SNAPSHOT</nutzboot.version>
<netty.version>4.1.28.Final</netty.version>
<fastjson.version>1.2.49</fastjson.version>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>cn.wizzer</groupId>
<artifactId>mqtt-wk</artifactId>
<packaging>pom</packaging>
<version>1.0.6-netty</version>
<version>1.0.7-netty</version>
<name>MqttWk</name>
<modules>
<module>mqtt-common</module>
Expand All @@ -15,7 +15,7 @@
<module>mqtt-store</module>
</modules>
<properties>
<mqttwk.version>1.0.6-netty</mqttwk.version>
<mqttwk.version>1.0.7-netty</mqttwk.version>
<nutzboot.version>2.3-SNAPSHOT</nutzboot.version>
<netty.version>4.1.28.Final</netty.version>
<fastjson.version>1.2.49</fastjson.version>
Expand Down

0 comments on commit 7dab8e9

Please sign in to comment.