#vulnerable code 
                                private static List<KubernetesCloud> getUsageRestrictedKubernetesClouds() {
        List<KubernetesCloud> clouds = new ArrayList<>();

        for (Cloud cloud : Jenkins.getInstance().clouds) {
            if(cloud instanceof KubernetesCloud) {
                if (((KubernetesCloud) cloud).isUsageRestricted()) {
                    clouds.add((KubernetesCloud) cloud);
                }
            }
        }

        Collections.sort(clouds, CLOUD_BY_NAME);

        return clouds;
    } 
                            #location 4 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                private static List<KubernetesCloud> getUsageRestrictedKubernetesClouds() {
        List<KubernetesCloud> clouds = Jenkins.get().clouds
                .getAll(KubernetesCloud.class)
                .stream()
                .filter(KubernetesCloud::isUsageRestricted)
                .collect(Collectors.toList());
        Collections.sort(clouds, Comparator.<Cloud, String>comparing(o -> o.name));
        return clouds;
    }