Program: 1410
Project: 1410
Buggy source:
/** 
 * Add a series of system and jvm-level stats to the given registry.
 */
public static void register(MetricRegistry registry){
  final MetricRegistry stats=registry.scope("String_Node_Str");
  final MemoryMXBean mem=ManagementFactory.getMemoryMXBean();
  final MemoryUsage heap=mem.getHeapMemoryUsage();
  final MetricRegistry heapRegistry=stats.scope("String_Node_Str");
  registerMemoryStats(heapRegistry,heap);
  final MemoryUsage nonHeap=mem.getNonHeapMemoryUsage();
  final MetricRegistry nonHeapRegistry=stats.scope("String_Node_Str");
  registerMemoryStats(nonHeapRegistry,nonHeap);
  final ThreadMXBean threads=ManagementFactory.getThreadMXBean();
  final MetricRegistry threadRegistry=stats.scope("String_Node_Str");
  threadRegistry.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return threads.getDaemonThreadCount();
    }
  }
);
  threadRegistry.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return threads.getThreadCount();
    }
  }
);
  threadRegistry.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return threads.getPeakThreadCount();
    }
  }
);
  final ClassLoadingMXBean classLoadingBean=ManagementFactory.getClassLoadingMXBean();
  stats.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return classLoadingBean.getLoadedClassCount();
    }
  }
);
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return classLoadingBean.getTotalLoadedClassCount();
    }
  }
);
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return classLoadingBean.getUnloadedClassCount();
    }
  }
);
  final RuntimeMXBean runtime=ManagementFactory.getRuntimeMXBean();
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return runtime.getStartTime();
    }
  }
);
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return runtime.getUptime();
    }
  }
);
  final OperatingSystemMXBean os=ManagementFactory.getOperatingSystemMXBean();
  stats.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return os.getAvailableProcessors();
    }
  }
);
  if (os instanceof com.sun.management.OperatingSystemMXBean) {
    final com.sun.management.OperatingSystemMXBean sunOsMbean=(com.sun.management.OperatingSystemMXBean)os;
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return sunOsMbean.getFreePhysicalMemorySize();
      }
    }
);
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return sunOsMbean.getFreeSwapSpaceSize();
      }
    }
);
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return sunOsMbean.getProcessCpuTime();
      }
    }
);
  }
  if (os instanceof com.sun.management.UnixOperatingSystemMXBean) {
    final UnixOperatingSystemMXBean unix=(UnixOperatingSystemMXBean)os;
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return unix.getOpenFileDescriptorCount();
      }
    }
);
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return unix.getMaxFileDescriptorCount();
      }
    }
);
  }
  final List<MemoryPoolMXBean> memPool=ManagementFactory.getMemoryPoolMXBeans();
  final MetricRegistry memRegistry=stats.scope("String_Node_Str");
  final MetricRegistry currentMem=memRegistry.scope("String_Node_Str");
  final MetricRegistry postGCRegistry=memRegistry.scope("String_Node_Str");
  for (  MemoryPoolMXBean pool : memPool) {
    String name=normalizeName(pool.getName());
    registerMemoryStats(currentMem.scope(name),pool.getUsage());
    MemoryUsage postGCUsage=pool.getCollectionUsage();
    registerMemoryStats(postGCRegistry.scope(name),postGCUsage);
  }
  currentMem.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      MemoryPoolMXBean pool : memPool) {
        MemoryUsage usage=pool.getUsage();
        if (usage != null) {
          sum+=usage.getUsed();
        }
      }
      return sum;
    }
  }
);
  AbstractGauge<Long> totalPostGCGauge=new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      MemoryPoolMXBean pool : memPool) {
        MemoryUsage usage=pool.getCollectionUsage();
        if (usage != null) {
          sum+=usage.getUsed();
        }
      }
      return sum;
    }
  }
;
  postGCRegistry.register(totalPostGCGauge);
  Multimap<String,AbstractGauge<Long>> java17gauges=buildJava17Gauges();
  if (!java17gauges.isEmpty()) {
    MetricRegistry bufferRegistry=stats.scope("String_Node_Str");
    for (    String scope : java17gauges.keySet()) {
      MetricRegistry pool=bufferRegistry.scope(scope);
      for (      AbstractGauge<Long> gauge : java17gauges.get(scope)) {
        pool.register(gauge);
      }
    }
  }
  final List<GarbageCollectorMXBean> gcPool=ManagementFactory.getGarbageCollectorMXBeans();
  MetricRegistry gcRegistry=stats.scope("String_Node_Str");
  for (  final GarbageCollectorMXBean gc : gcPool) {
    String name=normalizeName(gc.getName());
    MetricRegistry scoped=memRegistry.scope(name);
    scoped.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return gc.getCollectionCount();
      }
    }
);
    scoped.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return gc.getCollectionTime();
      }
    }
);
  }
  gcRegistry.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      GarbageCollectorMXBean pool : gcPool) {
        long count=pool.getCollectionCount();
        if (count > 0) {
          sum+=count;
        }
      }
      return sum;
    }
  }
);
  gcRegistry.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      GarbageCollectorMXBean pool : gcPool) {
        long msec=pool.getCollectionTime();
        if (msec > 0) {
          sum+=msec;
        }
      }
      return sum;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Add a series of system and jvm-level stats to the given registry.
 */
public static void register(MetricRegistry registry){
  final MetricRegistry stats=registry.scope("String_Node_Str");
  final MemoryMXBean mem=ManagementFactory.getMemoryMXBean();
  final MetricRegistry heapRegistry=stats.scope("String_Node_Str");
  registerMemoryStats(heapRegistry,new MemoryReporter(){
    @Override public MemoryUsage getUsage(){
      return mem.getHeapMemoryUsage();
    }
  }
);
  final MetricRegistry nonHeapRegistry=stats.scope("String_Node_Str");
  registerMemoryStats(nonHeapRegistry,new MemoryReporter(){
    @Override public MemoryUsage getUsage(){
      return mem.getNonHeapMemoryUsage();
    }
  }
);
  final ThreadMXBean threads=ManagementFactory.getThreadMXBean();
  final MetricRegistry threadRegistry=stats.scope("String_Node_Str");
  threadRegistry.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return threads.getDaemonThreadCount();
    }
  }
);
  threadRegistry.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return threads.getThreadCount();
    }
  }
);
  threadRegistry.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return threads.getPeakThreadCount();
    }
  }
);
  final ClassLoadingMXBean classLoadingBean=ManagementFactory.getClassLoadingMXBean();
  stats.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return classLoadingBean.getLoadedClassCount();
    }
  }
);
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return classLoadingBean.getTotalLoadedClassCount();
    }
  }
);
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return classLoadingBean.getUnloadedClassCount();
    }
  }
);
  final RuntimeMXBean runtime=ManagementFactory.getRuntimeMXBean();
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return runtime.getStartTime();
    }
  }
);
  stats.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      return runtime.getUptime();
    }
  }
);
  final OperatingSystemMXBean os=ManagementFactory.getOperatingSystemMXBean();
  stats.register(new AbstractGauge<Integer>("String_Node_Str"){
    @Override public Integer read(){
      return os.getAvailableProcessors();
    }
  }
);
  if (os instanceof com.sun.management.OperatingSystemMXBean) {
    final com.sun.management.OperatingSystemMXBean sunOsMbean=(com.sun.management.OperatingSystemMXBean)os;
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return sunOsMbean.getFreePhysicalMemorySize();
      }
    }
);
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return sunOsMbean.getFreeSwapSpaceSize();
      }
    }
);
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return sunOsMbean.getProcessCpuTime();
      }
    }
);
  }
  if (os instanceof com.sun.management.UnixOperatingSystemMXBean) {
    final UnixOperatingSystemMXBean unix=(UnixOperatingSystemMXBean)os;
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return unix.getOpenFileDescriptorCount();
      }
    }
);
    stats.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return unix.getMaxFileDescriptorCount();
      }
    }
);
  }
  final List<MemoryPoolMXBean> memPool=ManagementFactory.getMemoryPoolMXBeans();
  final MetricRegistry memRegistry=stats.scope("String_Node_Str");
  final MetricRegistry currentMem=memRegistry.scope("String_Node_Str");
  final MetricRegistry postGCRegistry=memRegistry.scope("String_Node_Str");
  for (  final MemoryPoolMXBean pool : memPool) {
    String name=normalizeName(pool.getName());
    registerMemoryStats(currentMem.scope(name),new MemoryReporter(){
      @Override public MemoryUsage getUsage(){
        return pool.getUsage();
      }
    }
);
    registerMemoryStats(postGCRegistry.scope(name),new MemoryReporter(){
      @Override public MemoryUsage getUsage(){
        return pool.getCollectionUsage();
      }
    }
);
  }
  currentMem.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      MemoryPoolMXBean pool : memPool) {
        MemoryUsage usage=pool.getUsage();
        if (usage != null) {
          sum+=usage.getUsed();
        }
      }
      return sum;
    }
  }
);
  AbstractGauge<Long> totalPostGCGauge=new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      MemoryPoolMXBean pool : memPool) {
        MemoryUsage usage=pool.getCollectionUsage();
        if (usage != null) {
          sum+=usage.getUsed();
        }
      }
      return sum;
    }
  }
;
  postGCRegistry.register(totalPostGCGauge);
  Multimap<String,AbstractGauge<Long>> java17gauges=buildJava17Gauges();
  if (!java17gauges.isEmpty()) {
    MetricRegistry bufferRegistry=stats.scope("String_Node_Str");
    for (    String scope : java17gauges.keySet()) {
      MetricRegistry pool=bufferRegistry.scope(scope);
      for (      AbstractGauge<Long> gauge : java17gauges.get(scope)) {
        pool.register(gauge);
      }
    }
  }
  final List<GarbageCollectorMXBean> gcPool=ManagementFactory.getGarbageCollectorMXBeans();
  MetricRegistry gcRegistry=stats.scope("String_Node_Str");
  for (  final GarbageCollectorMXBean gc : gcPool) {
    String name=normalizeName(gc.getName());
    MetricRegistry scoped=memRegistry.scope(name);
    scoped.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return gc.getCollectionCount();
      }
    }
);
    scoped.register(new AbstractGauge<Long>("String_Node_Str"){
      @Override public Long read(){
        return gc.getCollectionTime();
      }
    }
);
  }
  gcRegistry.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      GarbageCollectorMXBean pool : gcPool) {
        long count=pool.getCollectionCount();
        if (count > 0) {
          sum+=count;
        }
      }
      return sum;
    }
  }
);
  gcRegistry.register(new AbstractGauge<Long>("String_Node_Str"){
    @Override public Long read(){
      long sum=0;
      for (      GarbageCollectorMXBean pool : gcPool) {
        long msec=pool.getCollectionTime();
        if (msec > 0) {
          sum+=msec;
        }
      }
      return sum;
    }
  }
);
}