Commit 444b099e6945979072a5f1b7b58e2cbd0c11d2f7
1 parent
4673f8f4
refactor: 优化网关子设备不存在的业务逻辑
1、判断网关子设备是否存在,不存在时结束操作。
Showing
1 changed file
with
8 additions
and
1 deletions
@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j; | @@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j; | ||
32 | import org.springframework.util.ConcurrentReferenceHashMap; | 32 | import org.springframework.util.ConcurrentReferenceHashMap; |
33 | import org.springframework.util.StringUtils; | 33 | import org.springframework.util.StringUtils; |
34 | import org.thingsboard.common.util.JacksonUtil; | 34 | import org.thingsboard.common.util.JacksonUtil; |
35 | +import org.thingsboard.server.common.data.DeviceProfile; | ||
35 | import org.thingsboard.server.common.data.yunteng.utils.ByteUtils; | 36 | import org.thingsboard.server.common.data.yunteng.utils.ByteUtils; |
36 | import org.thingsboard.server.common.transport.TransportService; | 37 | import org.thingsboard.server.common.transport.TransportService; |
37 | import org.thingsboard.server.common.transport.TransportServiceCallback; | 38 | import org.thingsboard.server.common.transport.TransportServiceCallback; |
@@ -206,7 +207,13 @@ public class TcpGatewaySessionHandler { | @@ -206,7 +207,13 @@ public class TcpGatewaySessionHandler { | ||
206 | new TransportServiceCallback<GetOrCreateDeviceFromGatewayResponse>() { | 207 | new TransportServiceCallback<GetOrCreateDeviceFromGatewayResponse>() { |
207 | @Override | 208 | @Override |
208 | public void onSuccess(GetOrCreateDeviceFromGatewayResponse msg) { | 209 | public void onSuccess(GetOrCreateDeviceFromGatewayResponse msg) { |
209 | - TcpGatewayDeviceSessionCtx deviceSessionCtx = new TcpGatewayDeviceSessionCtx(context, TcpGatewaySessionHandler.this, msg.getDeviceInfo(), msg.getDeviceProfile(), transportService); | 210 | + TransportDeviceInfo deviceInfo = msg.getDeviceInfo(); |
211 | + DeviceProfile deviceProfile = msg.getDeviceProfile(); | ||
212 | + if(deviceInfo == null || deviceProfile == null){ | ||
213 | + deviceFutures.remove(deviceName); | ||
214 | + return; | ||
215 | + } | ||
216 | + TcpGatewayDeviceSessionCtx deviceSessionCtx = new TcpGatewayDeviceSessionCtx(context, TcpGatewaySessionHandler.this, deviceInfo, deviceProfile, transportService); | ||
210 | if (devices.putIfAbsent(deviceName, deviceSessionCtx) == null) { | 217 | if (devices.putIfAbsent(deviceName, deviceSessionCtx) == null) { |
211 | log.trace("[{}] First got or created device [{}], type [{}] for the gateway session", sessionId, deviceName, deviceType); | 218 | log.trace("[{}] First got or created device [{}], type [{}] for the gateway session", sessionId, deviceName, deviceType); |
212 | SessionInfoProto deviceSessionInfo = deviceSessionCtx.getSessionInfo(); | 219 | SessionInfoProto deviceSessionInfo = deviceSessionCtx.getSessionInfo(); |