Fix for UnsupportedOperationException: JsonNull in case if device type arrives as null
This commit is contained in:
parent
1f58c1b0d6
commit
489a1a6b62
@ -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…
x
Reference in New Issue
Block a user