nus-yam/ex-repair huggingface dataset:
Program: 80429
Project: 80429
Buggy source:
public static Jid from(String jidString) throws XmppStringprepException {
  String localpart=XmppStringUtils.parseBareAddress(jidString);
  String domainpart=XmppStringUtils.parseDomain(jidString);
  String resource=XmppStringUtils.parseResource(jidString);
  return from(localpart,domainpart,resource);
}

Fixed version (ground truth):
public static Jid from(String jidString) throws XmppStringprepException {
  String localpart=XmppStringUtils.parseLocalpart(jidString);
  String domainpart=XmppStringUtils.parseDomain(jidString);
  String resource=XmppStringUtils.parseResource(jidString);
  return from(localpart,domainpart,resource);
}
Program: 80430
Project: 80430
Buggy source:
public static Jid fromUnescaped(String escapedJidString) throws XmppStringprepException {
  String localpart=XmppStringUtils.parseBareAddress(escapedJidString);
  localpart=XmppStringUtils.escapeLocalpart(localpart);
  String domainpart=XmppStringUtils.parseDomain(escapedJidString);
  String resource=XmppStringUtils.parseResource(escapedJidString);
  return from(localpart,domainpart,resource);
}

Fixed version (ground truth):
public static Jid fromUnescaped(String escapedJidString) throws XmppStringprepException {
  String localpart=XmppStringUtils.parseLocalpart(escapedJidString);
  localpart=XmppStringUtils.escapeLocalpart(localpart);
  String domainpart=XmppStringUtils.parseDomain(escapedJidString);
  String resource=XmppStringUtils.parseResource(escapedJidString);
  return from(localpart,domainpart,resource);
}
Program: 80431
Project: 80431
Buggy source:
@Override public String asUnescapedString(){
  if (unescapedCache != null) {
    return unescapedCache;
  }
  unescapedCache=super.asUnescapedString() + '@' + super.toString();
  return unescapedCache;
}

Fixed version (ground truth):
@Override public String asUnescapedString(){
  if (unescapedCache != null) {
    return unescapedCache;
  }
  unescapedCache=super.asUnescapedString() + '/' + resource;
  return unescapedCache;
}
Program: 80432
Project: 80432
Buggy source:
/** 
 * @功能 : 根据name获取properties文件中的value, 如果为空返回默认值
 * @作者 : yangc
 * @创建日期 : 2013-11-21 下午07:01:48
 * @param filePath properties文件路径(classpath中的相对路径)
 * @param name
 * @param defaultValue
 * @return
 */
public static String getProperty(String filePath,String name,String defaultValue){
  if (StringUtils.isBlank(filePath) || StringUtils.isBlank(name) || StringUtils.isBlank(defaultValue)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    Properties prop=PROPS.get(filePath);
    if (prop == null) {
      prop=new Properties();
      prop.load(PropertiesUtils.class.getResourceAsStream(filePath));
      PROPS.put(filePath,prop);
    }
    String value=prop.getProperty(name);
    return StringUtils.isBlank(value) ? defaultValue : value;
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  return defaultValue;
}

Fixed version (ground truth):
/** 
 * @功能 : 根据name获取properties文件中的value, 如果为空返回默认值
 * @作者 : yangc
 * @创建日期 : 2013-11-21 下午07:01:48
 * @param filePath properties文件路径(classpath中的相对路径)
 * @param name
 * @param defaultValue
 * @return
 */
public static String getProperty(String filePath,String name,String defaultValue){
  if (StringUtils.isBlank(filePath) || StringUtils.isBlank(name)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Properties prop=new Properties();
  InputStream in=null;
  try {
    in=PropertiesUtils.class.getResourceAsStream(filePath);
    prop.load(in);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    try {
      if (in != null)       in.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  return prop.getProperty(name,defaultValue);
}
Program: 80433
Project: 80433
Buggy source:
public static void main(String[] args){
  System.out.println(PropertiesUtils.getProperty("String_Node_Str","String_Node_Str"));
  PropertiesUtils.setProperty("String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public static void main(String[] args){
  System.out.println(PropertiesUtils.getProperty("String_Node_Str","String_Node_Str"));
}
Program: 80434
Project: 80434
Buggy source:
protected void applySizeConstraintsForRead(ResourceEntity<?> entity,SizeConstraints constraints){
  int upperOffset=constraints.getFetchOffset();
  if (upperOffset > 0 && entity.getFetchOffset() > upperOffset) {
    LOGGER.info("String_Node_Str" + entity.getFetchOffset() + "String_Node_Str"+ upperOffset);
    entity.setFetchOffset(upperOffset);
  }
  int upperLimit=constraints.getFetchLimit();
  if (upperLimit > 0 && entity.getFetchLimit() > upperLimit) {
    LOGGER.info("String_Node_Str" + entity.getFetchLimit() + "String_Node_Str"+ upperLimit);
    entity.setFetchLimit(upperLimit);
  }
}

Fixed version (ground truth):
protected void applySizeConstraintsForRead(ResourceEntity<?> entity,SizeConstraints constraints){
  int upperOffset=constraints.getFetchOffset();
  if (upperOffset > 0 && entity.getFetchOffset() > upperOffset) {
    LOGGER.info("String_Node_Str" + entity.getFetchOffset() + "String_Node_Str"+ upperOffset);
    entity.setFetchOffset(upperOffset);
  }
  int upperLimit=constraints.getFetchLimit();
  if (upperLimit > 0 && (entity.getFetchLimit() <= 0 || entity.getFetchLimit() > upperLimit)) {
    LOGGER.info("String_Node_Str" + entity.getFetchLimit() + "String_Node_Str"+ upperLimit);
    entity.setFetchLimit(upperLimit);
  }
}
Program: 80435
Project: 80435
Buggy source:
@Test public void testApply_FetchLimit(){
  SizeConstraints s1=new SizeConstraints().fetchLimit(5);
  SizeConstraints s2=new SizeConstraints().fetchLimit(0);
  ResourceEntity<E1> t1=new ResourceEntity<>(lre0);
  t1.setFetchLimit(0);
  constraintHandler.constrainResponse(t1,s1,null);
  assertEquals(0,t1.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t2=new ResourceEntity<>(lre0);
  t2.setFetchLimit(3);
  constraintHandler.constrainResponse(t2,s1,null);
  assertEquals(3,t2.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t3=new ResourceEntity<>(lre0);
  t3.setFetchLimit(6);
  constraintHandler.constrainResponse(t3,s1,null);
  assertEquals(5,t3.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t4=new ResourceEntity<>(lre0);
  t4.setFetchLimit(6);
  constraintHandler.constrainResponse(t4,s2,null);
  assertEquals(6,t4.getFetchLimit());
  assertEquals(0,s2.getFetchLimit());
}

Fixed version (ground truth):
@Test public void testApply_FetchLimit(){
  SizeConstraints s1=new SizeConstraints().fetchLimit(5);
  SizeConstraints s2=new SizeConstraints().fetchLimit(0);
  ResourceEntity<E1> t1=new ResourceEntity<>(lre0);
  constraintHandler.constrainResponse(t1,s1,null);
  assertEquals(5,t1.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t1_1=new ResourceEntity<>(lre0);
  t1_1.setFetchLimit(0);
  constraintHandler.constrainResponse(t1_1,s1,null);
  assertEquals(5,t1_1.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t1_2=new ResourceEntity<>(lre0);
  t1_2.setFetchLimit(-1);
  constraintHandler.constrainResponse(t1_2,s1,null);
  assertEquals(5,t1_2.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t2=new ResourceEntity<>(lre0);
  t2.setFetchLimit(3);
  constraintHandler.constrainResponse(t2,s1,null);
  assertEquals(3,t2.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t3=new ResourceEntity<>(lre0);
  t3.setFetchLimit(6);
  constraintHandler.constrainResponse(t3,s1,null);
  assertEquals(5,t3.getFetchLimit());
  assertEquals(5,s1.getFetchLimit());
  ResourceEntity<E1> t4=new ResourceEntity<>(lre0);
  t4.setFetchLimit(6);
  constraintHandler.constrainResponse(t4,s2,null);
  assertEquals(6,t4.getFetchLimit());
  assertEquals(0,s2.getFetchLimit());
}
Program: 80436
Project: 80436
Buggy source:
@Before public void before(){
  this.context=runtime.newContext();
  QueryChain chain=new QueryChain();
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  context.performGenericQuery(chain);
}

Fixed version (ground truth):
@Before public void before(){
  this.context=runtime.newContext();
  context.performQuery(new RefreshQuery());
  QueryChain chain=new QueryChain();
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  chain.addQuery(new EJBQLQuery("String_Node_Str"));
  context.performGenericQuery(chain);
}
Program: 80437
Project: 80437
Buggy source:
static boolean isMetadataGetter(Method getter){
  return getter.getParameterCount() == 0 && hasAnnotation(getter,Meta.class);
}

Fixed version (ground truth):
static boolean isMetadataGetter(Method method){
  return isAnyGetter(method) && hasAnnotation(method,Meta.class);
}
Program: 80438
Project: 80438
Buggy source:
static <D extends DynamicObject<D>>Set<Object> cachedKeys(Class<D> type){
  return Arrays.stream(type.getMethods()).filter(method -> method.getAnnotation(Cached.class) != null).map(method -> method.getAnnotation(Key.class)).filter(key -> key != null).map(Key::value).map(Reflection::stringToKey).collect(toSet());
}

Fixed version (ground truth):
static <D extends DynamicObject<D>>Set<Object> cachedKeys(Class<D> type){
  return Arrays.stream(type.getMethods()).flatMap(Reflection::getCachedKeysForMethod).collect(toSet());
}
Program: 80439
Project: 80439
Buggy source:
private static Method getCorrespondingGetter(Method builderMethod){
  try {
    Class<?> type=builderMethod.getDeclaringClass();
    Method correspondingGetter=type.getMethod(builderMethod.getName());
    return correspondingGetter;
  }
 catch (  NoSuchMethodException ex) {
    throw new IllegalStateException("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
private static Method getCorrespondingGetter(Method builderMethod){
  try {
    Class<?> type=builderMethod.getDeclaringClass();
    Method correspondingGetter=type.getMethod(builderMethod.getName());
    return correspondingGetter;
  }
 catch (  NoSuchMethodException ex) {
    throw new IllegalStateException("String_Node_Str" + builderMethod + "String_Node_Str",ex);
  }
}
Program: 80440
Project: 80440
Buggy source:
static <D extends DynamicObject<D>>Collection<Method> fieldGetters(Class<D> type){
  Collection<Method> ret=new LinkedHashSet<>();
  for (  Method method : type.getDeclaredMethods())   if (method.getParameterCount() == 0 && !method.isDefault() && !method.isSynthetic() && !isMetadataGetter(method))   ret.add(method);
  return ret;
}

Fixed version (ground truth):
static <D extends DynamicObject<D>>Collection<Method> fieldGetters(Class<D> type){
  Collection<Method> ret=new LinkedHashSet<>();
  for (  Method method : type.getDeclaredMethods())   if (isGetter(method))   ret.add(method);
  return ret;
}
Program: 80441
Project: 80441
Buggy source:
private static <D extends DynamicObject<D>>D createIndyProxy(Map map,Class<D> type){
  try {
    Object proxy=proxyCache.computeIfAbsent(type,Instances::createProxy).constructor().invoke(map,type);
    return type.cast(proxy);
  }
 catch (  Throwable t) {
    throw new RuntimeException(t);
  }
}

Fixed version (ground truth):
private static <D extends DynamicObject<D>>D createIndyProxy(Map map,Class<D> type){
  ensureInitialized(type);
  try {
    Object proxy=proxyCache.computeIfAbsent(type,Instances::createProxy).constructor().invoke(map,type);
    return type.cast(proxy);
  }
 catch (  Throwable t) {
    throw new RuntimeException(t);
  }
}
Program: 80442
Project: 80442
Buggy source:
public void prettyPrint(){
  ClojureStuff.Pprint.invoke(map);
}

Fixed version (ground truth):
public void prettyPrint(){
  ClojureStuff.Pprint.invoke(this);
}
Program: 80443
Project: 80443
Buggy source:
public String toFormattedString(){
  Writer w=new StringWriter();
  ClojureStuff.Pprint.invoke(map,w);
  return w.toString();
}

Fixed version (ground truth):
public String toFormattedString(){
  Writer w=new StringWriter();
  ClojureStuff.Pprint.invoke(this,w);
  return w.toString();
}
Program: 80444
Project: 80444
Buggy source:
static synchronized <T extends DynamicObject<T>>void deregisterTag(Class<T> type){
  String tag=EdnSerialization.recordTagCache.get(type);
  fressianWriteHandlers.remove(type);
  fressianReadHandlers.remove(tag);
}

Fixed version (ground truth):
static synchronized <T extends DynamicObject<T>>void deregisterTag(Class<T> type){
  String tag=binaryTagCache.get(type);
  fressianWriteHandlers.remove(type);
  fressianReadHandlers.remove(tag);
}
Program: 80445
Project: 80445
Buggy source:
static synchronized <T extends DynamicObject<T>>void registerTag(Class<T> type,String tag){
  Handlers.installHandler(fressianWriteHandlers,type,tag,DynamicObject.getFressianWriteHandler(tag,type));
  fressianReadHandlers.putIfAbsent(tag,DynamicObject.getFressianReadHandler(tag,type));
}

Fixed version (ground truth):
static synchronized <T extends DynamicObject<T>>void registerTag(Class<T> type,String tag){
  binaryTagCache.put(type,tag);
  Handlers.installHandler(fressianWriteHandlers,type,tag,DynamicObject.getFressianWriteHandler(tag,type));
  fressianReadHandlers.putIfAbsent(tag,DynamicObject.getFressianReadHandler(tag,type));
}
Program: 80446
Project: 80446
Buggy source:
static synchronized <T extends DynamicObject<T>>void deregisterTag(Class<T> type){
  FressianSerialization.deregisterTag(type);
  EdnSerialization.deregisterTag(type);
}

Fixed version (ground truth):
static synchronized <T extends DynamicObject<T>>void deregisterTag(Class<T> type){
  EdnSerialization.deregisterTag(type);
  FressianSerialization.deregisterTag(type);
}
Program: 80447
Project: 80447
Buggy source:
private static Object convertCollectionToJavaTypes(Collection<?> coll,Object empty,Type genericReturnType){
  Object ret=Transient.invoke(empty);
  coll.forEach(o -> ConjBang.invoke(ret,convertCollectionElementToJavaTypes(o,genericReturnType)));
  return Persistent.invoke(ret);
}

Fixed version (ground truth):
private static Object convertCollectionToJavaTypes(Collection<?> coll,Object empty,Type genericReturnType){
  Object ret=Transient.invoke(empty);
  for (  Object o : coll)   ret=ConjBang.invoke(ret,convertCollectionElementToJavaTypes(o,genericReturnType));
  return Persistent.invoke(ret);
}
Program: 80448
Project: 80448
Buggy source:
private static Object convertMapToClojureTypes(Map<?,?> map){
  Object ret=Transient.invoke(EmptyMap);
  map.forEach((k,v) -> AssocBang.invoke(ret,javaToClojure(k),javaToClojure(v)));
  return Persistent.invoke(ret);
}

Fixed version (ground truth):
private static Object convertMapToClojureTypes(Map<?,?> map){
  Object ret=Transient.invoke(EmptyMap);
  for (  Map.Entry<?,?> entry : map.entrySet())   ret=AssocBang.invoke(ret,javaToClojure(entry.getKey()),javaToClojure(entry.getValue()));
  return Persistent.invoke(ret);
}
Program: 80449
Project: 80449
Buggy source:
private static Object convertCollectionToClojureTypes(Collection<?> val,Object empty){
  Object ret=Transient.invoke(empty);
  val.forEach(o -> ConjBang.invoke(ret,javaToClojure(o)));
  return Persistent.invoke(ret);
}

Fixed version (ground truth):
private static Object convertCollectionToClojureTypes(Collection<?> val,Object empty){
  Object ret=Transient.invoke(empty);
  for (  Object o : val)   ret=ConjBang.invoke(ret,javaToClojure(o));
  return Persistent.invoke(ret);
}
Program: 80450
Project: 80450
Buggy source:
Map<String,String> dictionary();

Fixed version (ground truth):
MapSchema dictionary(Map<String,String> dictionary);
Program: 80451
Project: 80451
Buggy source:
@Test public void listStream(){
  ListSchema listSchema=deserialize("String_Node_Str",ListSchema.class);
  List<String> stringList=listSchema.strings();
  List<Integer> collect=stringList.stream().map(x -> x.length()).collect(Collectors.toList());
  assertEquals(3,collect.get(0).intValue());
  assertEquals(3,collect.get(1).intValue());
  assertEquals(5,collect.get(2).intValue());
}

Fixed version (ground truth):
@Test public void listStream(){
  ListSchema listSchema=deserialize("String_Node_Str",ListSchema.class);
  List<String> stringList=listSchema.strings();
  List<Integer> collect=stringList.stream().map(x -> x.length()).collect(toList());
  assertEquals(3,collect.get(0).intValue());
  assertEquals(3,collect.get(1).intValue());
  assertEquals(5,collect.get(2).intValue());
}
Program: 80452
Project: 80452
Buggy source:
static Object unwrapCollectionElements(Object val,Class<?> type,Object empty){
  if (val != null && type.isAssignableFrom(val.getClass())) {
    Iterable<?> iterable=(Iterable<?>)val;
    Object ret=empty;
    ret=TRANSIENT.invoke(ret);
    for (    Object o : iterable)     CONJ_BANG.invoke(ret,unwrapAndAnnotate(o));
    return PERSISTENT.invoke(ret);
  }
  return val;
}

Fixed version (ground truth):
static Object unwrapCollectionElements(Object val,Class<?> type,Object empty){
  if (val != null && type.isAssignableFrom(val.getClass())) {
    Iterable<?> iterable=(Iterable<?>)val;
    Object ret=empty;
    ret=TRANSIENT.invoke(ret);
    for (    Object o : iterable) {
      o=Primitives.maybeUpconvert(o);
      o=unwrapAndAnnotate(o);
      CONJ_BANG.invoke(ret,o);
    }
    return PERSISTENT.invoke(ret);
  }
  return val;
}
Program: 80453
Project: 80453
Buggy source:
@Test public void listOfStrings(){
  ListSchema listSchema=DynamicObject.deserialize("String_Node_Str",ListSchema.class);
  List<String> stringList=listSchema.strings();
  assertEquals("String_Node_Str",stringList.get(0));
  assertEquals("String_Node_Str",stringList.get(1));
  assertEquals("String_Node_Str",stringList.get(2));
}

Fixed version (ground truth):
@Test public void listOfStrings(){
  ListSchema listSchema=deserialize("String_Node_Str",ListSchema.class);
  List<String> stringList=listSchema.strings();
  assertEquals("String_Node_Str",stringList.get(0));
  assertEquals("String_Node_Str",stringList.get(1));
  assertEquals("String_Node_Str",stringList.get(2));
}
Program: 80454
Project: 80454
Buggy source:
@Test public void embeddedMap(){
  String edn="String_Node_Str";
  MapSchema mapSchema=DynamicObject.deserialize(edn,MapSchema.class);
  assertEquals("String_Node_Str",mapSchema.dictionary().get("String_Node_Str"));
  assertEquals(1,mapSchema.dictionary().size());
}

Fixed version (ground truth):
@Test public void embeddedMap(){
  String edn="String_Node_Str";
  MapSchema mapSchema=deserialize(edn,MapSchema.class);
  assertEquals("String_Node_Str",mapSchema.dictionary().get("String_Node_Str"));
  assertEquals(1,mapSchema.dictionary().size());
}
Program: 80455
Project: 80455
Buggy source:
@Test public void setOfStrings(){
  SetSchema setSchema=DynamicObject.deserialize("String_Node_Str",SetSchema.class);
  Set<String> stringSet=setSchema.strings();
  assertEquals(3,stringSet.size());
  assertTrue(stringSet.contains("String_Node_Str"));
  assertTrue(stringSet.contains("String_Node_Str"));
  assertTrue(stringSet.contains("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void setOfStrings(){
  SetSchema setSchema=deserialize("String_Node_Str",SetSchema.class);
  Set<String> stringSet=setSchema.strings();
  assertEquals(3,stringSet.size());
  assertTrue(stringSet.contains("String_Node_Str"));
  assertTrue(stringSet.contains("String_Node_Str"));
  assertTrue(stringSet.contains("String_Node_Str"));
}
Program: 80456
Project: 80456
Buggy source:
@Test public void listStream(){
  ListSchema listSchema=DynamicObject.deserialize("String_Node_Str",ListSchema.class);
  List<String> stringList=listSchema.strings();
  List<Integer> collect=stringList.stream().map(x -> x.length()).collect(Collectors.toList());
  assertEquals(3,collect.get(0).intValue());
  assertEquals(3,collect.get(1).intValue());
  assertEquals(5,collect.get(2).intValue());
}

Fixed version (ground truth):
@Test public void listStream(){
  ListSchema listSchema=deserialize("String_Node_Str",ListSchema.class);
  List<String> stringList=listSchema.strings();
  List<Integer> collect=stringList.stream().map(x -> x.length()).collect(Collectors.toList());
  assertEquals(3,collect.get(0).intValue());
  assertEquals(3,collect.get(1).intValue());
  assertEquals(5,collect.get(2).intValue());
}
Program: 80457
Project: 80457
Buggy source:
private T assoc(String key,Object value){
  Keyword keyword=Keyword.intern(key);
  IPersistentMap newMap=map.assoc(keyword,value);
  return DynamicObject.wrap(newMap,clazz);
}

Fixed version (ground truth):
private T assoc(String key,Object value){
  Keyword keyword=Keyword.intern(key);
  if (value instanceof DynamicObject)   value=((DynamicObject)value).getMap();
  IPersistentMap newMap=map.assoc(keyword,value);
  return DynamicObject.wrap(newMap,clazz);
}
Program: 80458
Project: 80458
Buggy source:
private T assocEx(String key,Object value){
  Keyword keyword=Keyword.intern(key);
  IPersistentMap newMap=map.assocEx(keyword,value);
  return DynamicObject.wrap(newMap,clazz);
}

Fixed version (ground truth):
private T assocEx(String key,Object value){
  Keyword keyword=Keyword.intern(key);
  if (value instanceof DynamicObject)   value=((DynamicObject)value).getMap();
  IPersistentMap newMap=map.assocEx(keyword,value);
  return DynamicObject.wrap(newMap,clazz);
}
Program: 80459
Project: 80459
Buggy source:
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  String methodName=method.getName();
  if (method.getReturnType().equals(clazz))   return assoc(methodName,args[0]);
switch (methodName) {
case "String_Node_Str":
    return map;
case "String_Node_Str":
  return clazz;
case "String_Node_Str":
return assoc((String)args[0],args[1]);
case "String_Node_Str":
return assocEx((String)args[0],args[1]);
case "String_Node_Str":
return without((String)args[0]);
case "String_Node_Str":
return map.toString();
case "String_Node_Str":
return map.hashCode();
case "String_Node_Str":
Object other=args[0];
if (other instanceof DynamicObject) {
return map.equals(((DynamicObject)other).getMap());
}
 else return method.invoke(map,args);
default :
return getValueFor(method);
}
}

Fixed version (ground truth):
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  String methodName=method.getName();
  if (method.getReturnType().equals(clazz))   return assoc(methodName,args[0]);
switch (methodName) {
case "String_Node_Str":
    return map;
case "String_Node_Str":
  return clazz;
case "String_Node_Str":
return assoc((String)args[0],args[1]);
case "String_Node_Str":
return assocEx((String)args[0],args[1]);
case "String_Node_Str":
return without((String)args[0]);
case "String_Node_Str":
return map.toString();
case "String_Node_Str":
return map.hashCode();
case "String_Node_Str":
Object other=args[0];
if (other instanceof DynamicObject) return map.equals(((DynamicObject)other).getMap());
 else return method.invoke(map,args);
default :
return getValueFor(method);
}
}
Program: 80460
Project: 80460
Buggy source:
private JsonValue getRestValue(JsonArray restArray,int colIdx){
  JsonValue obj=restArray.get(colIdx);
  if (obj.getValueType() == ValueType.ARRAY && ((JsonArray)obj).size() > 0)   obj=((JsonArray)obj).get(0);
  return obj;
}

Fixed version (ground truth):
private JsonValue getRestValue(JsonArray restArray,int colIdx){
  return restArray.get(colIdx);
}
Program: 80461
Project: 80461
Buggy source:
private List<GrRelation> getRelations(String colKey){
  List<GrRelation> rRelations=getRelationColumns().get(colKey);
  if (rRelations == null) {
    rRelations=new ArrayList<GrRelation>();
    int colIdx=getColumnIndex(colKey);
    if (colIdx == -1)     throw new RuntimeException("String_Node_Str" + colKey);
    Iterator<JsonValue> it=getDataIterator();
    int rowIdx=-1;
    while (it.hasNext()) {
      rowIdx++;
      JsonObject dataObject=(JsonObject)it.next();
      GrRelation rRelation=null;
      ElementInfo ei=getElementInfo(dataObject,colIdx);
      if (!ei.isNull) {
        RelationInfo ri=getRelationInfo(dataObject,colIdx);
        rRelation=getRelationsById().get(ei.id);
        if (rRelation == null) {
          rRelation=GrAccess.createRelation(this,new GrId(ei.id),new GrId(ri.startNodeId),new GrId(ri.endNodeId),rowIdx);
          GrAccess.setState(rRelation,SyncState.SYNC);
          GrAccess.addChangeListener(getNodeRelationListener(),rRelation);
          getRelationsById().put(ei.id,rRelation);
        }
      }
      if (!rRelations.contains(rRelation))       rRelations.add(rRelation);
    }
    getRelationColumns().put(colKey,rRelations);
    getUnresolvedColumns().remove(colKey);
  }
  return rRelations;
}

Fixed version (ground truth):
private List<GrRelation> getRelations(String colKey){
  List<GrRelation> rRelations=getRelationColumns().get(colKey);
  if (rRelations == null) {
    rRelations=new ArrayList<GrRelation>();
    int colIdx=getColumnIndex(colKey);
    if (colIdx == -1)     throw new RuntimeException("String_Node_Str" + colKey);
    Iterator<JsonValue> it=getDataIterator();
    int rowIdx=-1;
    while (it.hasNext()) {
      rowIdx++;
      JsonObject dataObject=(JsonObject)it.next();
      GrRelation rRelation=null;
      ElementInfo ei=getElementInfo(dataObject,colIdx);
      if (!ei.isNull) {
        RelationInfo ri=getRelationInfo(dataObject,colIdx);
        rRelation=getRelationsById().get(ei.id);
        if (rRelation == null) {
          rRelation=GrAccess.createRelation(this,new GrId(ei.id),new GrId(ri.startNodeId),new GrId(ri.endNodeId),rowIdx);
          GrAccess.setState(rRelation,SyncState.SYNC);
          GrAccess.addChangeListener(getNodeRelationListener(),rRelation);
          getRelationsById().put(ei.id,rRelation);
        }
      }
      rRelations.add(rRelation);
    }
    getRelationColumns().put(colKey,rRelations);
    getUnresolvedColumns().remove(colKey);
  }
  return rRelations;
}
Program: 80462
Project: 80462
Buggy source:
private void addType(List<Class<?>> typeList,boolean noAbstractTypes){
  if (!noAbstractTypes || (!this.type.isInterface() && !Modifier.isAbstract(this.type.getModifiers()) && !this.type.equals(Object.class)))   typeList.add(this.type);
  if (this.next != null)   next.addType(typeList,noAbstractTypes);
}

Fixed version (ground truth):
private void addType(List<Class<?>> typeList,boolean noAbstractTypes){
  if (!noAbstractTypes || isConcrete(this.type))   typeList.add(this.type);
  if (this.next != null)   next.addType(typeList,noAbstractTypes);
}
Program: 80464
Project: 80464
Buggy source:
@Test public void testGregSample(){
  List<JcError> errs;
  IDomainAccess da=DomainAccessFactory.createDomainAccess(dbAccess,domainName);
  initDomain(da);
  conditionallyCreateEnv_App(da);
  DomainQuery q=da.createQuery();
  DomainObjectMatch<Env> envMatch=q.createMatch(Env.class);
  DomainObjectMatch<App> appMatch=q.createMatch(App.class);
  q.WHERE(envMatch.atttribute("String_Node_Str")).EQUALS("String_Node_Str");
  q.WHERE(appMatch.atttribute("String_Node_Str")).EQUALS("String_Node_Str");
  DomainObjectMatch<BIStats> statsMatch=q.createMatch(BIStats.class);
  DomainObjectMatch<Env> statEnv=q.TRAVERSE_FROM(statsMatch).FORTH("String_Node_Str").TO(Env.class);
  DomainObjectMatch<App> statApp=q.TRAVERSE_FROM(statsMatch).FORTH("String_Node_Str").TO(App.class);
  DomainObjectMatch<BIStats> n2bChainedMatch=q.SELECT_FROM(statsMatch).ELEMENTS(q.WHERE(statEnv).CONTAINS(envMatch),q.WHERE(statApp).CONTAINS(appMatch));
  DomainQueryResult result=q.execute();
  List<BIStats> n2bChained=result.resultOf(n2bChainedMatch);
  Env env=result.resultOf(envMatch).get(0);
  App app=result.resultOf(appMatch).get(0);
  BIStats newStat=new BIStats();
  newStat.setMeasuredIn(env);
  newStat.setMeasuredFor(app);
  if (n2bChained.size() > 0) {
    BIStats n2bC=n2bChained.get(0);
    n2bC.setMeasuredFor(null);
    n2bC.setMeasuredIn(null);
    newStat.setFollows(n2bC);
  }
  errs=da.store(newStat);
  assertTrue(errs.isEmpty());
  return;
}

Fixed version (ground truth):
public void testGregSample(int count){
  List<JcError> errs;
  IDomainAccess da=DomainAccessFactory.createDomainAccess(dbAccess,domainName);
  conditionallyCreateEnv_App(da);
  DomainQuery q=da.createQuery();
  DomainObjectMatch<Env> envMatch=q.createMatch(Env.class);
  DomainObjectMatch<App> appMatch=q.createMatch(App.class);
  q.WHERE(envMatch.atttribute("String_Node_Str")).EQUALS("String_Node_Str");
  q.WHERE(appMatch.atttribute("String_Node_Str")).EQUALS("String_Node_Str");
  DomainObjectMatch<BIStats> statsMatch=q.createMatch(BIStats.class);
  DomainObjectMatch<Env> statEnv=q.TRAVERSE_FROM(statsMatch).FORTH("String_Node_Str").TO(Env.class);
  DomainObjectMatch<App> statApp=q.TRAVERSE_FROM(statsMatch).FORTH("String_Node_Str").TO(App.class);
  DomainObjectMatch<BIStats> n2bChainedMatch=q.SELECT_FROM(statsMatch).ELEMENTS(q.WHERE(statEnv).CONTAINS(envMatch),q.WHERE(statApp).CONTAINS(appMatch));
  DomainQueryResult result=q.execute();
  List<BIStats> n2bChained=result.resultOf(n2bChainedMatch);
  Env env=result.resultOf(envMatch).get(0);
  App app=result.resultOf(appMatch).get(0);
  BIStats newStat=new BIStats();
  newStat.setMeasuredIn(env);
  newStat.setMeasuredFor(app);
  if (n2bChained.size() > 0) {
    BIStats n2bC=n2bChained.get(0);
    n2bC.setMeasuredFor(null);
    n2bC.setMeasuredIn(null);
    newStat.setFollows(n2bC);
  }
  errs=da.store(newStat);
  assertTrue(errs.isEmpty());
  if (count > 0)   testGregSample(count - 1);
  return;
}
Program: 80466
Project: 80466
Buggy source:
@BeforeClass public static void before(){
  domainName="String_Node_Str";
  Properties props=new Properties();
  props.setProperty(DBProperties.SERVER_ROOT_URI,"String_Node_Str");
  props.setProperty(DBProperties.DATABASE_DIR,"String_Node_Str");
  dbAccess=DBAccessFactory.createDBAccess(DBType.REMOTE,props);
  Population population=new Population();
  storedDomainObjects=population.createPopulation();
  QueriesPrintObserver.addOutputStream(System.out);
  QueriesPrintObserver.addToEnabledQueries(QueryToObserve.DOMAIN_INFO,ContentToObserve.CYPHER);
  QueriesPrintObserver.addToEnabledQueries(QueryToObserve.DOM_QUERY,ContentToObserve.CYPHER);
  QueriesPrintObserver.addToEnabledQueries(QueryToObserve.CLOSURE_QUERY,ContentToObserve.CYPHER);
  initDB(Locking.OPTIMISTIC);
}

Fixed version (ground truth):
@BeforeClass public static void before(){
  domainName="String_Node_Str";
  Properties props=new Properties();
  props.setProperty(DBProperties.SERVER_ROOT_URI,"String_Node_Str");
  props.setProperty(DBProperties.DATABASE_DIR,"String_Node_Str");
  dbAccess=DBAccessFactory.createDBAccess(DBType.IN_MEMORY,props);
  Population population=new Population();
  storedDomainObjects=population.createPopulation();
  QueriesPrintObserver.addOutputStream(System.out);
  QueriesPrintObserver.addToEnabledQueries(QueryToObserve.DOMAIN_INFO,ContentToObserve.CYPHER);
  QueriesPrintObserver.addToEnabledQueries(QueryToObserve.DOM_QUERY,ContentToObserve.CYPHER);
  QueriesPrintObserver.addToEnabledQueries(QueryToObserve.CLOSURE_QUERY,ContentToObserve.CYPHER);
  initDB(Locking.OPTIMISTIC);
}
Program: 80468
Project: 80468
Buggy source:
private List<IClause> createDomainInfoStartClause(JcNode info){
  List<IClause> ret=new ArrayList<IClause>();
  ret.add(MERGE.node(info).label(DomainInfoNodeLabel).property(DomainInfoNameProperty).value(DomainAccessHandler.this.domainName));
  ret.add(ON_CREATE.SET(info.property(DomainInfoVersionProperty)).to(0));
  ret.add(ON_CREATE.SET(info.property(DomainInfoModelVersionProperty)).to(0));
  return ret;
}

Fixed version (ground truth):
private List<IClause> createDomainInfoStartClause(JcNode info){
  String pLab=CurrentDomain.label.get();
  CurrentDomain.setDomainLabel(null);
  List<IClause> ret=new ArrayList<IClause>();
  try {
    ret.add(MERGE.node(info).label(DomainInfoNodeLabel).property(DomainInfoNameProperty).value(DomainAccessHandler.this.domainName));
    ret.add(ON_CREATE.SET(info.property(DomainInfoVersionProperty)).to(0));
    ret.add(ON_CREATE.SET(info.property(DomainInfoModelVersionProperty)).to(0));
  }
  finally {
    CurrentDomain.setDomainLabel(pLab);
  }
  return ret;
}
Program: 80469
Project: 80469
Buggy source:
List<JcError> store(List<Object> domainObjects){
  UpdateContext context;
  InternalDomainAccess internalAccess=null;
  try {
    internalAccess=MappingUtil.internalDomainAccess.get();
    MappingUtil.internalDomainAccess.set(getInternalDomainAccess());
    context=this.updateLocalGraph(domainObjects);
  }
  finally {
    if (internalAccess != null)     MappingUtil.internalDomainAccess.set(internalAccess);
 else     MappingUtil.internalDomainAccess.remove();
  }
  List<JcError> errors=context.graph.store();
  DomainState ds=getDomainState();
  if (errors.isEmpty()) {
    for (    IRelation relat : context.relationsToRemove) {
      ds.removeRelation(relat);
    }
    Iterator<Entry<Object,GrNode>> it=context.domObj2Node.entrySet().iterator();
    while (it.hasNext()) {
      Entry<Object,GrNode> entry=it.next();
      ds.add_Id2Object(entry.getKey(),entry.getValue().getId(),ResolutionDepth.DEEP);
    }
    for (    DomRelation2ResultRelation d2r : context.domRelation2Relations) {
      ds.add_Id2Relation(d2r.domRelation,d2r.resultRelation.getId());
    }
  }
  return errors;
}

Fixed version (ground truth):
List<JcError> store(List<?> domainObjects){
  UpdateContext context;
  InternalDomainAccess internalAccess=null;
  try {
    internalAccess=MappingUtil.internalDomainAccess.get();
    MappingUtil.internalDomainAccess.set(getInternalDomainAccess());
    context=this.updateLocalGraph(domainObjects);
  }
  finally {
    if (internalAccess != null)     MappingUtil.internalDomainAccess.set(internalAccess);
 else     MappingUtil.internalDomainAccess.remove();
  }
  List<JcError> errors=context.graph.store();
  DomainState ds=getDomainState();
  if (errors.isEmpty()) {
    for (    IRelation relat : context.relationsToRemove) {
      ds.removeRelation(relat);
    }
    Iterator<Entry<Object,GrNode>> it=context.domObj2Node.entrySet().iterator();
    while (it.hasNext()) {
      Entry<Object,GrNode> entry=it.next();
      ds.add_Id2Object(entry.getKey(),entry.getValue().getId(),ResolutionDepth.DEEP);
    }
    for (    DomRelation2ResultRelation d2r : context.domRelation2Relations) {
      ds.add_Id2Relation(d2r.domRelation,d2r.resultRelation.getId());
    }
  }
  return errors;
}
Program: 80471
Project: 80471
Buggy source:
private void calculateClosure(List<Object> domainObjects,UpdateContext context){
  for (  Object domainObject : domainObjects) {
    recursiveCalculateClosure(domainObject,null,context,false);
  }
}

Fixed version (ground truth):
private void calculateClosure(List<?> domainObjects,UpdateContext context){
  for (  Object domainObject : domainObjects) {
    recursiveCalculateClosure(domainObject,null,context,false);
  }
}
Program: 80472
Project: 80472
Buggy source:
@BeforeClass public static void before(){
  Properties props=new Properties();
  props.setProperty(DBProperties.SERVER_ROOT_URI,"String_Node_Str");
  props.setProperty(DBProperties.DATABASE_DIR,"String_Node_Str");
  dbAccess=DBAccessFactory.createDBAccess(DBType.IN_MEMORY,props);
}

Fixed version (ground truth):
@BeforeClass public static void before(){
  Properties props=new Properties();
  props.setProperty(DBProperties.SERVER_ROOT_URI,"String_Node_Str");
  props.setProperty(DBProperties.DATABASE_DIR,"String_Node_Str");
  dbAccess=DBAccessFactory.createDBAccess(DBType.IN_MEMORY,props);
  List<JcError> errors=dbAccess.clearDatabase();
  if (errors.size() > 0) {
    printErrors(errors);
    throw new JcResultException(errors);
  }
}
Program: 80473
Project: 80473
Buggy source:
private void queryDB_01(){
  JcQueryResult result;
  String resultString;
  String testId;
  setDoPrint(true);
  setDoAssert(true);
  TestDataReader tdr=new TestDataReader("String_Node_Str");
  JcNode movie=new JcNode("String_Node_Str");
  JcNode n=new JcNode("String_Node_Str");
  JcRelation r=new JcRelation("String_Node_Str");
  JcQuery query=new JcQuery();
  query.setClauses(new IClause[]{MATCH.node(movie).label("String_Node_Str").property("String_Node_Str").value("String_Node_Str"),RETURN.value(movie)});
  result=dbAccess.execute(query);
  resultString=Util.writePretty(result.getJsonResult());
  print(resultString);
  testId="String_Node_Str";
  assertQuery(testId,resultString,tdr.getTestData(testId));
  query=new JcQuery();
  query.setClauses(new IClause[]{MATCH.node(n).relation(r).out().node(),RETURN.ALL()});
  result=dbAccess.execute(query);
  resultString=Util.writePretty(result.getJsonResult());
  print(resultString);
  testId="String_Node_Str";
  return;
}

Fixed version (ground truth):
private void queryDB_01(){
  JcQueryResult result;
  String resultString;
  String testId;
  setDoPrint(true);
  setDoAssert(true);
  TestDataReader tdr=new TestDataReader("String_Node_Str");
  JcNode movie=new JcNode("String_Node_Str");
  JcNode n=new JcNode("String_Node_Str");
  JcRelation r=new JcRelation("String_Node_Str");
  JcQuery query=new JcQuery();
  query.setClauses(new IClause[]{MATCH.node(movie).label("String_Node_Str").property("String_Node_Str").value("String_Node_Str"),RETURN.value(movie)});
  result=dbAccess.execute(query);
  resultString=Util.writePretty(result.getJsonResult());
  print(resultString);
  testId="String_Node_Str";
  assertQuery(testId,resultString,tdr.getTestData(testId));
  query=new JcQuery();
  query.setClauses(new IClause[]{MATCH.node(n).relation(r).out().node(),RETURN.ALL()});
  result=dbAccess.execute(query);
  resultString=Util.writePretty(result.getJsonResult());
  print(resultString);
  testId="String_Node_Str";
  assertQuery(testId,resultString,tdr.getTestData(testId));
  return;
}
Program: 80474
Project: 80474
Buggy source:
private void buildNextClone(int tmpNodeIdx,List<Class<?>> types,boolean isList,CloneInfo cloneInfo){
  cloneInfo.toClone=cloneInfo.toClone.next;
  StepClause stpc=new StepClause();
  this.next=stpc;
  stpc.previous=this;
  stpc.matchNode=this.matchNode;
  stpc.endNodeLabel=this.endNodeLabel;
  stpc.originalEndNodeName=this.originalEndNodeName;
  stpc.traversalExpression=this.traversalExpression;
  stpc.stepClauses=this.stepClauses;
  stpc.stepIndex=cloneInfo.toClone.stepIndex;
  stpc.step=cloneInfo.toClone.step;
  stpc.fieldMapping=cloneInfo.toClone.fieldMapping;
  stpc.fieldMappings=cloneInfo.toClone.fieldMappings;
  stpc.fmIndex=cloneInfo.toClone.fmIndex;
  stpc.buildClone(tmpNodeIdx,cloneInfo,isList);
}

Fixed version (ground truth):
private void buildNextClone(int tmpNodeIdx,List<Class<?>> types,boolean isList,CloneInfo cloneInfo){
  cloneInfo.toClone=cloneInfo.toClone.next;
  StepClause stpc=new StepClause();
  this.next=stpc;
  stpc.previous=this;
  stpc.matchNode=this.matchNode;
  stpc.endNodeLabel=this.endNodeLabel;
  stpc.originalEndNodeName=this.originalEndNodeName;
  stpc.traversalExpression=this.traversalExpression;
  stpc.stepClauses=this.stepClauses;
  stpc.stepIndex=cloneInfo.toClone.stepIndex;
  stpc.step=cloneInfo.toClone.step;
  stpc.fieldMappings=cloneInfo.toClone.fieldMappings;
  stpc.fmIndex=cloneInfo.toClone.fmIndex;
  stpc.buildClone(tmpNodeIdx,cloneInfo,isList);
}
Program: 80476
Project: 80476
Buggy source:
private void cloneFirst(CloneInfo cloneInfo,int tmpNodeIdx){
  this.stepClauses.add(this);
  this.startNode=cloneInfo.toClone.startNode;
  this.jcPath=cloneInfo.toClone.jcPath;
  this.originalEndNodeName=cloneInfo.toClone.originalEndNodeName;
  this.endNodeLabel=cloneInfo.toClone.endNodeLabel;
  this.traversalExpression=cloneInfo.toClone.traversalExpression;
  if (this.jcPath != null)   this.matchNode=OPTIONAL_MATCH.path(this.jcPath).node(this.startNode);
 else   this.matchNode=OPTIONAL_MATCH.node(this.startNode);
  Class<?> typ=APIAccess.getTypeForNodeName(this.traversalExpression.getStart(),ValueAccess.getName(this.startNode));
  boolean isList=typ.equals(Collection.class) || typ.equals(Array.class);
  this.stepIndex=cloneInfo.toClone.stepIndex;
  this.step=cloneInfo.toClone.step;
  this.fieldMapping=cloneInfo.toClone.fieldMapping;
  this.fieldMappings=cloneInfo.toClone.fieldMappings;
  this.fmIndex=cloneInfo.toClone.fmIndex;
  this.buildClone(tmpNodeIdx,cloneInfo,isList);
}

Fixed version (ground truth):
private void cloneFirst(CloneInfo cloneInfo,int tmpNodeIdx){
  this.stepClauses.add(this);
  this.startNode=cloneInfo.toClone.startNode;
  this.jcPath=cloneInfo.toClone.jcPath;
  this.originalEndNodeName=cloneInfo.toClone.originalEndNodeName;
  this.endNodeLabel=cloneInfo.toClone.endNodeLabel;
  this.traversalExpression=cloneInfo.toClone.traversalExpression;
  if (this.jcPath != null)   this.matchNode=OPTIONAL_MATCH.path(this.jcPath).node(this.startNode);
 else   this.matchNode=OPTIONAL_MATCH.node(this.startNode);
  Class<?> typ=APIAccess.getTypeForNodeName(this.traversalExpression.getStart(),ValueAccess.getName(this.startNode));
  boolean isList=typ.equals(Collection.class) || typ.equals(Array.class);
  this.stepIndex=cloneInfo.toClone.stepIndex;
  this.step=cloneInfo.toClone.step;
  this.fieldMappings=cloneInfo.toClone.fieldMappings;
  this.fmIndex=cloneInfo.toClone.fmIndex;
  this.buildClone(tmpNodeIdx,cloneInfo,isList);
}
Program: 80477
Project: 80477
Buggy source:
private void addCountWithClause(ClausesPerType iCpt,List<IClause> countWithClauses,List<IClause> selectClauses,ClausesPerType cpt){
  String alias=ValueAccess.getName(iCpt.node).concat(countXprPostPrefix);
  JcNumber num=new JcNumber(alias);
  selectClauses.add(WITH.count().value(iCpt.node).AS(num));
  selectClauses.addAll(countWithClauses);
  cpt.countWithClausesIdxs.add(0,selectClauses.size());
  countWithClauses.add(0,WITH.value(num));
}

Fixed version (ground truth):
private void addCountWithClause(ClausesPerType iCpt,List<IClause> countWithClauses,List<IClause> selectClauses,ClausesPerType cpt){
  String alias=ValueAccess.getName(iCpt.node).concat(countXprPostPrefix);
  JcNumber num=new JcNumber(alias);
  selectClauses.add(WITH.count().DISTINCT().value(iCpt.node).AS(num));
  selectClauses.addAll(countWithClauses);
  cpt.countWithClausesIdxs.add(0,selectClauses.size());
  countWithClauses.add(0,WITH.value(num));
}
Program: 80478
Project: 80478
Buggy source:
private void build(int tmpNodeIdx,List<Class<?>> types,boolean isList){
  FieldMapping fm=null;
  List<FieldMapping> fms=null;
  for (  Class<?> t : types) {
    if (this.step.getDirection() == 0) {
      fm=getMappingInfo().getFieldMapping(this.step.getAttributeName(),t);
      if (fm != null)       break;
    }
 else {
      if (fms == null)       fms=new ArrayList<FieldMapping>();
      List<FieldMapping> fms_t=getMappingInfo().getBackwardFieldMappings(this.step.getAttributeName(),t);
      for (      FieldMapping f : fms_t) {
        if (!fms.contains(f))         fms.add(f);
      }
    }
  }
  boolean doBuild=false;
  if (fms != null && !fms.isEmpty()) {
    if (fms.size() == 1)     this.fieldMapping=fms.get(0);
 else {
      this.fieldMappings=fms;
      this.fmIndex=0;
    }
    doBuild=true;
  }
 else {
    if (fm != null) {
      this.fieldMapping=fm;
      doBuild=true;
    }
 else     this.matchNode=null;
  }
  if (doBuild) {
    if (this.step.getDirection() == 0)     this.buildStep(tmpNodeIdx,isList,null,true);
 else     this.buildStep(tmpNodeIdx,isList,null,false);
  }
  if (this.fieldMappings != null && this.fmIndex < this.fieldMappings.size() - 1) {
    this.cloneTraversal(this,tmpNodeIdx + 1);
  }
}

Fixed version (ground truth):
private void build(int tmpNodeIdx,List<Class<?>> types,boolean isList){
  List<FieldMapping> fms=null;
  for (  Class<?> t : types) {
    if (this.step.getDirection() == 0) {
      FieldMapping fm=getMappingInfo().getFieldMapping(this.step.getAttributeName(),t);
      if (fm != null) {
        if (fms == null)         fms=new ArrayList<FieldMapping>();
        fms.add(fm);
      }
    }
 else {
      if (fms == null)       fms=new ArrayList<FieldMapping>();
      List<FieldMapping> fms_t=getMappingInfo().getBackwardFieldMappings(this.step.getAttributeName(),t);
      for (      FieldMapping f : fms_t) {
        if (!fms.contains(f))         fms.add(f);
      }
    }
  }
  boolean doBuild=false;
  if (fms != null && !fms.isEmpty()) {
    this.fieldMappings=fms;
    this.fmIndex=0;
    doBuild=true;
  }
 else {
    this.matchNode=null;
  }
  if (doBuild) {
    if (this.step.getDirection() == 0)     this.buildStep(tmpNodeIdx,isList,null,true);
 else     this.buildStep(tmpNodeIdx,isList,null,false);
  }
  if (this.fieldMappings != null && this.fmIndex < this.fieldMappings.size() - 1) {
    this.cloneTraversal(this,tmpNodeIdx + 1);
  }
}
Program: 80482
Project: 80482
Buggy source:
private void addDependencyClauses(List<IClause> clauses){
  boolean hasCountWithXpr=this.countWithClausesIdxs != null;
  List<String> depBases=null;
  if (hasCountWithXpr)   depBases=new ArrayList<String>();
  if (this.expressionsPerDOM.flattenedDependencies != null) {
    for (    ExpressionsPerDOM xpd : this.expressionsPerDOM.flattenedDependencies) {
      List<DomainObjectMatch<?>> collOwner=APIAccess.getCollectExpressionOwner(xpd.domainObjectMatch);
      boolean addExpressions=collOwner == null || !collOwner.contains(this.domainObjectMatch);
      for (      ClausesPerType cpt : xpd.clausesPerTypes) {
        if (addExpressions) {
          cpt.addClausesTo(clauses);
          if (hasCountWithXpr) {
            String bnm=APIAccess.getBaseNodeName(cpt.domainObjectMatch);
            if (!depBases.contains(bnm))             depBases.add(bnm);
          }
        }
 else {
          if (this.countWithValidNodes != null)           this.countWithValidNodes.remove(ValueAccess.getName(cpt.node));
        }
      }
    }
  }
  if (hasCountWithXpr) {
    int sz=this.countWithValidNodes.size();
    for (int i=sz - 1; i >= 0; i--) {
      if (!isValidDependency(this.countWithValidNodes.get(i),depBases))       this.countWithValidNodes.remove(i);
    }
  }
}

Fixed version (ground truth):
private void addDependencyClauses(List<IClause> clauses,List<ClausesPerType> added){
  boolean hasCountWithXpr=this.countWithClausesIdxs != null;
  List<String> depBases=null;
  if (hasCountWithXpr)   depBases=new ArrayList<String>();
  if (this.expressionsPerDOM.flattenedDependencies != null) {
    for (    ExpressionsPerDOM xpd : this.expressionsPerDOM.flattenedDependencies) {
      List<DomainObjectMatch<?>> collOwner=APIAccess.getCollectExpressionOwner(xpd.domainObjectMatch);
      boolean addExpressions=collOwner == null || !collOwner.contains(this.domainObjectMatch);
      for (      ClausesPerType cpt : xpd.clausesPerTypes) {
        if (!added.contains(cpt)) {
          if (addExpressions) {
            cpt.addClausesTo(clauses);
            if (hasCountWithXpr) {
              String bnm=APIAccess.getBaseNodeName(cpt.domainObjectMatch);
              if (!depBases.contains(bnm))               depBases.add(bnm);
            }
          }
 else {
            if (this.countWithValidNodes != null)             this.countWithValidNodes.remove(ValueAccess.getName(cpt.node));
          }
          added.add(cpt);
        }
      }
    }
  }
  if (hasCountWithXpr) {
    int sz=this.countWithValidNodes.size();
    for (int i=sz - 1; i >= 0; i--) {
      if (!isValidDependency(this.countWithValidNodes.get(i),depBases))       this.countWithValidNodes.remove(i);
    }
  }
}