Program: 9729
Project: 9729
Buggy source:
public Model executeConstructQuery(SparqlEndpoint endpoint,String query) throws SQLException, UnsupportedEncodingException {
  byte[] md5=md5(query);
  PreparedStatement ps=conn.prepareStatement("String_Node_Str");
  ps.setBytes(1,md5);
  ResultSet rs=ps.executeQuery();
  boolean readFromCache=rs.next() && (rs.getTimestamp("String_Node_Str").getTime() - System.currentTimeMillis() < freshnessSeconds);
  if (readFromCache) {
    Clob clob=rs.getClob("String_Node_Str");
    Model readModel=ModelFactory.createDefaultModel();
    readModel.read(clob.getAsciiStream(),null,"String_Node_Str");
    return readModel;
  }
 else {
    QueryEngineHTTP queryExecution=new QueryEngineHTTP(endpoint.getURL().toString(),query);
    for (    String dgu : endpoint.getDefaultGraphURIs()) {
      queryExecution.addDefaultGraph(dgu);
    }
    for (    String ngu : endpoint.getNamedGraphURIs()) {
      queryExecution.addNamedGraph(ngu);
    }
    Model m2=queryExecution.execConstruct();
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    m2.write(baos,"String_Node_Str");
    String modelStr=baos.toString("String_Node_Str");
    PreparedStatement ps2=conn.prepareStatement("String_Node_Str");
    ps2.setBytes(1,md5);
    ps2.setString(2,query);
    ps2.setClob(3,new StringReader(modelStr));
    ps2.setTimestamp(4,new java.sql.Timestamp(new java.util.Date().getTime()));
    ps2.executeUpdate();
    return m2;
  }
}

Fixed version (ground truth):
public Model executeConstructQuery(SparqlEndpoint endpoint,String query) throws SQLException, UnsupportedEncodingException {
  byte[] md5=md5(query);
  PreparedStatement ps=conn.prepareStatement("String_Node_Str");
  ps.setBytes(1,md5);
  ResultSet rs=ps.executeQuery();
  boolean entryExists=rs.next();
  boolean readFromCache=entryExists && (System.currentTimeMillis() - rs.getTimestamp("String_Node_Str").getTime() < freshnessInMilliseconds);
  if (readFromCache) {
    Clob clob=rs.getClob("String_Node_Str");
    Model readModel=ModelFactory.createDefaultModel();
    readModel.read(clob.getAsciiStream(),null,"String_Node_Str");
    return readModel;
  }
 else {
    QueryEngineHTTP queryExecution=new QueryEngineHTTP(endpoint.getURL().toString(),query);
    for (    String dgu : endpoint.getDefaultGraphURIs()) {
      queryExecution.addDefaultGraph(dgu);
    }
    for (    String ngu : endpoint.getNamedGraphURIs()) {
      queryExecution.addNamedGraph(ngu);
    }
    Model m2=queryExecution.execConstruct();
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    m2.write(baos,"String_Node_Str");
    String modelStr=baos.toString("String_Node_Str");
    PreparedStatement ps2;
    if (entryExists) {
      ps2=conn.prepareStatement("String_Node_Str");
      ps2.setClob(1,new StringReader(modelStr));
      ps2.setTimestamp(2,new java.sql.Timestamp(new java.util.Date().getTime()));
      ps2.setBytes(3,md5);
    }
 else {
      ps2=conn.prepareStatement("String_Node_Str");
      ps2.setBytes(1,md5);
      ps2.setString(2,query);
      ps2.setClob(3,new StringReader(modelStr));
      ps2.setTimestamp(4,new java.sql.Timestamp(new java.util.Date().getTime()));
    }
    ps2.executeUpdate();
    return m2;
  }
}