fixed NPE
This commit is contained in:
parent
77b9a8c1af
commit
a9151b5100
@ -278,8 +278,8 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
|
||||
public LwM2mClient getClientBySessionInfo(TransportProtos.SessionInfoProto sessionInfo) {
|
||||
LwM2mClient lwM2mClient = null;
|
||||
UUID sessionId = new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB());
|
||||
Predicate<LwM2mClient> isClientFilter = c ->
|
||||
sessionId.equals((new UUID(c.getSession().getSessionIdMSB(), c.getSession().getSessionIdLSB())));
|
||||
Predicate<LwM2mClient> isClientFilter =
|
||||
c -> c.getSession() != null && sessionId.equals((new UUID(c.getSession().getSessionIdMSB(), c.getSession().getSessionIdLSB())));
|
||||
if (this.lwM2mClientsByEndpoint.size() > 0) {
|
||||
lwM2mClient = this.lwM2mClientsByEndpoint.values().stream().filter(isClientFilter).findAny().orElse(null);
|
||||
}
|
||||
|
||||
@ -17,15 +17,12 @@ package org.thingsboard.server.transport.lwm2m.server.rpc;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.eclipse.leshan.core.ResponseCode;
|
||||
import org.eclipse.leshan.core.request.ReadCompositeRequest;
|
||||
import org.eclipse.leshan.core.response.ReadCompositeResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.rpc.RpcStatus;
|
||||
import org.thingsboard.server.common.transport.TransportService;
|
||||
import org.thingsboard.server.common.transport.TransportServiceCallback;
|
||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||
import org.thingsboard.server.queue.util.TbLwM2mTransportComponent;
|
||||
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig;
|
||||
@ -63,11 +60,9 @@ import org.thingsboard.server.transport.lwm2m.server.rpc.composite.RpcReadRespon
|
||||
import org.thingsboard.server.transport.lwm2m.server.rpc.composite.RpcWriteCompositeRequest;
|
||||
import org.thingsboard.server.transport.lwm2m.server.uplink.LwM2mUplinkMsgHandler;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -85,6 +80,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
|
||||
@Override
|
||||
public void onToDeviceRpcRequest(TransportProtos.ToDeviceRpcRequestMsg rpcRequest, TransportProtos.SessionInfoProto sessionInfo) {
|
||||
log.debug("Received params: {}", rpcRequest.getParams());
|
||||
try {
|
||||
LwM2mOperationType operationType = LwM2mOperationType.fromType(rpcRequest.getMethodName());
|
||||
if (operationType == null) {
|
||||
this.sendErrorRpcResponse(sessionInfo, rpcRequest.getRequestId(), ResponseCode.METHOD_NOT_ALLOWED, "Unsupported operation type: " + rpcRequest.getMethodName());
|
||||
@ -171,6 +167,10 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.sendErrorRpcResponse(sessionInfo, rpcRequest.getRequestId(), ResponseCode.BAD_REQUEST, e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[{}] Failed to send RPC: [{}]", sessionInfo, rpcRequest, e);
|
||||
this.sendErrorRpcResponse(sessionInfo, rpcRequest.getRequestId(), ResponseCode.INTERNAL_SERVER_ERROR, ExceptionUtils.getRootCauseMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
private void sendReadRequest(LwM2mClient client, TransportProtos.ToDeviceRpcRequestMsg requestMsg, String versionedId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user