Browse Source

Merge pull request #875 from mp-loki/master

Fix for UnsupportedOperationException: JsonNull in case if device typ…
pull/881/head
Igor Kulikov 8 years ago
committed by GitHub
parent
commit
d9b650e7d8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/session/GatewaySessionCtx.java

3
transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/session/GatewaySessionCtx.java

@ -17,6 +17,7 @@ package org.thingsboard.server.transport.mqtt.session;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import io.netty.channel.ChannelHandlerContext;
@ -240,7 +241,7 @@ public class GatewaySessionCtx {
private String getDeviceType(JsonElement json) throws AdaptorException {
JsonElement type = json.getAsJsonObject().get("type");
return type == null ? DEFAULT_DEVICE_TYPE : type.getAsString();
return type == null || type instanceof JsonNull ? DEFAULT_DEVICE_TYPE : type.getAsString();
}
private JsonElement getJson(MqttPublishMessage mqttMsg) throws AdaptorException {

Loading…
Cancel
Save