Program: 157063
Project: 157063
Buggy source:
private void runDynamicEnergyValueResolution(){
  TreeMap<WrappedStack,EnergyValue> stackValueMap=new TreeMap<WrappedStack,EnergyValue>();
  stackValueMap.putAll(preAssignedMappings);
  Map<WrappedStack,EnergyValue> preAssignedValueMap=SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.PRE_ASSIGNED_ENERGY_VALUES);
  for (  WrappedStack wrappedStack : preAssignedValueMap.keySet()) {
    if (preAssignedValueMap.get(wrappedStack) != null) {
      stackValueMap.put(wrappedStack,preAssignedValueMap.get(wrappedStack));
    }
  }
  ImmutableSortedMap.Builder<WrappedStack,EnergyValue> stackMappingsBuilder=ImmutableSortedMap.naturalOrder();
  stackMappingsBuilder.putAll(stackValueMap);
  stackMappings=stackMappingsBuilder.build();
  Map<WrappedStack,EnergyValue> computedStackValues=new TreeMap<WrappedStack,EnergyValue>();
  int passNumber=0;
  long computationStartTime=System.currentTimeMillis();
  long passStartTime;
  int computedValueCount=0;
  int totalComputedValueCount=0;
  LogHelper.info("String_Node_Str");
  boolean isFirstPass=true;
  while ((isFirstPass || computedValueCount > 0) && (passNumber < 16)) {
    if (isFirstPass) {
      isFirstPass=false;
    }
    computedValueCount=0;
    passStartTime=System.currentTimeMillis();
    passNumber++;
    computedStackValues=computeStackMappings(stackValueMap);
    for (    WrappedStack keyStack : computedStackValues.keySet()) {
      EnergyValue factoredExchangeEnergyValue=null;
      WrappedStack factoredKeyStack=null;
      if (keyStack != null && keyStack.getWrappedObject() != null && keyStack.getStackSize() > 0) {
        if (computedStackValues.get(keyStack) != null && Float.compare(computedStackValues.get(keyStack).getEnergyValue(),0f) > 0) {
          factoredExchangeEnergyValue=EnergyValueHelper.factorEnergyValue(computedStackValues.get(keyStack),keyStack.getStackSize());
          factoredKeyStack=new WrappedStack(keyStack,1);
        }
      }
      if (factoredExchangeEnergyValue != null) {
        if (stackValueMap.containsKey(factoredKeyStack)) {
          if (factoredExchangeEnergyValue.compareTo(stackValueMap.get(factoredKeyStack)) == -1) {
            stackValueMap.put(factoredKeyStack,factoredExchangeEnergyValue);
          }
        }
 else {
          stackValueMap.put(factoredKeyStack,factoredExchangeEnergyValue);
          computedValueCount++;
          totalComputedValueCount++;
        }
      }
    }
    LogHelper.info(String.format("String_Node_Str",passNumber,computedValueCount,System.currentTimeMillis() - passStartTime));
  }
  LogHelper.info(String.format("String_Node_Str",totalComputedValueCount,System.currentTimeMillis() - computationStartTime));
  if (postAssignedExactMappings != null) {
    for (    WrappedStack wrappedStack : postAssignedExactMappings.keySet()) {
      if (postAssignedExactMappings.get(wrappedStack) != null) {
        stackValueMap.put(wrappedStack,postAssignedExactMappings.get(wrappedStack));
      }
    }
  }
 else {
    postAssignedExactMappings=new TreeMap<WrappedStack,EnergyValue>();
  }
  Map<WrappedStack,EnergyValue> postAssignedValueMap=SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.POST_ASSIGNED_ENERGY_VALUES);
  for (  WrappedStack wrappedStack : postAssignedValueMap.keySet()) {
    if (postAssignedValueMap.get(wrappedStack) != null) {
      stackValueMap.put(wrappedStack,postAssignedValueMap.get(wrappedStack));
    }
  }
  stackMappingsBuilder=ImmutableSortedMap.naturalOrder();
  stackMappingsBuilder.putAll(stackValueMap);
  stackMappings=stackMappingsBuilder.build();
  generateValueStackMappings();
  LogHelper.info("String_Node_Str");
  saveEnergyValueRegistryToFile();
}

Fixed version (ground truth):
private void runDynamicEnergyValueResolution(){
  TreeMap<WrappedStack,EnergyValue> stackValueMap=new TreeMap<WrappedStack,EnergyValue>();
  stackValueMap.putAll(preAssignedMappings);
  Map<WrappedStack,EnergyValue> preAssignedValueMap=SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.PRE_ASSIGNED_ENERGY_VALUES);
  for (  WrappedStack wrappedStack : preAssignedValueMap.keySet()) {
    if (preAssignedValueMap.get(wrappedStack) != null) {
      stackValueMap.put(wrappedStack,preAssignedValueMap.get(wrappedStack));
    }
  }
  ImmutableSortedMap.Builder<WrappedStack,EnergyValue> stackMappingsBuilder=ImmutableSortedMap.naturalOrder();
  stackMappingsBuilder.putAll(stackValueMap);
  stackMappings=stackMappingsBuilder.build();
  Map<WrappedStack,EnergyValue> computedStackValues=new TreeMap<WrappedStack,EnergyValue>();
  int passNumber=0;
  long computationStartTime=System.currentTimeMillis();
  long passStartTime;
  int computedValueCount=0;
  int totalComputedValueCount=0;
  LogHelper.info("String_Node_Str");
  boolean isFirstPass=true;
  while ((isFirstPass || computedValueCount > 0) && (passNumber < 16)) {
    if (isFirstPass) {
      isFirstPass=false;
    }
    computedValueCount=0;
    passStartTime=System.currentTimeMillis();
    passNumber++;
    computedStackValues=computeStackMappings(stackValueMap);
    for (    WrappedStack keyStack : computedStackValues.keySet()) {
      EnergyValue factoredExchangeEnergyValue=null;
      WrappedStack factoredKeyStack=null;
      if (keyStack != null && keyStack.getWrappedObject() != null && keyStack.getStackSize() > 0) {
        if (computedStackValues.get(keyStack) != null && Float.compare(computedStackValues.get(keyStack).getEnergyValue(),0f) > 0) {
          factoredExchangeEnergyValue=EnergyValueHelper.factorEnergyValue(computedStackValues.get(keyStack),keyStack.getStackSize());
          factoredKeyStack=new WrappedStack(keyStack,1);
        }
      }
      if (factoredExchangeEnergyValue != null) {
        if (stackValueMap.containsKey(factoredKeyStack)) {
          if (factoredExchangeEnergyValue.compareTo(stackValueMap.get(factoredKeyStack)) == -1) {
            stackValueMap.put(factoredKeyStack,factoredExchangeEnergyValue);
          }
        }
 else {
          stackValueMap.put(factoredKeyStack,factoredExchangeEnergyValue);
          computedValueCount++;
          totalComputedValueCount++;
        }
      }
    }
    LogHelper.info(String.format("String_Node_Str",passNumber,computedValueCount,System.currentTimeMillis() - passStartTime));
  }
  LogHelper.info(String.format("String_Node_Str",totalComputedValueCount,System.currentTimeMillis() - computationStartTime));
  if (postAssignedMappings != null) {
    for (    WrappedStack wrappedStack : postAssignedMappings.keySet()) {
      if (postAssignedMappings.get(wrappedStack) != null) {
        stackValueMap.put(wrappedStack,postAssignedMappings.get(wrappedStack));
      }
    }
  }
 else {
    postAssignedMappings=new TreeMap<WrappedStack,EnergyValue>();
  }
  Map<WrappedStack,EnergyValue> postAssignedValueMap=SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.POST_ASSIGNED_ENERGY_VALUES);
  for (  WrappedStack wrappedStack : postAssignedValueMap.keySet()) {
    if (postAssignedValueMap.get(wrappedStack) != null) {
      stackValueMap.put(wrappedStack,postAssignedValueMap.get(wrappedStack));
    }
  }
  stackMappingsBuilder=ImmutableSortedMap.naturalOrder();
  stackMappingsBuilder.putAll(stackValueMap);
  stackMappings=stackMappingsBuilder.build();
  generateValueStackMappings();
  LogHelper.info("String_Node_Str");
  saveEnergyValueRegistryToFile();
}