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 | 32 | import org.springframework.util.ConcurrentReferenceHashMap; |
33 | 33 | import org.springframework.util.StringUtils; |
34 | 34 | import org.thingsboard.common.util.JacksonUtil; |
35 | +import org.thingsboard.server.common.data.DeviceProfile; | |
35 | 36 | import org.thingsboard.server.common.data.yunteng.utils.ByteUtils; |
36 | 37 | import org.thingsboard.server.common.transport.TransportService; |
37 | 38 | import org.thingsboard.server.common.transport.TransportServiceCallback; |
... | ... | @@ -206,7 +207,13 @@ public class TcpGatewaySessionHandler { |
206 | 207 | new TransportServiceCallback<GetOrCreateDeviceFromGatewayResponse>() { |
207 | 208 | @Override |
208 | 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 | 217 | if (devices.putIfAbsent(deviceName, deviceSessionCtx) == null) { |
211 | 218 | log.trace("[{}] First got or created device [{}], type [{}] for the gateway session", sessionId, deviceName, deviceType); |
212 | 219 | SessionInfoProto deviceSessionInfo = deviceSessionCtx.getSessionInfo(); | ... | ... |