#vulnerable code 
                                @ReadOperation
    public HaloMetricResponse HaloMetric() {
        HaloMetricResponse haloMetricResponse=new HaloMetricResponse();
        MetricResponse jvmThreadsLive=metric("jvm.threads.live",null);
        haloMetricResponse.setJvmThreadslive(String.valueOf(jvmThreadsLive.getMeasurements().get(0).getValue()));
        MetricResponse jvmNemoryUsedHeap=metric("jvm.memory.used", Arrays.asList("area:heap") );
        haloMetricResponse.setJvmMemoryUsedHeap(String.valueOf(jvmNemoryUsedHeap.getMeasurements().get(0).getValue()));
        MetricResponse jvmNemoryUsedNonHeap=metric("jvm.memory.used", Arrays.asList("area:nonheap") );
        haloMetricResponse.setJvmMemoryUsedNonHeap(String.valueOf(jvmNemoryUsedNonHeap.getMeasurements().get(0).getValue()));

        MetricResponse systemLoadAverage=metric("system.load.average.1m", null );
        haloMetricResponse.setSystemloadAverage(String.valueOf(systemLoadAverage.getMeasurements().get(0).getValue()));

        MetricResponse heapCommitted=metric("jvm.memory.committed", Arrays.asList("area:heap") );
        haloMetricResponse.setHeapCommitted(String.valueOf(heapCommitted.getMeasurements().get(0).getValue()));
        MetricResponse nonheapCommitted=metric("jvm.memory.committed", Arrays.asList("area:nonheap") );
        haloMetricResponse.setNonheapCommitted(String.valueOf(nonheapCommitted.getMeasurements().get(0).getValue()));

        MetricResponse heapMax=metric("jvm.memory.max", Arrays.asList("area:heap") );
        haloMetricResponse.setHeapMax(String.valueOf(heapMax.getMeasurements().get(0).getValue()));


        getGcinfo(haloMetricResponse);
        MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean()
                .getHeapMemoryUsage();
        haloMetricResponse.setHeapInit(String.valueOf(memoryUsage.getInit()));
        Runtime runtime = Runtime.getRuntime();
        haloMetricResponse.setProcessors(String.valueOf(runtime.availableProcessors()));
        return haloMetricResponse;

    } 
                            #location 12 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @ReadOperation
    public HaloMetricResponse HaloMetric() {
        HaloMetricResponse haloMetricResponse=new HaloMetricResponse();
        MetricResponse jvmThreadsLive=metric("jvm.threads.live",null);
        haloMetricResponse.setJvmThreadslive(String.valueOf(jvmThreadsLive.getMeasurements().get(0).getValue()));
        MetricResponse jvmNemoryUsedHeap=metric("jvm.memory.used", Arrays.asList("area:heap") );
        haloMetricResponse.setJvmMemoryUsedHeap(String.valueOf(jvmNemoryUsedHeap.getMeasurements().get(0).getValue()));
        MetricResponse jvmNemoryUsedNonHeap=metric("jvm.memory.used", Arrays.asList("area:nonheap") );
        haloMetricResponse.setJvmMemoryUsedNonHeap(String.valueOf(jvmNemoryUsedNonHeap.getMeasurements().get(0).getValue()));
        // 2.0 actuator/metrics 中没有这个key
        MetricResponse systemLoadAverage=metric("system.load.average.1m", null );
        if(systemLoadAverage!=null){
            haloMetricResponse.setSystemloadAverage(String.valueOf(systemLoadAverage.getMeasurements().get(0).getValue()));
        }
        MetricResponse heapCommitted=metric("jvm.memory.committed", Arrays.asList("area:heap") );
        haloMetricResponse.setHeapCommitted(String.valueOf(heapCommitted.getMeasurements().get(0).getValue()));
        MetricResponse nonheapCommitted=metric("jvm.memory.committed", Arrays.asList("area:nonheap") );
        haloMetricResponse.setNonheapCommitted(String.valueOf(nonheapCommitted.getMeasurements().get(0).getValue()));

        MetricResponse heapMax=metric("jvm.memory.max", Arrays.asList("area:heap") );
        haloMetricResponse.setHeapMax(String.valueOf(heapMax.getMeasurements().get(0).getValue()));
        getGcinfo(haloMetricResponse);
        MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean()
                .getHeapMemoryUsage();
        haloMetricResponse.setHeapInit(String.valueOf(memoryUsage.getInit()));
        Runtime runtime = Runtime.getRuntime();
        haloMetricResponse.setProcessors(String.valueOf(runtime.availableProcessors()));
        return haloMetricResponse;

    }