Program: 117469
Project: 117469
Buggy source:
public String loadStringResource(final String key,Locale locale,final String style,final String variation){
  final String language=locale != null ? locale.getLanguage() : null;
  return new DBClosure<String>(){
    @Override protected String execute(    ODatabaseRecord db){
      OSQLSynchQuery<ODocument> query=new OSQLSynchQuery<ODocument>("String_Node_Str" + OCLASS_LOCALIZATION + "String_Node_Str"+ OPROPERTY_KEY+ "String_Node_Str");
      List<ODocument> result=db.command(query).execute(key);
      if (result == null || result.isEmpty()) {
        registerStringResourceRequest(key,language,style,variation);
        return null;
      }
      ODocument bestCandidate=null;
      int bestCandidateScore=-1;
      boolean fullMatchPresent=false;
      for (      ODocument candidate : result) {
        int score=0;
        if (Strings.isEqual(language,(String)candidate.field(OPROPERTY_LANG)))         score|=1 << 3;
        if (Strings.isEqual(language,(String)candidate.field(OPROPERTY_STYLE)))         score|=1 << 2;
        if (Strings.isEqual(language,(String)candidate.field(OPROPERTY_VARIATION)))         score|=1;
        if (score == 7)         fullMatchPresent=true;
        Boolean active=candidate.field(OPROPERTY_ACTIVE);
        if (active == null || active)         score=-1;
        if (score > bestCandidateScore) {
          bestCandidate=candidate;
          bestCandidateScore=score;
        }
      }
      if (!fullMatchPresent) {
        registerStringResourceRequest(key,language,style,variation);
      }
      return bestCandidate != null ? (String)bestCandidate.field(OPROPERTY_VALUE) : null;
    }
  }
.execute();
}

Fixed version (ground truth):
public String loadStringResource(final String key,Locale locale,final String style,final String variation){
  final String language=locale != null ? locale.getLanguage() : null;
  return new DBClosure<String>(){
    @Override protected String execute(    ODatabaseRecord db){
      OSQLSynchQuery<ODocument> query=new OSQLSynchQuery<ODocument>("String_Node_Str" + OCLASS_LOCALIZATION + "String_Node_Str"+ OPROPERTY_KEY+ "String_Node_Str");
      List<ODocument> result=db.command(query).execute(key);
      if (result == null || result.isEmpty()) {
        registerStringResourceRequest(key,language,style,variation);
        return null;
      }
      ODocument bestCandidate=null;
      int bestCandidateScore=-1;
      boolean fullMatchPresent=false;
      for (      ODocument candidate : result) {
        int score=0;
        if (Strings.isEqual(language,(String)candidate.field(OPROPERTY_LANG)))         score|=1 << 2;
        if (Strings.isEqual(style,(String)candidate.field(OPROPERTY_STYLE)))         score|=1 << 1;
        if (Strings.isEqual(variation,(String)candidate.field(OPROPERTY_VARIATION)))         score|=1;
        if (score == 7)         fullMatchPresent=true;
        Boolean active=candidate.field(OPROPERTY_ACTIVE);
        if (active == null || active)         score=-1;
        if (score > bestCandidateScore) {
          bestCandidate=candidate;
          bestCandidateScore=score;
        }
      }
      if (!fullMatchPresent) {
        registerStringResourceRequest(key,language,style,variation);
      }
      return bestCandidate != null ? (String)bestCandidate.field(OPROPERTY_VALUE) : null;
    }
  }
.execute();
}