nus-yam/ex-repair huggingface dataset:
Program: 9830
Project: 9830
Buggy source:
public static JoinContext _collectJoins(SqlOp sqlOp,Set<String> refs){
  JoinContext result;
  SqlOps type=SqlOps.valueOf(sqlOp.getClass().getSimpleName());
switch (type) {
case SqlOpEmpty:
    result=collectJoins((SqlOpEmpty)sqlOp,refs);
  break;
case SqlOpTable:
result=collectJoins((SqlOpTable)sqlOp,refs);
break;
case SqlOpQuery:
result=collectJoins((SqlOpQuery)sqlOp,refs);
break;
case SqlOpFilter:
result=collectJoins((SqlOpFilter)sqlOp,refs);
break;
case SqlOpExtend:
result=collectJoins((SqlOpExtend)sqlOp,refs);
break;
case SqlOpRename:
result=collectJoins((SqlOpRename)sqlOp,refs);
break;
case SqlOpJoin:
result=collectJoins((SqlOpJoin)sqlOp,refs);
break;
case SqlOpUnionN:
result=collectJoins((SqlOpUnionN)sqlOp,refs);
break;
default :
logger.warn("String_Node_Str");
result=MultiMethod.invokeStatic(SqlOpSelectBlockCollectorImpl.class,"String_Node_Str",sqlOp);
break;
}
return result;
}

Fixed version (ground truth):
public static JoinContext _collectJoins(SqlOp sqlOp,Set<String> refs){
  JoinContext result;
  SqlOps type=SqlOps.valueOf(sqlOp.getClass().getSimpleName());
switch (type) {
case SqlOpEmpty:
    result=collectJoins((SqlOpEmpty)sqlOp,refs);
  break;
case SqlOpTable:
result=collectJoins((SqlOpTable)sqlOp,refs);
break;
case SqlOpQuery:
result=collectJoins((SqlOpQuery)sqlOp,refs);
break;
case SqlOpFilter:
result=collectJoins((SqlOpFilter)sqlOp,refs);
break;
case SqlOpExtend:
result=collectJoins((SqlOpExtend)sqlOp,refs);
break;
case SqlOpRename:
result=collectJoins((SqlOpRename)sqlOp,refs);
break;
case SqlOpJoin:
result=collectJoins((SqlOpJoin)sqlOp,refs);
break;
case SqlOpUnionN:
result=collectJoins((SqlOpUnionN)sqlOp,refs);
break;
case SqlOpDistinct:
{
SqlOpSelectBlock tmp=makeSelect((SqlOpDistinct)sqlOp,refs);
result=collectJoins(tmp,refs);
break;
}
case SqlOpSlice:
{
SqlOpSelectBlock tmp=makeSelect((SqlOpSlice)sqlOp,refs);
result=collectJoins(tmp,refs);
break;
}
default :
throw new RuntimeException("String_Node_Str" + sqlOp);
}
return result;
}
Program: 9832
Project: 9832
Buggy source:
public WatchDog(Statement stmt,int timeOutInMillis){
  this.stmt=stmt;
  this.timeOutInMillis=timeOutInMillis;
}

Fixed version (ground truth):
public WatchDog(Statement stmt,long timeOutInMillis){
  this.stmt=stmt;
  this.timeOutInMillis=timeOutInMillis;
}
Program: 9834
Project: 9834
Buggy source:
public static String encodeCell(String cell){
  String result=cell.replace("String_Node_Str","String_Node_Str");
  return result;
}

Fixed version (ground truth):
public static String encodeCell(String cell){
  String result;
  result=cell.replace("String_Node_Str","String_Node_Str");
  return result;
}
Program: 9835
Project: 9835
Buggy source:
@Override public int read(char[] cbuf,int off,int len) throws IOException {
  if (offset < 0) {
    return -1;
  }
  int initOff=off;
  while (len > 0) {
    int lineLen=line == null ? 0 : line.length();
    int lineAvailLen=lineLen - offset;
    int readLen=Math.min(lineAvailLen,len);
    if (readLen > 0) {
      line.getChars(offset,offset + readLen,cbuf,off);
      off+=readLen;
      len-=readLen;
      lineAvailLen-=readLen;
    }
    if (len > 0 && lineAvailLen <= 0) {
      line=nextString();
      if (line == null) {
        offset=-1;
        break;
      }
      offset=0;
    }
  }
  int result=off - initOff;
  return result;
}

Fixed version (ground truth):
@Override public int read(char[] cbuf,int dstBegin,int len) throws IOException {
  if (offset < 0) {
    return -1;
  }
  int initOff=dstBegin;
  while (len > 0) {
    int lineLen=line == null ? 0 : line.length();
    int lineAvailLen=lineLen - offset;
    int readLen=Math.min(lineAvailLen,len);
    if (readLen > 0) {
      int srcEnd=offset + readLen;
      line.getChars(offset,srcEnd,cbuf,dstBegin);
      offset=srcEnd;
      dstBegin+=readLen;
      len-=readLen;
      lineAvailLen-=readLen;
    }
    if (len > 0 && lineAvailLen <= 0) {
      line=nextString();
      if (line == null) {
        offset=-1;
        break;
      }
      offset=0;
    }
  }
  int result=dstBegin - initOff;
  return result;
}
Program: 9836
Project: 9836
Buggy source:
public static void main(String[] args) throws Exception {
  Model testModel=ModelFactory.createDefaultModel();
  testModel.read(new FileInputStream(new File("String_Node_Str")),null,"String_Node_Str");
  ModelSparqlEndpoint endpoint=new ModelSparqlEndpoint(testModel);
  UpdateGraph graph=new UpdateGraph(endpoint);
  CleanListener cleaner=new CleanListener(endpoint);
  graph.getPreUpdateListeners().add(cleaner);
  String queryString="String_Node_Str";
  IncrementalQueryUpdateManager queryUpdates=new IncrementalQueryUpdateManager(queryString,endpoint);
  cleaner.getGraphListeners().add(queryUpdates);
  String inserts=Files.readContent(new File("String_Node_Str"));
  String stmt="String_Node_Str" + inserts + "String_Node_Str";
  graph.executeUpdate(stmt);
  processChanges(queryUpdates.getChanges());
  stmt="String_Node_Str" + inserts + "String_Node_Str";
  graph.executeUpdate(stmt);
  processChanges(queryUpdates.getChanges());
  stmt="String_Node_Str";
  graph.executeUpdate(stmt);
  processChanges(queryUpdates.getChanges());
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  Model testModel=ModelFactory.createDefaultModel();
  testModel.read(new FileInputStream(new File("String_Node_Str")),null,"String_Node_Str");
  ModelSparqlEndpoint endpoint=new ModelSparqlEndpoint(testModel);
  UpdateGraph graph=new UpdateGraph(endpoint);
  CleanListener cleaner=new CleanListener(endpoint);
  graph.getPreUpdateListeners().add(cleaner);
  String queryString="String_Node_Str";
  IncrementalQueryUpdateManager queryUpdates=new IncrementalQueryUpdateManager(queryString,endpoint);
  cleaner.getGraphListeners().add(queryUpdates);
  String inserts=Files.readContent(new File("String_Node_Str"));
  String stmt="String_Node_Str" + inserts + "String_Node_Str";
  graph.executeUpdate(stmt);
  processChanges(queryUpdates.getChanges());
}
Program: 9837
Project: 9837
Buggy source:
public IteratorResultSetSparqlifyBinding(ResultSet rs,Multimap<Var,RestrictedExpr> sparqlVarMap){
  this.rs=rs;
  this.sparqlVarMap=sparqlVarMap;
}

Fixed version (ground truth):
public IteratorResultSetSparqlifyBinding(ResultSet rs,Multimap<Var,RestrictedExpr> sparqlVarMap,long nextRowId,String rowIdName){
  this.rs=rs;
  this.sparqlVarMap=sparqlVarMap;
  this.nextRowId=nextRowId;
  this.rowIdVar=rowIdName == null ? null : Var.alloc(rowIdName);
}
Program: 9839
Project: 9839
Buggy source:
public void close(){
  if (rs != null) {
    try {
      rs.close();
    }
 catch (    SQLException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void close(){
  if (rs != null) {
    try {
      rs.close();
    }
 catch (    SQLException e) {
      e.printStackTrace();
    }
  }
}
Program: 9840
Project: 9840
Buggy source:
@Override public QueryExecutionStreaming createQueryExecution(Query query){
  logger.info("String_Node_Str" + query);
  Connection conn=null;
  try {
    conn=dataSource.getConnection();
    conn.setAutoCommit(false);
    QueryExecutionStreaming result=new QueryExecutionSparqlify(rewriter,conn,true,query,this);
    conn.commit();
    return result;
  }
 catch (  SQLException e) {
    if (conn != null) {
      try {
        conn.rollback();
      }
 catch (      SQLException f) {
        throw new RuntimeException(f);
      }
    }
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public QueryExecutionStreaming createQueryExecution(Query query){
  logger.info("String_Node_Str" + query);
  Connection conn=null;
  try {
    conn=dataSource.getConnection();
    System.out.println("String_Node_Str" + conn + "String_Node_Str");
    conn.setAutoCommit(false);
    QueryExecutionStreaming result=new QueryExecutionSparqlify(rewriter,conn,true,query,this);
    return result;
  }
 catch (  SQLException e) {
    if (conn != null) {
      try {
        conn.rollback();
        conn.close();
      }
 catch (      SQLException f) {
        throw new RuntimeException(f);
      }
    }
    throw new RuntimeException(e);
  }
}
Program: 9842
Project: 9842
Buggy source:
public static SqlOp makeSelect(SqlOpJoin op){
  JoinContext context=collectJoins(op);
  SqlOpSelectBlock block=SqlOpSelectBlock.create();
  block.setSubOp(context.getOp());
  block.setSchema(op.getSchema());
  block.getProjection().add(context.getProjection());
  block.getConditions().addAll(context.getConditions());
  return block;
}

Fixed version (ground truth):
public static SqlOp makeSelect(SqlOpJoin op){
  JoinContext context=collectJoins(op);
  SqlOpSelectBlock block=contextToBlock(op.getSchema(),context);
  return block;
}
Program: 9843
Project: 9843
Buggy source:
public static SqlOp _makeSelect(SqlOp sqlOp){
  SqlOp result=MultiMethod.invokeStatic(SqlOpSelectBlockCollectorImpl.class,"String_Node_Str",sqlOp);
  return result;
}

Fixed version (ground truth):
/** 
 * Turn an SqlOp into an OpSqlSelectBlock. Exception is SqlOpUnion, which does not need to be wrapped as such block.
 * @param sqlOp
 * @return
 */
public static SqlOp _makeSelect(SqlOp sqlOp){
  SqlOp result=MultiMethod.invokeStatic(SqlOpSelectBlockCollectorImpl.class,"String_Node_Str",sqlOp);
  return result;
}
Program: 9844
Project: 9844
Buggy source:
public void serializeJoinU(SqlOp op,String aliasName,IndentedWriter writer){
  boolean isSubSelect=op instanceof SqlOpUnionN;
  if (isSubSelect) {
    writer.println("String_Node_Str");
    writer.incIndent();
  }
  serialize(op,writer);
  if (isSubSelect) {
    writer.decIndent();
    if (!writer.atLineStart()) {
      writer.println();
    }
    writer.print("String_Node_Str" + aliasName);
  }
}

Fixed version (ground truth):
public void serializeJoinU(SqlOp op,String aliasName,IndentedWriter writer){
  boolean isSubSelect=op instanceof SqlOpSelectBlock || op instanceof SqlOpUnionN;
  if (isSubSelect) {
    writer.println("String_Node_Str");
    writer.incIndent();
  }
  serialize(op,writer);
  if (isSubSelect) {
    writer.decIndent();
    if (!writer.atLineStart()) {
      writer.println();
    }
    writer.print("String_Node_Str" + aliasName);
  }
}
Program: 9847
Project: 9847
Buggy source:
public Expr transform(ExprFunction expr){
  Expr result=expr;
  if (expr.isFunction()) {
    ExprFunction fn=expr.getFunction();
    ExprTransformer transformer=lookup(fn);
    if (transformer != null) {
      result=transformer.transform(expr);
    }
  }
  return result;
}

Fixed version (ground truth):
public Expr transform(ExprFunction expr){
  Expr result=expr;
  if (expr.isFunction()) {
    ExprFunction fn=expr.getFunction();
    ExprTransformer transformer=lookup(fn);
    if (transformer != null) {
      result=transformer.transform(expr);
    }
 else {
      System.err.println("String_Node_Str" + fn);
    }
  }
  return result;
}
Program: 9848
Project: 9848
Buggy source:
/** 
 * If there are multiple definitions for any of the specified variables, each definition results in a new mapping. The result is then a union of these mappings.
 * @param m
 */
public static List<Mapping> refactorToUnion(Mapping m,List<Var> tmpVars){
  List<Mapping> result=new ArrayList<Mapping>();
  VarDefinition varDef=m.getVarDefinition();
  List<Var> vars=new ArrayList<Var>(tmpVars.size());
  List<Collection<RestrictedExpr>> c=new ArrayList<Collection<RestrictedExpr>>(tmpVars.size());
  for (  Var var : tmpVars) {
    Collection<RestrictedExpr> defs=varDef.getDefinitions(var);
    if (defs.isEmpty()) {
      continue;
    }
    vars.add(var);
    c.add(defs);
  }
  Multimap<Var,RestrictedExpr> baseMap=HashMultimap.create(varDef.getMap());
  baseMap.keySet().removeAll(vars);
  CartesianProduct<RestrictedExpr> cart=CartesianProduct.create(c);
  for (  List<RestrictedExpr> item : cart) {
    Multimap<Var,RestrictedExpr> map=HashMultimap.create(varDef.getMap());
    for (int i=0; i < vars.size(); ++i) {
      Var var=vars.get(i);
      RestrictedExpr restExpr=item.get(i);
      map.put(var,restExpr);
    }
    VarDefinition newVd=new VarDefinition(map);
    Mapping newM=new Mapping(newVd,m.getSqlOp());
    result.add(newM);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * If there are multiple definitions for any of the specified variables, each definition results in a new mapping. The result is then a union of these mappings.
 * @param m
 */
public static List<Mapping> refactorToUnion(Mapping m,List<Var> tmpVars){
  List<Mapping> result=new ArrayList<Mapping>();
  VarDefinition varDef=m.getVarDefinition();
  List<Var> vars=new ArrayList<Var>(tmpVars.size());
  List<Collection<RestrictedExpr>> c=new ArrayList<Collection<RestrictedExpr>>(tmpVars.size());
  if (tmpVars.isEmpty()) {
    result.add(m);
    return result;
  }
  for (  Var var : tmpVars) {
    Collection<RestrictedExpr> defs=varDef.getDefinitions(var);
    if (defs.isEmpty()) {
      continue;
    }
    vars.add(var);
    c.add(defs);
  }
  Multimap<Var,RestrictedExpr> baseMap=HashMultimap.create(varDef.getMap());
  baseMap.keySet().removeAll(vars);
  CartesianProduct<RestrictedExpr> cart=CartesianProduct.create(c);
  for (  List<RestrictedExpr> item : cart) {
    Multimap<Var,RestrictedExpr> map=HashMultimap.create(varDef.getMap());
    for (int i=0; i < vars.size(); ++i) {
      Var var=vars.get(i);
      RestrictedExpr restExpr=item.get(i);
      map.put(var,restExpr);
    }
    VarDefinition newVd=new VarDefinition(map);
    Mapping newM=new Mapping(newVd,m.getSqlOp());
    result.add(newM);
  }
  return result;
}
Program: 9849
Project: 9849
Buggy source:
/** 
 * Eleminate self-joins from the conjunction In place operation
 * @param conjunction
 * @return
 */
public static void merge(ViewInstanceJoin conjunction){
  for (int i=0; i < conjunction.getViewInstances().size(); ++i) {
    ViewInstance a=conjunction.getViewInstances().get(i);
    for (int j=i + 1; j < conjunction.getViewInstances().size(); ++j) {
      ViewInstance b=conjunction.getViewInstances().get(j);
      ViewInstance view=merge(a,b);
      if (view != null) {
        a=view;
        conjunction.getViewInstances().set(i,view);
        conjunction.getViewInstances().remove(j);
        --j;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Eleminate self-joins from the conjunction In place operation
 * @param conjunction
 * @return
 */
public static void merge(ViewInstanceJoin conjunction){
  ListMultimap<String,ViewInstance> nameToInstance=conjunction.getInstancesGroupedByParent();
  for (  Entry<String,Collection<ViewInstance>> entry : nameToInstance.asMap().entrySet()) {
    List<ViewInstance> list=(List<ViewInstance>)entry.getValue();
    eliminateSelfJoins(list);
  }
}
Program: 9850
Project: 9850
Buggy source:
public static ExprEvaluator createDefaultEvaluator(){
  ExprTransformerMap exprTransformer=new ExprTransformerMap();
  ExprEvaluatorPartial evaluator=new ExprEvaluatorPartial(FunctionRegistry.get(),exprTransformer);
  Map<String,ExprTransformer> transMap=exprTransformer.getTransformerMap();
  transMap.put("String_Node_Str",new ExprTransformerConcatNested());
  transMap.put("String_Node_Str",new ExprTransformerLang());
  transMap.put("String_Node_Str",new ExprTransformerRdfTermComparator(evaluator));
  transMap.put("String_Node_Str",new ExprTransformerRdfTermComparator(evaluator));
  transMap.put("String_Node_Str",new ExprTransformerLogicalAnd());
  return evaluator;
}

Fixed version (ground truth):
public static ExprEvaluator createDefaultEvaluator(){
  ExprTransformerMap exprTransformer=new ExprTransformerMap();
  ExprEvaluatorPartial evaluator=new ExprEvaluatorPartial(FunctionRegistry.get(),exprTransformer);
  Map<String,ExprTransformer> transMap=exprTransformer.getTransformerMap();
  transMap.put("String_Node_Str",new ExprTransformerConcatNested());
  transMap.put("String_Node_Str",new ExprTransformerLang());
  transMap.put("String_Node_Str",new ExprTransformerRdfTermComparator(evaluator));
  transMap.put("String_Node_Str",new ExprTransformerRdfTermComparator(evaluator));
  transMap.put("String_Node_Str",new ExprTransformerRdfTermComparator(evaluator));
  transMap.put("String_Node_Str",new ExprTransformerRdfTermComparator(evaluator));
  transMap.put("String_Node_Str",new ExprTransformerRdfTermComparator(evaluator));
  transMap.put("String_Node_Str",new ExprTransformerLogicalAnd());
  return evaluator;
}
Program: 9851
Project: 9851
Buggy source:
public ViewInstanceJoin(List<ViewInstance> viewBindings,RestrictionManagerImpl restrictions){
  super();
  this.viewInstances=viewBindings;
  this.restrictions=restrictions;
}

Fixed version (ground truth):
public ViewInstanceJoin(ListMultimap<String,ViewInstance> nameToInstances,RestrictionManagerImpl restrictions){
  super();
  this.nameToInstances=nameToInstances;
  this.restrictions=restrictions;
}
Program: 9852
Project: 9852
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + viewInstances;
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + getViewInstances();
}
Program: 9853
Project: 9853
Buggy source:
public List<ViewInstance> getViewInstances(){
  return viewInstances;
}

Fixed version (ground truth):
public Collection<ViewInstance> getViewInstances(){
  return nameToInstances.values();
}
Program: 9854
Project: 9854
Buggy source:
public List<String> getViewNames(){
  List<String> result=new ArrayList<String>(viewInstances.size());
  for (  ViewInstance instance : viewInstances) {
    result.add(instance.getViewDefinition().getName());
  }
  return result;
}

Fixed version (ground truth):
public List<String> getViewNames(){
  Collection<ViewInstance> viewInstances=getViewInstances();
  List<String> result=new ArrayList<String>(viewInstances.size());
  for (  ViewInstance instance : viewInstances) {
    result.add(instance.getViewDefinition().getName());
  }
  return result;
}
Program: 9855
Project: 9855
Buggy source:
@Test public void creationTest() throws RecognitionException, SQLException, IOException {
  RdfViewSystemOld.initSparqlifyFunctions();
  DatatypeSystem datatypeSystem=SparqlifyUtils.createDefaultDatatypeSystem();
  SqlTranslator sqlTranslator=new SqlTranslatorImpl(datatypeSystem);
  DataSource dataSource=SparqlifyUtils.createTestDatabase();
  Connection conn=dataSource.getConnection();
  Map<String,String> typeAlias=MapReader.readFile(new File("String_Node_Str"));
  SqlExprSerializer serExpr=null;
  SqlFunctionSerializer serFn=null;
  ViewDefinitionFactory vdf=SparqlifyUtils.createViewDefinitionFactory(conn,typeAlias);
  ViewDefinition personView=vdf.create("String_Node_Str");
  ViewDefinition deptView=vdf.create("String_Node_Str");
  ViewDefinition personToDeptView=vdf.create("String_Node_Str");
  ViewDefinition personAgeView=vdf.create("String_Node_Str");
  ViewDefinition personAndAgeView=vdf.create("String_Node_Str");
  CandidateViewSelector candidateViewSelector=new CandidateViewSelectorImpl();
  candidateViewSelector.addView(personView);
  candidateViewSelector.addView(deptView);
  candidateViewSelector.addView(personToDeptView);
  candidateViewSelector.addView(personAgeView);
  SparqlSqlRewriter rewriter=SparqlifyUtils.createTestRewriter(candidateViewSelector,datatypeSystem);
  QueryExecutionFactory qef=new QueryExecutionFactorySparqlifyDs(rewriter,dataSource);
{
    QueryExecution qe=qef.createQueryExecution("String_Node_Str");
    ResultSet rs=qe.execSelect();
    String rsStr=ResultSetFormatter.asText(rs);
    System.out.println(rsStr);
  }
}

Fixed version (ground truth):
@Test public void creationTest() throws RecognitionException, SQLException, IOException {
  RdfViewSystemOld.initSparqlifyFunctions();
  DatatypeSystem datatypeSystem=SparqlifyUtils.createDefaultDatatypeSystem();
  SqlTranslator sqlTranslator=new SqlTranslatorImpl(datatypeSystem);
  DataSource dataSource=SparqlifyUtils.createTestDatabase();
  Connection conn=dataSource.getConnection();
  Map<String,String> typeAlias=MapReader.readFile(new File("String_Node_Str"));
  SqlExprSerializer serExpr=null;
  SqlFunctionSerializer serFn=null;
  ViewDefinitionFactory vdf=SparqlifyUtils.createViewDefinitionFactory(conn,typeAlias);
  ViewDefinition personView=vdf.create("String_Node_Str");
  ViewDefinition deptView=vdf.create("String_Node_Str");
  ViewDefinition personToDeptView=vdf.create("String_Node_Str");
  ViewDefinition personAgeView=vdf.create("String_Node_Str");
  ViewDefinition personAndAgeView=vdf.create("String_Node_Str");
  CandidateViewSelector candidateViewSelector=new CandidateViewSelectorImpl();
  candidateViewSelector.addView(deptView);
  candidateViewSelector.addView(personAndAgeView);
  SparqlSqlRewriter rewriter=SparqlifyUtils.createTestRewriter(candidateViewSelector,datatypeSystem);
  QueryExecutionFactory qef=new QueryExecutionFactorySparqlifyDs(rewriter,dataSource);
{
    QueryExecution qe=qef.createQueryExecution("String_Node_Str");
    ResultSet rs=qe.execSelect();
    String rsStr=ResultSetFormatter.asText(rs);
    System.out.println(rsStr);
  }
}
Program: 9857
Project: 9857
Buggy source:
@Override public Mapping rewrite(Op op){
  Mapping result;
  if (op instanceof OpViewInstanceJoin) {
    result=rewrite((OpViewInstanceJoin)op);
  }
 else   if (op instanceof OpDisjunction) {
    result=rewrite((OpDisjunction)op);
  }
 else   if (op instanceof OpFilterIndexed) {
    result=rewrite((OpFilterIndexed)op);
  }
 else   if (op instanceof OpProject) {
    result=rewrite((OpProject)op);
  }
 else   if (op instanceof OpJoin) {
    result=rewrite((OpJoin)op);
  }
 else   if (op instanceof OpLeftJoin) {
    result=rewrite((OpLeftJoin)op);
  }
 else   if (op instanceof OpConditional) {
    result=rewrite((OpConditional)op);
  }
 else   if (op instanceof OpSlice) {
    result=rewrite((OpSlice)op);
  }
 else   if (op instanceof OpDistinct) {
    result=rewrite((OpDistinct)op);
  }
 else   if (op instanceof OpGroup) {
    result=rewrite((OpGroup)op);
  }
 else   if (op instanceof OpExtend) {
    result=rewrite((OpExtend)op);
  }
 else   if (op instanceof OpAssign) {
    result=rewrite((OpAssign)op);
  }
 else {
    throw new RuntimeException("String_Node_Str" + op.getClass() + "String_Node_Str"+ op);
  }
  return result;
}

Fixed version (ground truth):
@Override public Mapping rewrite(Op op){
  Mapping result;
  if (op instanceof OpViewInstanceJoin) {
    result=rewrite((OpViewInstanceJoin)op);
  }
 else   if (op instanceof OpDisjunction) {
    result=rewrite((OpDisjunction)op);
  }
 else   if (op instanceof OpFilterIndexed) {
    result=rewrite((OpFilterIndexed)op);
  }
 else   if (op instanceof OpProject) {
    result=rewrite((OpProject)op);
  }
 else   if (op instanceof OpJoin) {
    result=rewrite((OpJoin)op);
  }
 else   if (op instanceof OpLeftJoin) {
    result=rewrite((OpLeftJoin)op);
  }
 else   if (op instanceof OpSequence) {
    result=rewrite((OpSequence)op);
  }
 else   if (op instanceof OpConditional) {
    result=rewrite((OpConditional)op);
  }
 else   if (op instanceof OpSlice) {
    result=rewrite((OpSlice)op);
  }
 else   if (op instanceof OpDistinct) {
    result=rewrite((OpDistinct)op);
  }
 else   if (op instanceof OpGroup) {
    result=rewrite((OpGroup)op);
  }
 else   if (op instanceof OpExtend) {
    result=rewrite((OpExtend)op);
  }
 else   if (op instanceof OpAssign) {
    result=rewrite((OpAssign)op);
  }
 else {
    throw new RuntimeException("String_Node_Str" + op.getClass() + "String_Node_Str"+ op);
  }
  return result;
}
Program: 9858
Project: 9858
Buggy source:
public static Op optimize(Op op,RestrictionManagerImpl cnf){
  if (op instanceof OpNull) {
    return op;
  }
  Op result=MultiMethod.invokeStatic(FilterPlacementOptimizer2.class,"String_Node_Str",op,cnf);
  return result;
}

Fixed version (ground truth):
public static Op optimize(Op op,RestrictionManagerImpl cnf){
  Op result=MultiMethod.invokeStatic(FilterPlacementOptimizer2.class,"String_Node_Str",op,cnf);
  return result;
}
Program: 9859
Project: 9859
Buggy source:
public static RestrictionManagerImpl filterByVars(RestrictionManagerImpl cnf,Op op){
  Set<Clause> clauses=cnf.getClausesForVars(GetVarsMentioned.getVarsMentioned(op));
  return new RestrictionManagerImpl(new NestedNormalForm(clauses));
}

Fixed version (ground truth):
public static RestrictionManagerImpl filterByVars(RestrictionManagerImpl cnf,Op op){
  Set<Var> vars=GetVarsMentioned.getVarsMentioned(op);
  Set<Clause> clauses=cnf.getClausesForVars(vars);
  return new RestrictionManagerImpl(new NestedNormalForm(clauses));
}
Program: 9860
Project: 9860
Buggy source:
public Set<Clause> getClausesForVars(Collection<Var> vars){
  Set<Clause> result=new HashSet<Clause>();
  for (  Var var : vars) {
    Set<Clause> tmp=cnf.getClausesByVar(var);
    if (tmp != null) {
      result.addAll(tmp);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Returns all clauses having any of the given variables
 * @param vars
 * @return
 */
public Set<Clause> getClausesForVars(Collection<Var> vars){
  Set<Clause> result=new HashSet<Clause>();
  for (  Var var : vars) {
    Set<Clause> tmp=cnf.getClausesByVar(var);
    if (tmp != null) {
      result.addAll(tmp);
    }
  }
  return result;
}
Program: 9861
Project: 9861
Buggy source:
public static Map<String,String> readFile(File file) throws IOException {
  Map<String,String> result=new HashMap<String,String>();
  BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(file)));
  try {
    String line=null;
    while ((line=reader.readLine()) != null) {
      line=line.trim();
      if (line.isEmpty() || line.startsWith("String_Node_Str")) {
        continue;
      }
      String[] parts=line.split("String_Node_Str",2);
      if (parts.length != 2) {
        logger.debug("String_Node_Str" + parts[0]);
        continue;
      }
      result.put(parts[0],parts[1]);
    }
  }
  finally {
    reader.close();
  }
  return result;
}

Fixed version (ground truth):
@Deprecated public static Map<String,String> readFile(File file) throws IOException {
  return read(file);
}
Program: 9862
Project: 9862
Buggy source:
public static DatatypeSystemCustom createDefaultDatatypeSystem() throws IOException {
  Map<String,String> typeNameToClass=MapReader.readFile(new File("String_Node_Str"));
  Map<String,String> typeNameToUri=MapReader.readFile(new File("String_Node_Str"));
  Map<String,String> typeHierarchy=MapReader.readFile(new File("String_Node_Str"));
  DatatypeSystemCustom result=DatatypeSystemCustom.create(typeNameToClass,typeNameToUri,typeHierarchy,SparqlifyUtils.logger);
  initDatatypeSystem(result);
  return result;
}

Fixed version (ground truth):
public static DatatypeSystemCustom createDefaultDatatypeSystem() throws IOException {
  Map<String,String> typeNameToClass=readMapFromResource("String_Node_Str");
  Map<String,String> typeNameToUri=readMapFromResource("String_Node_Str");
  Map<String,String> typeHierarchy=readMapFromResource("String_Node_Str");
  DatatypeSystemCustom result=DatatypeSystemCustom.create(typeNameToClass,typeNameToUri,typeHierarchy,SparqlifyUtils.logger);
  initDatatypeSystem(result);
  return result;
}
Program: 9863
Project: 9863
Buggy source:
@Override public boolean isConstant(){
  for (  Expr expr : super.getArgs()) {
    if (!expr.isConstant()) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean isConstant(){
  return false;
}
Program: 9865
Project: 9865
Buggy source:
@Override public Mapping select(Mapping a,ExprList exprs){
  Map<String,TypeToken> typeMap=a.getSqlOp().getSchema().getTypeMap();
  List<SqlExpr> sqlExprs=new ArrayList<SqlExpr>();
  for (  Expr expr : exprs) {
    SqlExpr sqlExpr=createSqlCondition(expr,a.getVarDefinition(),typeMap,sqlTranslator);
    if (sqlExpr.equals(S_Constant.TRUE)) {
      continue;
    }
    sqlExprs.add(sqlExpr);
  }
  SqlOp op=SqlOpFilter.createIfNeeded(a.getSqlOp(),sqlExprs);
  Mapping result=new Mapping(a.getVarDefinition(),op);
  return result;
}

Fixed version (ground truth):
@Override public Mapping select(Mapping a,ExprList exprs){
  Map<String,TypeToken> typeMap=a.getSqlOp().getSchema().getTypeMap();
  List<SqlExpr> sqlExprs=new ArrayList<SqlExpr>();
  for (  Expr expr : exprs) {
    SqlExpr sqlExpr=createSqlCondition(expr,a.getVarDefinition(),typeMap,exprTransformer,sqlTranslator);
    if (sqlExpr.equals(S_Constant.TRUE)) {
      continue;
    }
    sqlExprs.add(sqlExpr);
  }
  SqlOp op=SqlOpFilter.createIfNeeded(a.getSqlOp(),sqlExprs);
  Mapping result=new Mapping(a.getVarDefinition(),op);
  return result;
}
Program: 9867
Project: 9867
Buggy source:
/** 
 * Creates an SQL condidion given a (SPARQL query filter) condition and a set of variable definitions. The resulting expression takes alternatives into account: Given for example: ?s -> {sa1, ..., san} ?o -> {so1} ?o must hold independently of ?s
 */
public static SqlExpr createSqlCondition(Expr condition,VarDefinition varDef,Map<String,TypeToken> typeMap,SqlTranslator sqlTranslator){
}

Fixed version (ground truth):
/** 
 * Creates an SQL condidion given a (SPARQL query filter) condition and a set of variable definitions. The resulting expression takes alternatives into account: Given for example: ?s -> {sa1, ..., san} ?o -> {so1} ?o must hold independently of ?s
 */
public static SqlExpr createSqlCondition(Expr condition,VarDefinition varDef,Map<String,TypeToken> typeMap,ExprEvaluator exprTransformer,SqlTranslator sqlTranslator){
}
Program: 9868
Project: 9868
Buggy source:
@Override public Mapping slice(Mapping a,Long limit,Long offset){
  SqlOpSlice opSlice=SqlOpSlice.create(a.getSqlOp(),limit,offset);
  Mapping result=new Mapping(a.getVarDefinition(),opSlice);
  return result;
}

Fixed version (ground truth):
@Override public Mapping slice(Mapping a,Long limit,Long offset){
  SqlOpSlice opSlice=SqlOpSlice.create(a.getSqlOp(),offset,limit);
  Mapping result=new Mapping(a.getVarDefinition(),opSlice);
  return result;
}
Program: 9869
Project: 9869
Buggy source:
public static Op surroundWithFilterIfNeccessary(Op op,RestrictionManagerImpl cnf){
  if (cnf.getCnf().isEmpty()) {
    return op;
  }
 else {
    Op result=new OpFilterIndexed(op,cnf);
    return result;
  }
}

Fixed version (ground truth):
public static Op surroundWithFilterIfNeccessary(Op op,RestrictionManagerImpl cnf){
  Op result;
  if (cnf.isUnsatisfiable()) {
    result=new OpFilterIndexed(op,new RestrictionManagerImpl(new NestedNormalForm(new HashSet<Clause>(Collections.singleton(new Clause(new HashSet<Expr>(Collections.singleton(NodeValue.FALSE))))))));
  }
 else   if (cnf.getCnf().isEmpty()) {
    result=op;
  }
 else {
    result=new OpFilterIndexed(op,cnf);
  }
  return result;
}
Program: 9870
Project: 9870
Buggy source:
public static Op optimize(Op op,RestrictionManagerImpl cnf){
  if (op instanceof OpNull) {
    return op;
  }
  return (Op)MultiMethod.invokeStatic(FilterPlacementOptimizer2.class,"String_Node_Str",op,cnf);
}

Fixed version (ground truth):
public static Op optimize(Op op,RestrictionManagerImpl cnf){
  if (op instanceof OpNull) {
    return op;
  }
  Op result=MultiMethod.invokeStatic(FilterPlacementOptimizer2.class,"String_Node_Str",op,cnf);
  return result;
}
Program: 9871
Project: 9871
Buggy source:
@Test public void creationTest() throws RecognitionException, SQLException, IOException {
  RdfViewSystemOld.initSparqlifyFunctions();
  DatatypeSystem datatypeSystem=SparqlifyUtils.createDefaultDatatypeSystem();
  SqlTranslator sqlTranslator=new SqlTranslatorImpl(datatypeSystem);
  DataSource dataSource=SparqlifyUtils.createTestDatabase();
  Connection conn=dataSource.getConnection();
  Map<String,String> typeAlias=MapReader.readFile(new File("String_Node_Str"));
  ViewDefinitionFactory vdf=SparqlifyUtils.createViewDefinitionFactory(conn,typeAlias);
  ViewDefinition personView=vdf.create("String_Node_Str");
  ViewDefinition deptView=vdf.create("String_Node_Str");
  ViewDefinition personToDeptView=vdf.create("String_Node_Str");
  CandidateViewSelector candidateViewSelector=new CandidateViewSelectorImpl();
  candidateViewSelector.addView(personView);
  candidateViewSelector.addView(deptView);
  candidateViewSelector.addView(personToDeptView);
  SparqlSqlRewriter rewriter=SparqlifyUtils.createTestRewriter(candidateViewSelector,datatypeSystem);
  QueryExecutionFactory qef=new QueryExecutionFactorySparqlifyDs(rewriter,dataSource);
{
    QueryExecution qe=qef.createQueryExecution("String_Node_Str");
    ResultSet rs=qe.execSelect();
    String rsStr=ResultSetFormatter.asText(rs);
    System.out.println(rsStr);
  }
{
    QueryExecution qe=qef.createQueryExecution("String_Node_Str");
    ResultSet rs=qe.execSelect();
    String rsStr=ResultSetFormatter.asText(rs);
    System.out.println(rsStr);
  }
}

Fixed version (ground truth):
@Test public void creationTest() throws RecognitionException, SQLException, IOException {
  RdfViewSystemOld.initSparqlifyFunctions();
  DatatypeSystem datatypeSystem=SparqlifyUtils.createDefaultDatatypeSystem();
  SqlTranslator sqlTranslator=new SqlTranslatorImpl(datatypeSystem);
  DataSource dataSource=SparqlifyUtils.createTestDatabase();
  Connection conn=dataSource.getConnection();
  Map<String,String> typeAlias=MapReader.readFile(new File("String_Node_Str"));
  ViewDefinitionFactory vdf=SparqlifyUtils.createViewDefinitionFactory(conn,typeAlias);
  ViewDefinition personView=vdf.create("String_Node_Str");
  ViewDefinition deptView=vdf.create("String_Node_Str");
  ViewDefinition personToDeptView=vdf.create("String_Node_Str");
  CandidateViewSelector candidateViewSelector=new CandidateViewSelectorImpl();
  candidateViewSelector.addView(personView);
  candidateViewSelector.addView(deptView);
  candidateViewSelector.addView(personToDeptView);
  SparqlSqlRewriter rewriter=SparqlifyUtils.createTestRewriter(candidateViewSelector,datatypeSystem);
  QueryExecutionFactory qef=new QueryExecutionFactorySparqlifyDs(rewriter,dataSource);
{
    QueryExecution qe=qef.createQueryExecution("String_Node_Str");
    ResultSet rs=qe.execSelect();
    String rsStr=ResultSetFormatter.asText(rs);
    System.out.println(rsStr);
  }
}
Program: 9872
Project: 9872
Buggy source:
/** 
 * In place projection
 * @param columnNames
 */
public void project(List<String> columnNames){
  this.names.retainAll(columnNames);
  this.nameToExpr.keySet().retainAll(columnNames);
}

Fixed version (ground truth):
/** 
 * In place projection
 * @param columnNames
 */
public void project(List<String> columnNames){
  this.names=columnNames;
  this.nameToExpr.keySet().retainAll(columnNames);
}
Program: 9874
Project: 9874
Buggy source:
@Override public SparqlSqlRewrite rewrite(Query query){
  Op opViewInstance=candidateViewSelector.getApplicableViews(query);
  logger.debug("String_Node_Str" + opViewInstance);
  List<Var> projectionOrder=null;
  if (query.isSelectType() && query.isQueryResultStar()) {
    projectionOrder=query.getProjectVars();
  }
 else {
    projectionOrder=query.getProjectVars();
  }
  Mapping mapping=opMappingRewriter.rewrite(opViewInstance);
  logger.debug("String_Node_Str" + mapping);
  SqlOp block=sqlOpSelectBlockCollector.transform(mapping.getSqlOp());
  String sqlQueryString=sqlOpSerializer.serialize(block);
  logger.info(sqlQueryString);
  SparqlSqlRewrite result=new SparqlSqlRewrite(sqlQueryString,mapping.getVarDefinition(),projectionOrder);
  return result;
}

Fixed version (ground truth):
@Override public SparqlSqlRewrite rewrite(Query query){
  Op opViewInstance=candidateViewSelector.getApplicableViews(query);
  logger.debug("String_Node_Str" + opViewInstance);
  List<Var> projectionOrder=null;
  if (query.isSelectType() && query.isQueryResultStar()) {
    projectionOrder=query.getProjectVars();
  }
 else {
    projectionOrder=query.getProjectVars();
  }
  Mapping mapping=opMappingRewriter.rewrite(opViewInstance);
  logger.debug("String_Node_Str" + toIndentedString(mapping.getVarDefinition()));
  SqlOp block=sqlOpSelectBlockCollector.transform(mapping.getSqlOp());
  String sqlQueryString=sqlOpSerializer.serialize(block);
  logger.info("String_Node_Str" + sqlQueryString);
  SparqlSqlRewrite result=new SparqlSqlRewrite(sqlQueryString,mapping.getVarDefinition(),projectionOrder);
  return result;
}
Program: 9875
Project: 9875
Buggy source:
public VarDefinition copyExpandConstants(){
  Multimap<Var,RestrictedExpr> resultMap=HashMultimap.create();
  for (  Entry<Var,RestrictedExpr> entry : varToExprs.entries()) {
    Var var=entry.getKey();
    RestrictedExpr restExpr=entry.getValue();
    Expr expr=restExpr.getExpr();
    Expr expandedExpr=ConstantExpander.transform(expr);
    RestrictedExpr finalExpr=new RestrictedExpr(expandedExpr,restExpr.getRestrictions());
    resultMap.put(var,finalExpr);
  }
  VarDefinition result=new VarDefinition(resultMap);
  return result;
}

Fixed version (ground truth):
public VarDefinition copyExpandConstants(){
  Multimap<Var,RestrictedExpr> resultMap=HashMultimap.create();
  for (  Entry<Var,RestrictedExpr> entry : varToExprs.entries()) {
    Var var=entry.getKey();
    RestrictedExpr restExpr=entry.getValue();
    Expr expr=restExpr.getExpr();
    Expr expandedExpr;
    if (expr.isConstant()) {
      expandedExpr=ConstantExpander._transform(expr.getConstant());
    }
 else {
      expandedExpr=expr;
    }
    RestrictedExpr finalExpr=new RestrictedExpr(expandedExpr,restExpr.getRestrictions());
    resultMap.put(var,finalExpr);
  }
  VarDefinition result=new VarDefinition(resultMap);
  return result;
}
Program: 9876
Project: 9876
Buggy source:
public DatatypeSystemDefault(){
  for (  SqlDatatype item : DatatypeSystemDefault.getDefaultDatatypes()) {
    nameToDatatype.put(item.getName(),item);
  }
  for (  Entry<SqlDatatype,SqlDatatype> entry : childToParent.entries()) {
    typeHierarchy.put(entry.getKey(),entry.getValue());
  }
}

Fixed version (ground truth):
public DatatypeSystemDefault(){
  for (  SqlDatatype item : DatatypeSystemDefault.getDefaultDatatypes()) {
    nameToDatatype.put(item.getName(),item);
    if (item.getXsd() != null) {
      nameToDatatype.put(item.getXsd().getURI(),item);
    }
  }
  for (  Entry<SqlDatatype,SqlDatatype> entry : childToParent.entries()) {
    typeHierarchy.put(entry.getKey(),entry.getValue());
  }
}
Program: 9877
Project: 9877
Buggy source:
public static void main(String[] args) throws Exception {
  PropertyConfigurator.configure("String_Node_Str");
  Connection conn=getConnection();
  RdfViewSystemOld system=configureSystem(conn);
  QueryExecutionFactory sparqler=new QueryExecutionFactorySparqlify(system,conn);
  String polygon="String_Node_Str";
  String prefixes="String_Node_Str";
  prefixes+="String_Node_Str";
  prefixes+="String_Node_Str" + OWL.getURI() + "String_Node_Str";
  prefixes+="String_Node_Str" + RDFS.getURI() + "String_Node_Str";
  String str=prefixes + "String_Node_Str";
  ResultSet rs=sparqler.createQueryExecution(str).execSelect();
  System.out.println(ResultSetFormatter.asText(rs));
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  PropertyConfigurator.configure("String_Node_Str");
  if (true) {
    String str="String_Node_Str";
    Query q=QueryFactory.create(str);
    Op op=Algebra.compile(q);
    Algebra.toQuadForm(op);
    System.out.println(op);
    return;
  }
  Connection conn=getConnection();
  RdfViewSystemOld system=configureSystem(conn);
  QueryExecutionFactory sparqler=new QueryExecutionFactorySparqlify(system,conn);
  String polygon="String_Node_Str";
  String prefixes="String_Node_Str";
  prefixes+="String_Node_Str";
  prefixes+="String_Node_Str" + OWL.getURI() + "String_Node_Str";
  prefixes+="String_Node_Str" + RDFS.getURI() + "String_Node_Str";
  String str=prefixes + "String_Node_Str";
  ResultSet rs=sparqler.createQueryExecution(str).execSelect();
  System.out.println(ResultSetFormatter.asText(rs));
}
Program: 9878
Project: 9878
Buggy source:
public static int hash(Expr expr,Map<String,SqlDatatype> columnToDatatype){
  return (Integer)MultiMethod.invokeStatic(ExprDatatypeHash.class,"String_Node_Str",expr,columnToDatatype);
}

Fixed version (ground truth):
public static int hash(Expr expr,Map<String,SqlDatatype> columnToDatatype){
  if (expr == null) {
    return 7531902;
  }
  return (Integer)MultiMethod.invokeStatic(ExprDatatypeHash.class,"String_Node_Str",expr,columnToDatatype);
}
Program: 9880
Project: 9880
Buggy source:
public Map<Var,Type> deriveTypeConstraints(RdfView view){
  Map<Var,Type> result=new HashMap<Var,Type>();
  for (  Entry<Node,Expr> entry : view.getBinding().entrySet()) {
    Var var=(Var)entry.getKey();
    ExprFunction termCtor=(ExprFunction)entry.getValue();
    String functionIri=termCtor.getFunctionSymbol().getSymbol();
    if (functionIri.equals(SparqlifyConstants.rdfTermLabel)) {
      Expr arg=termCtor.getArg(1);
      if (arg.isConstant()) {
        Object o=PushDown.getValue(arg.getConstant());
        Number number=(Number)o;
switch (number.intValue()) {
case 1:
          result.put(var,Type.URI);
        break;
case 2:
case 3:
      result.put(var,Type.LITERAL);
    break;
}
}
}
 else if (functionIri.equals(SparqlifyConstants.uriLabel)) {
result.put(var,Type.URI);
}
 else if (functionIri.equals(SparqlifyConstants.plainLiteralLabel) || functionIri.equals(SparqlifyConstants.typedLiteralLabel)) {
result.put(var,Type.LITERAL);
}
}
return result;
}

Fixed version (ground truth):
public Map<Var,Type> deriveTypeConstraints(RdfView view){
  Map<Var,Type> result=new HashMap<Var,Type>();
  for (  Entry<Node,Expr> entry : view.getBinding().entrySet()) {
    Var var=(Var)entry.getKey();
    ExprFunction termCtor=(ExprFunction)entry.getValue();
    String functionIri=termCtor.getFunctionSymbol().getSymbol();
    if (functionIri.equals(SparqlifyConstants.rdfTermLabel)) {
      Expr arg=termCtor.getArg(1);
      if (arg.isConstant()) {
        Object o=NodeValueUtils.getValue(arg.getConstant());
        Number number=(Number)o;
switch (number.intValue()) {
case 1:
          result.put(var,Type.URI);
        break;
case 2:
case 3:
      result.put(var,Type.LITERAL);
    break;
}
}
}
 else if (functionIri.equals(SparqlifyConstants.uriLabel)) {
result.put(var,Type.URI);
}
 else if (functionIri.equals(SparqlifyConstants.plainLiteralLabel) || functionIri.equals(SparqlifyConstants.typedLiteralLabel)) {
result.put(var,Type.LITERAL);
}
}
return result;
}
Program: 9881
Project: 9881
Buggy source:
/** 
 * If a variable equals a (uri or string) constant, it means that the view must provide a prefix for that value.
 * @param a
 * @param b
 * @return
 */
public static VariableConstraint deriveIsPrefixOfConstraint(Expr a,Expr b){
  if (!(a.isVariable() && b.isConstant())) {
    return null;
  }
  Object value=PushDown.getValue(b.getConstant());
  return new VariableConstraint(a.getVarName(),new IsPrefixOfConstraint(value.toString()));
}

Fixed version (ground truth):
/** 
 * If a variable equals a (uri or string) constant, it means that the view must provide a prefix for that value.
 * @param a
 * @param b
 * @return
 */
public static VariableConstraint deriveIsPrefixOfConstraint(Expr a,Expr b){
  if (!(a.isVariable() && b.isConstant())) {
    return null;
  }
  Object value=NodeValueUtils.getValue(b.getConstant());
  return new VariableConstraint(a.getVarName(),new IsPrefixOfConstraint(value.toString()));
}
Program: 9882
Project: 9882
Buggy source:
@Override public boolean login() throws LoginException {
  log.debug("String_Node_Str");
  try {
    Callback[] callbacks=new Callback[]{new NameCallback("String_Node_Str")};
    callbackHandler.handle(callbacks);
    String username=((NameCallback)callbacks[0]).getName();
    if (username != null) {
      OrganizationService service=(OrganizationService)getContainer().getComponentInstanceOfType(OrganizationService.class);
      UserHandler uHandler=service.getUserHandler();
      User user=uHandler.findUserByName(username,UserStatus.ANY);
      if (user == null) {
        log.debug("String_Node_Str",username);
      }
 else       if (user instanceof UserImpl && !((UserImpl)user).isEnabled()) {
        HttpServletRequest request=getCurrentHttpServletRequest();
        if (request != null) {
          request.setAttribute(DISABLED_USER_NAME,username);
        }
        throw new LoginException("String_Node_Str" + username + "String_Node_Str");
      }
    }
 else {
      log.debug("String_Node_Str");
    }
    return true;
  }
 catch (  final Exception e) {
    log.warn(e.getMessage());
    throw new LoginException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override public boolean login() throws LoginException {
  log.debug("String_Node_Str");
  try {
    Callback[] callbacks=new Callback[]{new NameCallback("String_Node_Str")};
    callbackHandler.handle(callbacks);
    String username=((NameCallback)callbacks[0]).getName();
    if (username != null) {
      OrganizationService service=(OrganizationService)getContainer().getComponentInstanceOfType(OrganizationService.class);
      try {
        begin(service);
        UserHandler uHandler=service.getUserHandler();
        User user=uHandler.findUserByName(username,UserStatus.ANY);
        if (user == null) {
          log.debug("String_Node_Str",username);
        }
 else         if (user instanceof UserImpl && !((UserImpl)user).isEnabled()) {
          HttpServletRequest request=getCurrentHttpServletRequest();
          if (request != null) {
            request.setAttribute(DISABLED_USER_NAME,username);
          }
          throw new LoginException("String_Node_Str" + username + "String_Node_Str");
        }
      }
  finally {
        end(service);
      }
    }
 else {
      log.debug("String_Node_Str");
    }
    return true;
  }
 catch (  final Exception e) {
    log.warn(e.getMessage());
    throw new LoginException(e.getMessage());
  }
}
Program: 9886
Project: 9886
Buggy source:
public void testAccessTokensWithMoreScopes() throws Exception {
  User user1=new UserImpl("String_Node_Str");
  orgService.getUserHandler().createUser(user1,false);
  GoogleAccessTokenContext googleToken=createGoogleAccessToken("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  socialNetworkService.updateOAuthAccessToken(getGoogleProvider(),user1.getUserName(),googleToken);
  assertEquals(googleToken,socialNetworkService.getOAuthAccessToken(getGoogleProvider(),user1.getUserName()));
  FacebookAccessTokenContext facebookToken=createFacebookAccessToken("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  socialNetworkService.updateOAuthAccessToken(getFacebookProvider(),user1.getUserName(),facebookToken);
  assertEquals(facebookToken,socialNetworkService.getOAuthAccessToken(getFacebookProvider(),user1.getUserName()));
}

Fixed version (ground truth):
public void testAccessTokensWithMoreScopes() throws Exception {
  User user1=new UserImpl("String_Node_Str");
  orgService.getUserHandler().createUser(user1,false);
  GoogleAccessTokenContext googleToken=createGoogleAccessToken("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  socialNetworkService.updateOAuthAccessToken(getGoogleProvider(),user1.getUserName(),googleToken);
  assertEquals(googleToken,socialNetworkService.getOAuthAccessToken(getGoogleProvider(),user1.getUserName()));
  FacebookAccessTokenContext facebookToken=createFacebookAccessToken("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  socialNetworkService.updateOAuthAccessToken(getFacebookProvider(),user1.getUserName(),facebookToken);
  assertEquals(facebookToken,socialNetworkService.getOAuthAccessToken(getFacebookProvider(),user1.getUserName()));
  orgService.getUserHandler().removeUser(user1.getUserName(),false);
}