Program: 79694
Project: 79694
Buggy source:
private void onMetricChanged(Number val){
  if (LOG.isTraceEnabled())   LOG.trace("String_Node_Str",new Object[]{this,poolEntity,val});
  double currentMetricD=val.doubleValue();
  double metricUpperBoundD=metricUpperBound.doubleValue();
  double metricLowerBoundD=metricLowerBound.doubleValue();
  int currentSize=currentSizeOperator.apply(entity);
  int desiredSize;
  if (currentMetricD > metricUpperBoundD) {
    desiredSize=currentSize + (int)Math.ceil(currentSize * ((currentMetricD - metricUpperBoundD) / metricUpperBoundD));
    desiredSize=toBoundedDesiredPoolSize(desiredSize);
    if (desiredSize > currentSize) {
      if (LOG.isTraceEnabled())       LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,desiredSize,currentMetricD,metricUpperBoundD});
      scheduleResize(desiredSize);
    }
  }
 else   if (currentMetricD < metricLowerBoundD) {
    desiredSize=currentSize - (int)Math.floor(currentSize * ((metricLowerBoundD - currentMetricD) / metricLowerBoundD));
    desiredSize=toBoundedDesiredPoolSize(desiredSize);
    if (desiredSize < currentSize) {
      if (LOG.isTraceEnabled())       LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,desiredSize,currentMetricD,metricLowerBoundD});
      scheduleResize(desiredSize);
    }
  }
 else {
    if (LOG.isTraceEnabled())     LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,currentMetricD,metricLowerBoundD,metricUpperBoundD});
    abortResize(currentSize);
    return;
  }
}

Fixed version (ground truth):
private void onMetricChanged(Number val){
  if (LOG.isTraceEnabled())   LOG.trace("String_Node_Str",new Object[]{this,poolEntity,val});
  double currentMetricD=val.doubleValue();
  double metricUpperBoundD=metricUpperBound.doubleValue();
  double metricLowerBoundD=metricLowerBound.doubleValue();
  int currentSize=currentSizeOperator.apply(entity);
  double currentTotalActivity=currentSize * currentMetricD;
  int desiredSize;
  if (currentMetricD > metricUpperBoundD) {
    desiredSize=(int)Math.ceil(currentTotalActivity / metricUpperBoundD);
    desiredSize=toBoundedDesiredPoolSize(desiredSize);
    if (desiredSize > currentSize) {
      if (LOG.isTraceEnabled())       LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,desiredSize,currentMetricD,metricUpperBoundD});
      scheduleResize(desiredSize);
    }
 else {
      if (LOG.isTraceEnabled())       LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,currentMetricD,metricUpperBoundD,metricLowerBoundD});
    }
  }
 else   if (currentMetricD < metricLowerBoundD) {
    desiredSize=(int)Math.floor(currentTotalActivity / metricLowerBoundD);
    desiredSize=toBoundedDesiredPoolSize(desiredSize);
    if (desiredSize < currentTotalActivity / metricUpperBoundD) {
      if (LOG.isTraceEnabled())       LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,desiredSize});
      desiredSize=(int)Math.ceil(currentTotalActivity / metricUpperBoundD);
      desiredSize=toBoundedDesiredPoolSize(desiredSize);
    }
    if (desiredSize < currentSize) {
      if (LOG.isTraceEnabled())       LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,desiredSize,currentMetricD,metricLowerBoundD});
      scheduleResize(desiredSize);
    }
 else {
      if (LOG.isTraceEnabled())       LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,currentMetricD,metricLowerBoundD,metricUpperBoundD});
    }
  }
 else {
    if (LOG.isTraceEnabled())     LOG.trace("String_Node_Str",new Object[]{this,poolEntity,currentSize,currentMetricD,metricLowerBoundD,metricUpperBoundD});
    abortResize(currentSize);
    return;
  }
}