private AwsIotDeviceCommand getPendingCommand()

in aws-iot-device-sdk-java/src/main/java/com/amazonaws/services/iot/client/shadow/AwsIotDeviceCommandManager.java [286:323]


    private AwsIotDeviceCommand getPendingCommand(AWSIotMessage message) {
        String payload = message.getStringPayload();
        if (payload == null) {
            return null;
        }

        try {
            JsonNode jsonNode = objectMapper.readTree(payload);
            if (!jsonNode.isObject()) {
                return null;
            }

            JsonNode node = jsonNode.get(COMMAND_ID_FIELD);
            if (node == null) {
                return null;
            }

            String commandId = node.textValue();
            AwsIotDeviceCommand command = pendingCommands.remove(commandId);
            if (command == null) {
                return null;
            }

            node = jsonNode.get(ERROR_CODE_FIELD);
            if (node != null) {
                command.setErrorCode(AWSIotDeviceErrorCode.valueOf(node.longValue()));
            }

            node = jsonNode.get(ERROR_MESSAGE_FIELD);
            if (node != null) {
                command.setErrorMessage(node.textValue());
            }

            return command;
        } catch (IOException e) {
            return null;
        }
    }