Program: 12215
Project: 12215
Buggy source:
/** 
 * Opens the SQLite database and performs all initialization required for the current mode The readonly param should only be used in experimentation where you don't want to alter previous database state. <p>semantic_memory.cpp:1952:smem_init_db
 * @param readonly
 * @throws SoarException
 * @throws SQLException
 * @throws IOException
 */
void smem_init_db(boolean readonly) throws SoarException, SQLException, IOException {
  if (db != null) {
    return;
  }
  final String db_path;
  if (true) {
    db_path="String_Node_Str";
  }
 else {
    db_path="String_Node_Str";
  }
  final Connection connection=JdbcTools.connect("String_Node_Str","String_Node_Str" + db_path);
  try {
    db=new SemanticMemoryDatabase(connection);
  }
 catch (  SoarException e) {
    connection.close();
    throw e;
  }
{
{
      final int cacheSize=5000;
      final Statement s=db.getConnection().createStatement();
      s.execute("String_Node_Str" + cacheSize);
    }
    if (false) {
      final Statement s=db.getConnection().createStatement();
      s.execute("String_Node_Str");
      s.execute("String_Node_Str");
      s.execute("String_Node_Str");
    }
  }
  smem_validation++;
  db.structure();
  db.prepare();
  smem_reset_id_counters();
  db.begin.executeUpdate();
  if (!readonly) {
    final ByRef<Long> tempMaxCycle=ByRef.create(smem_max_cycle);
    if (!smem_variable_get(smem_variable_key.var_max_cycle,tempMaxCycle)) {
      smem_max_cycle=1;
    }
 else {
      smem_max_cycle=tempMaxCycle.value;
    }
{
      ByRef<Long> temp=ByRef.create(0L);
      if (smem_variable_get(smem_variable_key.var_act_thresh,temp)) {
      }
 else {
        smem_variable_set(smem_variable_key.var_act_thresh,100L);
      }
      if (smem_variable_get(smem_variable_key.var_num_nodes,temp)) {
      }
 else {
      }
      if (smem_variable_get(smem_variable_key.var_num_edges,temp)) {
      }
 else {
      }
    }
  }
  db.commit.executeUpdate();
  if (false) {
    db.begin.executeUpdate();
  }
}

Fixed version (ground truth):
/** 
 * Opens the SQLite database and performs all initialization required for the current mode The readonly param should only be used in experimentation where you don't want to alter previous database state. <p>semantic_memory.cpp:1952:smem_init_db
 * @param readonly
 * @throws SoarException
 * @throws SQLException
 * @throws IOException
 */
void smem_init_db(boolean readonly) throws SoarException, SQLException, IOException {
  if (db != null) {
    return;
  }
  final Connection connection=JdbcTools.connect(params.driver.get(),params.path.get());
  try {
    db=new SemanticMemoryDatabase(connection);
  }
 catch (  SoarException e) {
    connection.close();
    throw e;
  }
{
{
      final int cacheSize;
switch (params.cache.get()) {
case small:
        cacheSize=5000;
      break;
case medium:
    cacheSize=20000;
  break;
case large:
default :
cacheSize=100000;
}
final Statement s=db.getConnection().createStatement();
try {
s.execute("String_Node_Str" + cacheSize);
}
  finally {
s.close();
}
}
if (params.optimization.get() == Optimization.performance) {
final Statement s=db.getConnection().createStatement();
try {
s.execute("String_Node_Str");
s.execute("String_Node_Str");
s.execute("String_Node_Str");
}
  finally {
s.close();
}
}
}
smem_validation++;
db.structure();
db.prepare();
smem_reset_id_counters();
db.begin.executeUpdate();
if (!readonly) {
final ByRef<Long> tempMaxCycle=ByRef.create(smem_max_cycle);
if (!smem_variable_get(smem_variable_key.var_max_cycle,tempMaxCycle)) {
smem_max_cycle=1;
}
 else {
smem_max_cycle=tempMaxCycle.value;
}
{
ByRef<Long> temp=ByRef.create(0L);
if (smem_variable_get(smem_variable_key.var_act_thresh,temp)) {
params.thresh.set(temp.value);
}
 else {
smem_variable_set(smem_variable_key.var_act_thresh,params.thresh.get());
}
if (smem_variable_get(smem_variable_key.var_num_nodes,temp)) {
}
 else {
}
if (smem_variable_get(smem_variable_key.var_num_edges,temp)) {
}
 else {
}
}
}
db.commit.executeUpdate();
if (params.lazy_commit.get()) {
db.begin.executeUpdate();
}
}