public static void checkInstanceIsLegal(Instance instance) throws NacosException {
        if (null == instance) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.INSTANCE_ERROR,
                    "Instance can not be null.");
        }
        if (instance.getInstanceHeartBeatTimeOut() < instance.getInstanceHeartBeatInterval()
                || instance.getIpDeleteTimeout() < instance.getInstanceHeartBeatInterval()) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.INSTANCE_ERROR,
                    "Instance 'heart beat interval' must less than 'heart beat timeout' and 'ip delete timeout'.");
        }
        if (!StringUtils.isEmpty(instance.getClusterName()) && !CLUSTER_NAME_PATTERN.matcher(instance.getClusterName()).matches()) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.INSTANCE_ERROR,
                    String.format("Instance 'clusterName' should be characters with only 0-9a-zA-Z-. (current: %s)",
                            instance.getClusterName()));
        }
    }
@Test
    void testCheckInstanceIsNull() throws NacosException {
        Instance instance = new Instance();
        instance.setIp("127.0.0.1");
        instance.setPort(9089);
        NamingUtils.checkInstanceIsLegal(instance);
        try {
            NamingUtils.checkInstanceIsLegal(null);
        } catch (NacosException e) {
            assertEquals(NacosException.INVALID_PARAM, e.getErrCode());
        }
    }