Program: 38657
Project: 38657
Buggy source:
@Test public void testReadSubScopes() throws Exception {
  String parentScope="String_Node_Str";
  String jsonKey1="String_Node_Str";
  String jsonKey2="String_Node_Str";
  String jsonKey3="String_Node_Str";
  long parentScopeId=createSubScope(Optional.empty(),Optional.of(parentScope));
  int size=20;
  List<JsRecord> allJsRecords=Lists.newLinkedList();
  transactor.executeAsTransaction(db -> {
    for (long i=0L; i < size; ++i) {
      JsRecord record=jackStore2.scope(parentScopeId).createSubScope().scopeName(String.valueOf(i)).putLong(LONG_KEY,i).putString(STRING_KEY,String.valueOf(i)).putJson(JSON_KEY,JSON_PARSER.parse(String.format("String_Node_Str",jsonKey1,jsonKey2,i,jsonKey3)).getAsJsonObject()).execute(db);
      allJsRecords.add(record);
    }
  }
);
  Random random=new Random(System.currentTimeMillis());
  int lo=Math.max(1,random.nextInt(size / 2));
  int hi=Math.min(size,lo + size / 5 + random.nextInt(size));
  LOG.info("String_Node_Str",lo,hi);
  List<JsRecord> subRecords=allJsRecords.subList(lo,hi);
  List<Long> subScopeIds=subRecords.stream().map(JsRecord::getScopeId).collect(Collectors.toList());
  jsRecords=transactor.queryAsTransaction(db -> jackStore2.scope(parentScopeId).readSubScopes().whereSubScopeIds(subScopeIds).execute(db));
  assertEquals(subRecords.size(),jsRecords.size());
  for (int i=0; i < subRecords.size(); ++i) {
    int index=i + lo;
    JsRecord jsRecord=jsRecords.get(i);
    String intString=String.valueOf(index);
    assertEquals(index,jsRecord.getLong(LONG_KEY).intValue());
    assertEquals(intString,jsRecord.getString(STRING_KEY));
    JsonObject json=jsRecord.getJson(JSON_KEY);
    int jsonKey3Value=json.get(jsonKey1).getAsJsonObject().get(jsonKey2).getAsJsonPrimitive().getAsNumber().intValue();
    assertEquals(index,jsonKey3Value);
  }
}

Fixed version (ground truth):
@Test public void testReadSubScopes() throws Exception {
  String parentScope="String_Node_Str";
  String jsonKey1="String_Node_Str";
  String jsonKey2="String_Node_Str";
  String jsonKey3="String_Node_Str";
  long parentScopeId=createSubScope(Optional.empty(),Optional.of(parentScope));
  int size=20;
  List<JsRecord> allJsRecords=Lists.newLinkedList();
  transactor.executeAsTransaction(db -> {
    for (long i=0L; i < size; ++i) {
      JsRecord record=jackStore2.scope(parentScopeId).createSubScope().scopeName(String.valueOf(i)).putLong(LONG_KEY,i).putString(STRING_KEY,String.valueOf(i)).putJson(JSON_KEY,JSON_PARSER.parse(String.format("String_Node_Str",jsonKey1,jsonKey2,i,jsonKey3)).getAsJsonObject()).execute(db);
      allJsRecords.add(record);
    }
  }
);
  Random random=new Random(System.currentTimeMillis());
  int lo=Math.max(1,random.nextInt(size / 2));
  int hi=Math.min(size,lo + size / 5 + random.nextInt(size));
  LOG.info("String_Node_Str",lo,hi);
  List<JsRecord> subRecords=allJsRecords.subList(lo,hi);
  List<Long> subScopeIds=subRecords.stream().map(JsRecord::getScopeId).collect(Collectors.toList());
  jsRecords=transactor.queryAsTransaction(db -> jackStore2.scope(parentScopeId).readSubScopes().whereSubScopeIds(subScopeIds).execute(db));
  assertEquals(subRecords.size(),jsRecords.size());
  for (int i=0; i < subRecords.size(); ++i) {
    int index=i + lo;
    JsRecord jsRecord=jsRecords.get(i);
    long scopeId=subRecords.get(i).getScopeId();
    String intString=String.valueOf(index);
    assertEquals(scopeId,jsRecord.getScopeId().longValue());
    assertEquals(index,jsRecord.getLong(LONG_KEY).intValue());
    assertEquals(intString,jsRecord.getString(STRING_KEY));
    JsonObject json=jsRecord.getJson(JSON_KEY);
    int jsonKey3Value=json.get(jsonKey1).getAsJsonObject().get(jsonKey2).getAsJsonPrimitive().getAsNumber().intValue();
    assertEquals(index,jsonKey3Value);
  }
}