Program: 15861
Project: 15861
Buggy source:
/** 
 * Create and open the store.
 * @param config the configuration to use
 * @throws IllegalStateException if the file is corrupt, or an exceptionoccurred while opening
 * @throws IllegalArgumentException if the directory does not exist
 */
MVStore(HashMap<String,Object> config){
  this.compress=config.containsKey("String_Node_Str");
  Object o=config.get("String_Node_Str");
  pageSplitSize=o == null ? 16 * 1024 : (Integer)o;
  o=config.get("String_Node_Str");
  this.backgroundExceptionHandler=(UncaughtExceptionHandler)o;
  meta=new MVMapConcurrent<String,String>(StringDataType.INSTANCE,StringDataType.INSTANCE);
  HashMap<String,String> c=New.hashMap();
  c.put("String_Node_Str","String_Node_Str");
  c.put("String_Node_Str",Long.toString(currentVersion));
  meta.init(this,c);
  fileStore=(FileStore)config.get("String_Node_Str");
  String fileName=(String)config.get("String_Node_Str");
  if (fileName == null && fileStore == null) {
    cache=null;
    return;
  }
  if (fileStore == null) {
    fileStore=new FileStore();
  }
  retentionTime=fileStore.getDefaultRetentionTime();
  boolean readOnly=config.containsKey("String_Node_Str");
  o=config.get("String_Node_Str");
  int mb=o == null ? 16 : (Integer)o;
  if (mb > 0) {
    int maxMemoryBytes=mb * 1024 * 1024;
    int averageMemory=Math.max(10,pageSplitSize / 2);
    int segmentCount=16;
    int stackMoveDistance=maxMemoryBytes / averageMemory * 2 / 100;
    cache=new CacheLongKeyLIRS<Page>(maxMemoryBytes,averageMemory,segmentCount,stackMoveDistance);
  }
  o=config.get("String_Node_Str");
  int kb=o == null ? 512 : (Integer)o;
  int autoCommitBufferSize=kb * 1024 * 19;
  int div=pageSplitSize;
  autoCommitPageCount=autoCommitBufferSize / (div == 0 ? 1 : div);
  char[] encryptionKey=(char[])config.get("String_Node_Str");
  try {
    fileStore.open(fileName,readOnly,encryptionKey);
    if (fileStore.size() == 0) {
      creationTime=0;
      creationTime=getTime();
      lastCommitTime=creationTime;
      storeHeader.put("String_Node_Str","String_Node_Str");
      storeHeader.put("String_Node_Str","String_Node_Str" + BLOCK_SIZE);
      storeHeader.put("String_Node_Str","String_Node_Str" + FORMAT_WRITE);
      storeHeader.put("String_Node_Str","String_Node_Str" + creationTime);
      writeStoreHeader();
    }
 else {
      readStoreHeader();
      long format=DataUtils.parseLong(storeHeader.get("String_Node_Str"),0);
      if (format > FORMAT_WRITE && !fileStore.isReadOnly()) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_UNSUPPORTED_FORMAT,"String_Node_Str" + "String_Node_Str",format,FORMAT_WRITE);
      }
      format=DataUtils.parseLong(storeHeader.get("String_Node_Str"),format);
      if (format > FORMAT_READ) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_UNSUPPORTED_FORMAT,"String_Node_Str",format,FORMAT_READ);
      }
      if (rootChunkStart > 0) {
        readMeta();
      }
    }
  }
 catch (  IllegalStateException e) {
    try {
      closeStore(false);
    }
 catch (    Exception e2) {
    }
    throw e;
  }
 finally {
    if (encryptionKey != null) {
      Arrays.fill(encryptionKey,(char)0);
    }
  }
  lastCommitTime=getTime();
  o=config.get("String_Node_Str");
  int delay=o == null ? 1000 : (Integer)o;
  setAutoCommitDelay(delay);
}

Fixed version (ground truth):
/** 
 * Create and open the store.
 * @param config the configuration to use
 * @throws IllegalStateException if the file is corrupt, or an exceptionoccurred while opening
 * @throws IllegalArgumentException if the directory does not exist
 */
MVStore(HashMap<String,Object> config){
  this.compress=config.containsKey("String_Node_Str");
  String fileName=(String)config.get("String_Node_Str");
  Object o=config.get("String_Node_Str");
  if (o == null) {
    pageSplitSize=fileName == null ? 4 * 1024 : 16 * 1024;
  }
 else {
    pageSplitSize=(Integer)o;
  }
  o=config.get("String_Node_Str");
  this.backgroundExceptionHandler=(UncaughtExceptionHandler)o;
  meta=new MVMapConcurrent<String,String>(StringDataType.INSTANCE,StringDataType.INSTANCE);
  HashMap<String,String> c=New.hashMap();
  c.put("String_Node_Str","String_Node_Str");
  c.put("String_Node_Str",Long.toString(currentVersion));
  meta.init(this,c);
  fileStore=(FileStore)config.get("String_Node_Str");
  if (fileName == null && fileStore == null) {
    cache=null;
    return;
  }
  if (fileStore == null) {
    fileStore=new FileStore();
  }
  retentionTime=fileStore.getDefaultRetentionTime();
  boolean readOnly=config.containsKey("String_Node_Str");
  o=config.get("String_Node_Str");
  int mb=o == null ? 16 : (Integer)o;
  if (mb > 0) {
    int maxMemoryBytes=mb * 1024 * 1024;
    int averageMemory=Math.max(10,pageSplitSize / 2);
    int segmentCount=16;
    int stackMoveDistance=maxMemoryBytes / averageMemory * 2 / 100;
    cache=new CacheLongKeyLIRS<Page>(maxMemoryBytes,averageMemory,segmentCount,stackMoveDistance);
  }
  o=config.get("String_Node_Str");
  int kb=o == null ? 512 : (Integer)o;
  int autoCommitBufferSize=kb * 1024 * 19;
  int div=pageSplitSize;
  autoCommitPageCount=autoCommitBufferSize / (div == 0 ? 1 : div);
  char[] encryptionKey=(char[])config.get("String_Node_Str");
  try {
    fileStore.open(fileName,readOnly,encryptionKey);
    if (fileStore.size() == 0) {
      creationTime=0;
      creationTime=getTime();
      lastCommitTime=creationTime;
      storeHeader.put("String_Node_Str","String_Node_Str");
      storeHeader.put("String_Node_Str","String_Node_Str" + BLOCK_SIZE);
      storeHeader.put("String_Node_Str","String_Node_Str" + FORMAT_WRITE);
      storeHeader.put("String_Node_Str","String_Node_Str" + creationTime);
      writeStoreHeader();
    }
 else {
      readStoreHeader();
      long format=DataUtils.parseLong(storeHeader.get("String_Node_Str"),0);
      if (format > FORMAT_WRITE && !fileStore.isReadOnly()) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_UNSUPPORTED_FORMAT,"String_Node_Str" + "String_Node_Str",format,FORMAT_WRITE);
      }
      format=DataUtils.parseLong(storeHeader.get("String_Node_Str"),format);
      if (format > FORMAT_READ) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_UNSUPPORTED_FORMAT,"String_Node_Str",format,FORMAT_READ);
      }
      if (rootChunkStart > 0) {
        readMeta();
      }
    }
  }
 catch (  IllegalStateException e) {
    try {
      closeStore(false);
    }
 catch (    Exception e2) {
    }
    throw e;
  }
 finally {
    if (encryptionKey != null) {
      Arrays.fill(encryptionKey,(char)0);
    }
  }
  lastCommitTime=getTime();
  o=config.get("String_Node_Str");
  int delay=o == null ? 1000 : (Integer)o;
  setAutoCommitDelay(delay);
}