Program: 38839
Project: 38839
Buggy source:
private void initTable(List<DoubleTimeSeries> doubleTimeSeries,List<StringTimeSeries> stringTimeSeries){
  initLock.lock();
  try {
    if (timeSeriesMetadata != null) {
      return;
    }
    timeSeriesMetadata=new ArrayList<>(doubleTimeSeries.size() + stringTimeSeries.size());
    for (    DoubleTimeSeries timeSeries : doubleTimeSeries.stream().sorted(Comparator.comparing(ts -> ts.getMetadata().getName())).collect(Collectors.toList())) {
      timeSeries.synchronize(tableIndex);
      timeSeriesMetadata.add(timeSeries.getMetadata());
      int i=doubleTimeSeriesNames.add(timeSeries.getMetadata().getName());
      timeSeriesIndexDoubleOrString.add(i);
    }
    for (    StringTimeSeries timeSeries : stringTimeSeries.stream().sorted(Comparator.comparing(ts -> ts.getMetadata().getName())).collect(Collectors.toList())) {
      timeSeries.synchronize(tableIndex);
      timeSeriesMetadata.add(timeSeries.getMetadata());
      int i=stringTimeSeriesNames.add(timeSeries.getMetadata().getName());
      timeSeriesIndexDoubleOrString.add(i);
    }
    if (tableIndex == null) {
      throw new TimeSeriesException("String_Node_Str");
    }
    int versionCount=toVersion - fromVersion + 1;
    int doubleBufferSize=versionCount * doubleTimeSeriesNames.size() * tableIndex.getPointCount();
    doubleBuffer=createDoubleBuffer(doubleBufferSize,Double.NaN);
    int stringBufferSize=versionCount * stringTimeSeriesNames.size() * tableIndex.getPointCount();
    stringBuffer=new CompactStringBuffer(stringBufferSize);
    if (LOGGER.isInfoEnabled()) {
      LOGGER.info("String_Node_Str",FileUtils.byteCountToDisplaySize((long)doubleBuffer.capacity() * Double.BYTES + stringBuffer.capacity() * Integer.BYTES));
    }
    means=new double[doubleTimeSeriesNames.size() * versionCount];
    Arrays.fill(means,Double.NaN);
    stdDevs=new double[doubleTimeSeriesNames.size() * versionCount];
    Arrays.fill(stdDevs,Double.NaN);
  }
 catch (  Exception e) {
    LOGGER.error(e.toString(),e);
    timeSeriesMetadata=null;
    doubleTimeSeriesNames.clear();
    stringTimeSeriesNames.clear();
    timeSeriesIndexDoubleOrString.clear();
    doubleBuffer=null;
    stringBuffer=null;
    means=null;
    stdDevs=null;
  }
 finally {
    initLock.unlock();
  }
}

Fixed version (ground truth):
private void initTable(List<DoubleTimeSeries> doubleTimeSeries,List<StringTimeSeries> stringTimeSeries){
  initLock.lock();
  try {
    if (timeSeriesMetadata != null) {
      return;
    }
    timeSeriesMetadata=new ArrayList<>(doubleTimeSeries.size() + stringTimeSeries.size());
    for (    DoubleTimeSeries timeSeries : doubleTimeSeries.stream().sorted(Comparator.comparing(ts -> ts.getMetadata().getName())).collect(Collectors.toList())) {
      timeSeriesMetadata.add(timeSeries.getMetadata());
      int i=doubleTimeSeriesNames.add(timeSeries.getMetadata().getName());
      timeSeriesIndexDoubleOrString.add(i);
    }
    for (    StringTimeSeries timeSeries : stringTimeSeries.stream().sorted(Comparator.comparing(ts -> ts.getMetadata().getName())).collect(Collectors.toList())) {
      timeSeriesMetadata.add(timeSeries.getMetadata());
      int i=stringTimeSeriesNames.add(timeSeries.getMetadata().getName());
      timeSeriesIndexDoubleOrString.add(i);
    }
    if (tableIndex == null) {
      throw new TimeSeriesException("String_Node_Str");
    }
    int versionCount=toVersion - fromVersion + 1;
    int doubleBufferSize=versionCount * doubleTimeSeriesNames.size() * tableIndex.getPointCount();
    doubleBuffer=createDoubleBuffer(doubleBufferSize,Double.NaN);
    int stringBufferSize=versionCount * stringTimeSeriesNames.size() * tableIndex.getPointCount();
    stringBuffer=new CompactStringBuffer(stringBufferSize);
    if (LOGGER.isInfoEnabled()) {
      LOGGER.info("String_Node_Str",FileUtils.byteCountToDisplaySize((long)doubleBuffer.capacity() * Double.BYTES + stringBuffer.capacity() * Integer.BYTES));
    }
    means=new double[doubleTimeSeriesNames.size() * versionCount];
    Arrays.fill(means,Double.NaN);
    stdDevs=new double[doubleTimeSeriesNames.size() * versionCount];
    Arrays.fill(stdDevs,Double.NaN);
  }
 catch (  Exception e) {
    LOGGER.error(e.toString(),e);
    timeSeriesMetadata=null;
    doubleTimeSeriesNames.clear();
    stringTimeSeriesNames.clear();
    timeSeriesIndexDoubleOrString.clear();
    doubleBuffer=null;
    stringBuffer=null;
    means=null;
    stdDevs=null;
  }
 finally {
    initLock.unlock();
  }
}