nus-yam/ex-repair huggingface dataset:
Program: 39662
Project: 39662
Buggy source:
protected <O>O _create(Class<O> clazz,String name) throws NullPointerException, IllegalArgumentException, RepositoryException {
  if (clazz == null) {
    throw new NullPointerException();
  }
  ObjectMapper<?> typeMapper=domain.getTypeMapper(clazz);
  TransientEntityContextState state=new TransientEntityContextState(this);
  ObjectContext octx;
  if (typeMapper.getKind() == NodeTypeKind.PRIMARY) {
    EntityContext ctx=new EntityContext((ObjectMapper<EntityContext>)typeMapper,state);
    if (name != null) {
      ctx.setName(name);
    }
    broadcaster.created(ctx.getObject());
    octx=ctx;
  }
 else {
    if (name != null) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    octx=new EmbeddedContext((ObjectMapper<EmbeddedContext>)typeMapper,this);
  }
  return clazz.cast(octx.getObject());
}

Fixed version (ground truth):
protected <O>O _create(Class<O> clazz,String name) throws NullPointerException, IllegalArgumentException, RepositoryException {
  if (clazz == null) {
    throw new NullPointerException();
  }
  ObjectMapper<?> typeMapper=domain.getTypeMapper(clazz);
  if (typeMapper == null) {
    throw new IllegalArgumentException("String_Node_Str" + clazz.getName() + "String_Node_Str");
  }
  TransientEntityContextState state=new TransientEntityContextState(this);
  ObjectContext octx;
  if (typeMapper.getKind() == NodeTypeKind.PRIMARY) {
    EntityContext ctx=new EntityContext((ObjectMapper<EntityContext>)typeMapper,state);
    if (name != null) {
      ctx.setName(name);
    }
    broadcaster.created(ctx.getObject());
    octx=ctx;
  }
 else {
    if (name != null) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    octx=new EmbeddedContext((ObjectMapper<EmbeddedContext>)typeMapper,this);
  }
  return clazz.cast(octx.getObject());
}
Program: 39663
Project: 39663
Buggy source:
@Override protected EmbeddedContext _getEmbedded(EntityContext entityCtx,Class<?> embeddedClass) throws RepositoryException {
  if (entityCtx == null) {
    throw new NullPointerException();
  }
  if (embeddedClass == null) {
    throw new NullPointerException();
  }
  ObjectMapper<EmbeddedContext> mapper=(ObjectMapper<EmbeddedContext>)domain.getTypeMapper(embeddedClass);
  EmbeddedContext embeddedCtx=entityCtx.embeddeds.get(mapper);
  if (embeddedCtx == null) {
    Node node=entityCtx.state.getNode();
    if (mapper.getKind() == NodeTypeKind.MIXIN) {
      String mixinTypeName=mapper.getNodeTypeName();
      if (sessionWrapper.haxMixin(node,mixinTypeName)) {
        NodeType mixinType=sessionWrapper.getNodeType(mixinTypeName);
        MixinTypeInfo mixinTypeInfo=domain.nodeInfoManager.getMixinTypeInfo(mixinType);
        embeddedCtx=new EmbeddedContext(mapper,this);
        entityCtx.embeddeds.put(embeddedCtx.mapper,embeddedCtx);
        embeddedCtx.relatedEntity=entityCtx;
        embeddedCtx.typeInfo=mixinTypeInfo;
      }
    }
 else {
      PrimaryTypeInfo typeInfo=entityCtx.state.getTypeInfo();
      PrimaryTypeInfo superTI=(PrimaryTypeInfo)typeInfo.getSuperType(mapper.getNodeTypeName());
      if (superTI != null) {
        embeddedCtx=new EmbeddedContext(mapper,this);
        entityCtx.embeddeds.put(embeddedCtx.mapper,embeddedCtx);
        embeddedCtx.relatedEntity=entityCtx;
        embeddedCtx.typeInfo=superTI;
      }
    }
  }
  return embeddedCtx;
}

Fixed version (ground truth):
@Override protected EmbeddedContext _getEmbedded(EntityContext entityCtx,Class<?> embeddedClass) throws RepositoryException {
  if (entityCtx == null) {
    throw new NullPointerException();
  }
  if (embeddedClass == null) {
    throw new NullPointerException();
  }
  ObjectMapper<EmbeddedContext> mapper=(ObjectMapper<EmbeddedContext>)domain.getTypeMapper(embeddedClass);
  EmbeddedContext embeddedCtx=null;
  if (mapper != null) {
    embeddedCtx=entityCtx.embeddeds.get(mapper);
    if (embeddedCtx == null) {
      Node node=entityCtx.state.getNode();
      if (mapper.getKind() == NodeTypeKind.MIXIN) {
        String mixinTypeName=mapper.getNodeTypeName();
        if (sessionWrapper.haxMixin(node,mixinTypeName)) {
          NodeType mixinType=sessionWrapper.getNodeType(mixinTypeName);
          MixinTypeInfo mixinTypeInfo=domain.nodeInfoManager.getMixinTypeInfo(mixinType);
          embeddedCtx=new EmbeddedContext(mapper,this);
          entityCtx.embeddeds.put(embeddedCtx.mapper,embeddedCtx);
          embeddedCtx.relatedEntity=entityCtx;
          embeddedCtx.typeInfo=mixinTypeInfo;
        }
      }
 else {
        PrimaryTypeInfo typeInfo=entityCtx.state.getTypeInfo();
        PrimaryTypeInfo superTI=(PrimaryTypeInfo)typeInfo.getSuperType(mapper.getNodeTypeName());
        if (superTI != null) {
          embeddedCtx=new EmbeddedContext(mapper,this);
          entityCtx.embeddeds.put(embeddedCtx.mapper,embeddedCtx);
          embeddedCtx.relatedEntity=entityCtx;
          embeddedCtx.typeInfo=superTI;
        }
      }
    }
  }
  return embeddedCtx;
}
Program: 39664
Project: 39664
Buggy source:
@Override public Object get(EntityContext context) throws Throwable {
  Object parent=context.getParent();
  Class<?> relatedClass=getRelatedClass();
  if (relatedClass.isInstance(parent)) {
    return parent;
  }
 else {
    EntityContext parentCtx=context.getSession().unwrapEntity(parent);
    EmbeddedContext mixinCtx=parentCtx.getEmbedded(relatedClass);
    if (mixinCtx != null) {
      return mixinCtx.getObject();
    }
    return null;
  }
}

Fixed version (ground truth):
@Override public Object get(EntityContext context) throws Throwable {
  Object parent=context.getParent();
  Class<?> relatedClass=getRelatedClass();
  if (relatedClass.isInstance(parent)) {
    return parent;
  }
 else {
    EntityContext parentCtx=context.getSession().unwrapEntity(parent);
    EmbeddedContext embeddedCtx=parentCtx.getEmbedded(relatedClass);
    if (embeddedCtx != null) {
      return embeddedCtx.getObject();
    }
    return null;
  }
}
Program: 39665
Project: 39665
Buggy source:
public void testLoad() throws Exception {
  DomainSession session=login();
  Node rootNode=session.getRoot();
  Node aNode=rootNode.addNode("String_Node_Str","String_Node_Str");
  String aId=aNode.getUUID();
  Node bNode=aNode.addNode("String_Node_Str","String_Node_Str");
  String bId=bNode.getUUID();
  Node cNode=bNode.addNode("String_Node_Str","String_Node_Str");
  String cId=cNode.getUUID();
  rootNode.save();
  session=login();
  A a=session.findById(A.class,aId);
  B b=session.findById(B.class,bId);
  B c=session.findById(B.class,cId);
  assertSame(b,c.getBParent());
  assertNull(c.getAParent());
  assertSame(a,b.getAParent());
  assertNull(b.getBParent());
}

Fixed version (ground truth):
public void testLoad() throws Exception {
  DomainSession session=login();
  Node rootNode=session.getRoot();
  Node aNode=rootNode.addNode("String_Node_Str","String_Node_Str");
  String aId=aNode.getUUID();
  Node bNode=aNode.addNode("String_Node_Str","String_Node_Str");
  String bId=bNode.getUUID();
  Node cNode=bNode.addNode("String_Node_Str","String_Node_Str");
  String cId=cNode.getUUID();
  rootNode.save();
  session=login();
  A a=session.findById(A.class,aId);
  B b=session.findById(B.class,bId);
  B c=session.findById(B.class,cId);
  assertNull(c.getAParent());
  assertSame(b,c.getBParent());
  assertNull(c.getCParent());
  assertSame(a,b.getAParent());
  assertNull(b.getBParent());
  assertNull(b.getCParent());
}
Program: 39666
Project: 39666
Buggy source:
public void remove(Node node,LinkedList<String> ids) throws RepositoryException {
  for (NodeIterator i=node.getNodes(); i.hasNext(); ) {
    Node child=i.nextNode();
    remove(child,ids);
  }
  for (PropertyIterator i=node.getReferences(); i.hasNext(); ) {
    Property property=i.nextProperty();
    property.setValue((Node)null);
  }
  for (PropertyIterator i=node.getProperties(); i.hasNext(); ) {
    Property property=i.nextProperty();
    if (property.getType() == PropertyType.REFERENCE) {
      linkMgrs[LinkType.REFERENCE.index].setReferenced(node,property.getName(),null);
    }
 else     if (property.getType() == PropertyType.PATH) {
      linkMgrs[LinkType.PATH.index].setReferenced(node,property.getName(),null);
    }
  }
  String id=node.getUUID();
  node.remove();
  ids.add(id);
}

Fixed version (ground truth):
/** 
 * Remove a node recursively in order to have one remove event generated for every descendants of the node in order to keep the contexts state corrects. It also remove all existing references to that node.
 * @param node the node to remove
 * @throws RepositoryException any repository exception
 */
public Iterator<String> remove(Node node) throws RepositoryException {
  LinkedList<String> ids=new LinkedList<String>();
  collectRemovedIds(node,ids);
  node.remove();
  return ids.iterator();
}
Program: 39667
Project: 39667
Buggy source:
protected void createDomain(){
  addClass(TLF_A.class);
}

Fixed version (ground truth):
protected void createDomain(){
  addClass(TLF_A.class);
  addClass(M1.class);
  addClass(M2.class);
}
Program: 39668
Project: 39668
Buggy source:
private Option(String name,String displayName){
  ParameterizedType pt=(ParameterizedType)getClass().getGenericSuperclass();
  Class clazz=(Class)pt.getActualTypeArguments()[0];
  Type<T> type;
  if (clazz == String.class) {
    type=(Type<T>)Type.STRING;
  }
 else   if (clazz == Boolean.class) {
    type=(Type<T>)Type.BOOLEAN;
  }
 else {
    throw new UnsupportedOperationException();
  }
  this.name=name;
  this.displayName=displayName;
  this.type=type;
}

Fixed version (ground truth):
private Option(Type<T> type,String name,String displayName){
  this.name=name;
  this.displayName=displayName;
  this.type=type;
}
Program: 39669
Project: 39669
Buggy source:
private Iterable<MethodInfo> getMethodsToImplement(ClassTypeInfo cti){
  List<MethodInfo> methods=new ArrayList<MethodInfo>();
  MethodIntrospector introspector=new MethodIntrospector(TypeScope.CLASS_HIERARCHY);
  for (  MethodInfo method : introspector.getMethods(cti)) {
    if (method.isAbstract()) {
      methods.add(method);
    }
  }
  return methods;
}

Fixed version (ground truth):
private Iterable<MethodInfo> getMethodsToImplement(ClassTypeInfo cti){
  List<MethodInfo> methods=new ArrayList<MethodInfo>();
  MethodIntrospector introspector=new MethodIntrospector(HierarchyScope.ALL,true);
  for (  MethodInfo method : introspector.getMethods(cti)) {
    if (method.isAbstract()) {
      methods.add(method);
    }
  }
  return methods;
}
Program: 39672
Project: 39672
Buggy source:
public ListIterator<E> listIterator(int index){
  return new AbstractBufferingListIterator<E>(model);
}

Fixed version (ground truth):
public ListIterator<E> listIterator(int index){
  BufferingListIterator<E> iterator=new BufferingListIterator<E>(model);
  while (index-- > 0) {
    iterator.next();
  }
  return iterator;
}
Program: 39673
Project: 39673
Buggy source:
void add(ElementPosition<E> position,E addedElement);

Fixed version (ground truth):
void add(ElementInsertion<E> insertion);
Program: 39674
Project: 39674
Buggy source:
protected void createDomain(){
  addClass(A.class);
  addClass(C.class);
}

Fixed version (ground truth):
protected void createDomain(){
  addClass(A.class);
  addClass(C.class);
  addClass(D2Impl.class);
}
Program: 39675
Project: 39675
Buggy source:
private Iterable<MethodInfo> getMethodsToImplement(ClassTypeInfo cti){
  List<MethodInfo> methods=new ArrayList<MethodInfo>();
  ClassIntrospector introspector=new ClassIntrospector(cti);
  for (  MethodInfo method : introspector.getMethods()) {
    if (method.isAbstract()) {
      methods.add(method);
    }
  }
  return methods;
}

Fixed version (ground truth):
private Iterable<MethodInfo> getMethodsToImplement(ClassTypeInfo cti){
  List<MethodInfo> methods=new ArrayList<MethodInfo>();
  MethodIntrospector introspector=new MethodIntrospector(TypeScope.CLASS_HIERARCHY);
  for (  MethodInfo method : introspector.getMethods(cti)) {
    if (method.isAbstract()) {
      methods.add(method);
    }
  }
  return methods;
}
Program: 39676
Project: 39676
Buggy source:
public Object invoke(ObjectContext ctx,Method method,Object[] args) throws Throwable {
  MethodInvoker invoker=dispatchers.get(method);
  if (invoker != null) {
    return invoker.invoke(ctx,method,args);
  }
 else {
    throw new AssertionError();
  }
}

Fixed version (ground truth):
public Object invoke(ObjectContext ctx,Method method,Object[] args) throws Throwable {
  MethodInvoker invoker=dispatchers.get(method);
  if (invoker != null) {
    return invoker.invoke(ctx,method,args);
  }
 else {
    StringBuilder msg=new StringBuilder("String_Node_Str").append(method.getName()).append("String_Node_Str");
    Class[] parameterTypes=method.getParameterTypes();
    for (int i=0; i < parameterTypes.length; i++) {
      if (i > 0) {
        msg.append(',');
      }
      msg.append(parameterTypes[i].getName());
    }
    msg.append("String_Node_Str");
    for (int i=0; i < args.length; i++) {
      if (i > 0) {
        msg.append(',');
      }
      msg.append(String.valueOf(args[i]));
    }
    msg.append("String_Node_Str");
    throw new AssertionError(msg);
  }
}
Program: 39677
Project: 39677
Buggy source:
protected void createDomain(){
  addClass(A.class);
}

Fixed version (ground truth):
protected void createDomain(){
  addClass(A.class);
  addClass(C.class);
}
Program: 39678
Project: 39678
Buggy source:
<O>void addLifeCycleListener(LifeCycleListener<O> listener);

Fixed version (ground truth):
/** 
 * Returns a virtual object from the specified object
 * @param o the real object
 * @param < O > the object type parameter
 * @return the corresponding virtual object
 * @throws ChromatticException any exception
 */
<O>void addLifeCycleListener(LifeCycleListener<O> listener);
Program: 39679
Project: 39679
Buggy source:
void setPropertyValue(String propertyName,SimpleValueInfo type,Object o){
  try {
    Value value;
    if (o != null) {
      ValueFactory valueFactory=session.getJCRSession().getValueFactory();
      SimpleType st=type != null ? type.getSimpleType() : null;
      value=ValueMapper.instance.get(valueFactory,o,st);
    }
 else {
      value=null;
    }
    PropertyDefinition def=JCR.findPropertyDefinition(node,propertyName);
    if (def == null) {
      throw new NoSuchPropertyException("String_Node_Str" + propertyName + "String_Node_Str"+ node.getPath()+ "String_Node_Str"+ node.getPrimaryNodeType().getName());
    }
    if (value != null) {
      int neededType=def.getRequiredType();
      if (neededType != PropertyType.UNDEFINED) {
        if (neededType != value.getType()) {
          throw new ClassCastException();
        }
      }
    }
    if (def.isMultiple()) {
      if (value == null) {
        node.setProperty(propertyName,new Value[0]);
      }
 else {
        node.setProperty(propertyName,new Value[]{value});
      }
    }
 else {
      node.setProperty(propertyName,value);
    }
  }
 catch (  RepositoryException e) {
    throw new UndeclaredRepositoryException(e);
  }
}

Fixed version (ground truth):
void setPropertyValue(String propertyName,SimpleValueInfo type,Object o){
  try {
    Value value;
    if (o != null) {
      ValueFactory valueFactory=session.getJCRSession().getValueFactory();
      SimpleType st=type != null ? type.getSimpleType() : null;
      value=ValueMapper.instance.get(valueFactory,o,st);
    }
 else {
      value=null;
    }
    PropertyDefinition def=JCR.findPropertyDefinition(node,propertyName);
    if (def == null) {
      throw new NoSuchPropertyException("String_Node_Str" + propertyName + "String_Node_Str"+ node.getPath()+ "String_Node_Str"+ node.getPrimaryNodeType().getName());
    }
    if (value != null) {
      int neededType=def.getRequiredType();
      if (neededType != PropertyType.UNDEFINED) {
        if (neededType != value.getType()) {
          throw new ClassCastException("String_Node_Str" + value.getType() + "String_Node_Str"+ neededType+ "String_Node_Str"+ propertyName);
        }
      }
    }
    if (def.isMultiple()) {
      if (value == null) {
        node.setProperty(propertyName,new Value[0]);
      }
 else {
        node.setProperty(propertyName,new Value[]{value});
      }
    }
 else {
      node.setProperty(propertyName,value);
    }
  }
 catch (  RepositoryException e) {
    throw new UndeclaredRepositoryException(e);
  }
}
Program: 39680
Project: 39680
Buggy source:
public Node setReferenced(Node referent,String propertyName,Node referenced) throws RepositoryException {
  Node oldReferenced=null;
  if (referent.hasProperty(propertyName)) {
    Property property=referent.getProperty(propertyName);
    oldReferenced=_getReferenced(property);
    Entry entry=getEntry(oldReferenced);
    boolean scheduleForAddition=true;
    Set<Node> propertyScheduledForAddition=entry.propertiesScheduledForAddition.get(propertyName);
    if (propertyScheduledForAddition != null) {
      if (propertyScheduledForAddition.contains(referent)) {
        propertyScheduledForAddition.remove(referent);
        scheduleForAddition=false;
      }
    }
    if (scheduleForAddition) {
      Set<Node> propertyScheduledForRemoval=entry.propertiesScheduledForRemoval.get(propertyName);
      if (propertyScheduledForRemoval == null) {
        propertyScheduledForRemoval=new HashSet<Node>();
        entry.propertiesScheduledForRemoval.put(propertyName,propertyScheduledForRemoval);
      }
      propertyScheduledForRemoval.add(referent);
      entry.version++;
    }
  }
  _setReferenced(referent,propertyName,referenced);
  if (referenced != null) {
    Entry entry=getEntry(referenced);
    Set<Node> srcs=entry.propertiesScheduledForAddition.get(propertyName);
    if (srcs == null) {
      srcs=new HashSet<Node>();
      entry.propertiesScheduledForAddition.put(propertyName,srcs);
    }
    srcs.add(referent);
    entry.version++;
  }
 else {
  }
  return oldReferenced;
}

Fixed version (ground truth):
public Node setReferenced(Node referent,String propertyName,Node referenced) throws RepositoryException {
  Node oldReferenced=null;
  if (referent.hasProperty(propertyName)) {
    Property property=referent.getProperty(propertyName);
    oldReferenced=_getReferenced(property);
    if (oldReferenced != null) {
      Entry entry=getEntry(oldReferenced);
      boolean scheduleForAddition=true;
      Set<Node> propertyScheduledForAddition=entry.propertiesScheduledForAddition.get(propertyName);
      if (propertyScheduledForAddition != null) {
        if (propertyScheduledForAddition.contains(referent)) {
          propertyScheduledForAddition.remove(referent);
          scheduleForAddition=false;
        }
      }
      if (scheduleForAddition) {
        Set<Node> propertyScheduledForRemoval=entry.propertiesScheduledForRemoval.get(propertyName);
        if (propertyScheduledForRemoval == null) {
          propertyScheduledForRemoval=new HashSet<Node>();
          entry.propertiesScheduledForRemoval.put(propertyName,propertyScheduledForRemoval);
        }
        propertyScheduledForRemoval.add(referent);
        entry.version++;
      }
    }
  }
  _setReferenced(referent,propertyName,referenced);
  if (referenced != null) {
    Entry entry=getEntry(referenced);
    Set<Node> srcs=entry.propertiesScheduledForAddition.get(propertyName);
    if (srcs == null) {
      srcs=new HashSet<Node>();
      entry.propertiesScheduledForAddition.put(propertyName,srcs);
    }
    srcs.add(referent);
    entry.version++;
  }
 else {
  }
  return oldReferenced;
}
Program: 39681
Project: 39681
Buggy source:
public Node getReferenced(Node referent,String propertyName) throws RepositoryException {
  if (referent.hasProperty(propertyName)) {
    Property property=referent.getProperty(propertyName);
    if (property.getType() == PropertyType.REFERENCE) {
      return property.getNode();
    }
 else {
      return null;
    }
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public Node getReferenced(Node referent,String propertyName) throws RepositoryException {
  if (referent.hasProperty(propertyName)) {
    Property property=referent.getProperty(propertyName);
    if (property.getType() == PropertyType.REFERENCE) {
      try {
        return property.getNode();
      }
 catch (      ItemNotFoundException e) {
        return null;
      }
    }
 else {
      return null;
    }
  }
 else {
    return null;
  }
}
Program: 39682
Project: 39682
Buggy source:
public void nodeRemoved(String nodeId) throws RepositoryException {
  log.trace("String_Node_Str",nodeId);
  ObjectContext ctx=contexts.remove(nodeId);
  ctx.state=new RemovedContextState(nodeId,ctx.state.getPrimaryNodeType());
  fireEvent(LifeCycleType.REMOVED,ctx);
  log.trace("String_Node_Str",ctx,nodeId);
}

Fixed version (ground truth):
public void nodeRemoved(String nodeId) throws RepositoryException {
  log.trace("String_Node_Str",nodeId);
  ObjectContext ctx=contexts.remove(nodeId);
  if (ctx != null) {
    ctx.state=new RemovedContextState(nodeId,ctx.state.getPrimaryNodeType());
    fireEvent(LifeCycleType.REMOVED,ctx);
    log.trace("String_Node_Str",ctx,nodeId);
  }
 else {
    log.trace("String_Node_Str",ctx,nodeId);
  }
}
Program: 39683
Project: 39683
Buggy source:
protected <T>Iterator<T> _getRelateds(ObjectContext ctx,String name,Class<T> filterClass) throws RepositoryException {
  Node node=ctx.state.getNode();
  Iterator<Node> nodes=sessionWrapper.getRelateds(node,name);
  return new ReferentCollectionIterator<T>(this,nodes,filterClass,name);
}

Fixed version (ground truth):
protected <T>Iterator<T> _getRelateds(ObjectContext ctx,String name,Class<T> filterClass) throws RepositoryException {
  Node node=ctx.state.getNode();
  Iterator<Node> nodes=sessionWrapper.getReferents(node,name);
  return new ReferentCollectionIterator<T>(this,nodes,filterClass,name);
}
Program: 39684
Project: 39684
Buggy source:
protected boolean _setRelated(ObjectContext ctx,String name,ObjectContext relatedCtx) throws RepositoryException {
  if (ctx.getStatus() != Status.PERSISTENT) {
    throw new IllegalStateException("String_Node_Str" + this);
  }
  Node node=ctx.state.getNode();
  if (relatedCtx != null) {
    if (relatedCtx.getStatus() != Status.PERSISTENT) {
      throw new IllegalStateException();
    }
    Node relatedNode=relatedCtx.state.getNode();
    return relatedNode != sessionWrapper.setRelated(node,name,relatedNode);
  }
 else {
    return null != sessionWrapper.setRelated(node,name,null);
  }
}

Fixed version (ground truth):
protected boolean _setRelated(ObjectContext ctx,String name,ObjectContext relatedCtx) throws RepositoryException {
  if (ctx.getStatus() != Status.PERSISTENT) {
    throw new IllegalStateException("String_Node_Str" + this);
  }
  Node node=ctx.state.getNode();
  if (relatedCtx != null) {
    if (relatedCtx.getStatus() != Status.PERSISTENT) {
      throw new IllegalStateException();
    }
    Node relatedNode=relatedCtx.state.getNode();
    return relatedNode != sessionWrapper.setReferenced(node,name,relatedNode);
  }
 else {
    return null != sessionWrapper.setReferenced(node,name,null);
  }
}
Program: 39685
Project: 39685
Buggy source:
protected Object _getRelated(ObjectContext ctx,String name) throws RepositoryException {
  if (ctx.getStatus() != Status.PERSISTENT) {
    throw new IllegalStateException();
  }
  Node node=ctx.state.getNode();
  Node related=sessionWrapper.getRelated(node,name);
  if (related != null) {
    return findByNode(Object.class,related);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
protected Object _getRelated(ObjectContext ctx,String name) throws RepositoryException {
  if (ctx.getStatus() != Status.PERSISTENT) {
    throw new IllegalStateException();
  }
  Node node=ctx.state.getNode();
  Node related=sessionWrapper.getReferenced(node,name);
  if (related != null) {
    return findByNode(Object.class,related);
  }
 else {
    return null;
  }
}
Program: 39686
Project: 39686
Buggy source:
private Entry(Node dst){
  this.version=0;
  this.dst=dst;
  this.propertiesScheduledForAddition=new HashMap<String,Set<Node>>();
  this.propertiesScheduledForRemoval=new HashMap<String,Set<Node>>();
}

Fixed version (ground truth):
private Entry(Node referenced){
  this.version=0;
  this.referenced=referenced;
  this.propertiesScheduledForAddition=new HashMap<String,Set<Node>>();
  this.propertiesScheduledForRemoval=new HashMap<String,Set<Node>>();
}
Program: 39687
Project: 39687
Buggy source:
public Iterator<Node> iterator(final String name) throws RepositoryException {
  PropertyIterator properties=dst.getReferences();
  Set<Node> blah=propertiesScheduledForRemoval.get(name);
  if (blah == null) {
    blah=Collections.emptySet();
  }
  final Set<Node> tutu=blah;
  AbstractFilterIterator<Node,Property> i1=new AbstractFilterIterator<Node,Property>((Iterator<Property>)properties){
    protected Node adapt(    Property property){
      try {
        String propertyName=property.getName();
        if (propertyName.equals(name)) {
          Node src=property.getParent();
          if (!tutu.contains(src)) {
            return src;
          }
        }
        return null;
      }
 catch (      RepositoryException e) {
        throw new UndeclaredRepositoryException(e);
      }
    }
  }
;
  Set<Node> srcs=propertiesScheduledForAddition.get(name);
  if (srcs == null) {
    srcs=new HashSet<Node>();
    propertiesScheduledForAddition.put(name,srcs);
  }
  final Iterator<Node> i2=srcs.iterator();
  return new CompoundIterator<Node>(i1,i2){
    int version=Entry.this.version;
    private void check(){
      if (version != Entry.this.version) {
        throw new ConcurrentModificationException();
      }
    }
    @Override public boolean hasNext(){
      check();
      return super.hasNext();
    }
    @Override public Node next(){
      check();
      return super.next();
    }
    @Override public void remove(){
      check();
      super.remove();
      version=Entry.this.version++;
    }
  }
;
}

Fixed version (ground truth):
public Iterator<Node> iterator(final String name) throws RepositoryException {
  PropertyIterator properties=referenced.getReferences();
  Set<Node> blah=propertiesScheduledForRemoval.get(name);
  if (blah == null) {
    blah=Collections.emptySet();
  }
  final Set<Node> tutu=blah;
  AbstractFilterIterator<Node,Property> i1=new AbstractFilterIterator<Node,Property>((Iterator<Property>)properties){
    protected Node adapt(    Property property){
      try {
        String propertyName=property.getName();
        if (propertyName.equals(name)) {
          Node src=property.getParent();
          if (!tutu.contains(src)) {
            return src;
          }
        }
        return null;
      }
 catch (      RepositoryException e) {
        throw new UndeclaredRepositoryException(e);
      }
    }
  }
;
  Set<Node> srcs=propertiesScheduledForAddition.get(name);
  if (srcs == null) {
    srcs=new HashSet<Node>();
    propertiesScheduledForAddition.put(name,srcs);
  }
  final Iterator<Node> i2=srcs.iterator();
  return new CompoundIterator<Node>(i1,i2){
    int version=Entry.this.version;
    private void check(){
      if (version != Entry.this.version) {
        throw new ConcurrentModificationException();
      }
    }
    @Override public boolean hasNext(){
      check();
      return super.hasNext();
    }
    @Override public Node next(){
      check();
      return super.next();
    }
    @Override public void remove(){
      check();
      super.remove();
      version=Entry.this.version++;
    }
  }
;
}
Program: 39688
Project: 39688
Buggy source:
private Entry getEntry(Node dst) throws RepositoryException {
  Entry entry=entries.get(dst.getUUID());
  if (entry == null) {
    entry=new Entry(dst);
    entries.put(dst.getUUID(),entry);
  }
  return entry;
}

Fixed version (ground truth):
private Entry getEntry(Node referenced) throws RepositoryException {
  Entry entry=entries.get(referenced.getUUID());
  if (entry == null) {
    entry=new Entry(referenced);
    entries.put(referenced.getUUID(),entry);
  }
  return entry;
}
Program: 39689
Project: 39689
Buggy source:
public void remove(Node node,LinkedList<String> ids) throws RepositoryException {
  for (NodeIterator i=node.getNodes(); i.hasNext(); ) {
    Node child=i.nextNode();
    remove(child,ids);
  }
  for (PropertyIterator i=node.getReferences(); i.hasNext(); ) {
    Property property=i.nextProperty();
    property.setValue((Node)null);
  }
  String id=node.getUUID();
  node.remove();
  ids.add(id);
}

Fixed version (ground truth):
public void remove(Node node,LinkedList<String> ids) throws RepositoryException {
  for (NodeIterator i=node.getNodes(); i.hasNext(); ) {
    Node child=i.nextNode();
    remove(child,ids);
  }
  for (PropertyIterator i=node.getReferences(); i.hasNext(); ) {
    Property property=i.nextProperty();
    property.setValue((Node)null);
  }
  for (PropertyIterator i=node.getProperties(); i.hasNext(); ) {
    Property property=i.nextProperty();
    if (property.getType() == PropertyType.REFERENCE) {
      refMgr.setReferenced(node,property.getName(),null);
    }
  }
  String id=node.getUUID();
  node.remove();
  ids.add(id);
}
Program: 39691
Project: 39691
Buggy source:
public static Invoker getDeclaredMethod(Class<?> clazz,final String methodName,final Class<?>... parameterTypes){
  MethodFinder visitor=new MethodFinder(methodName,parameterTypes);
  visitor.accept(clazz.getSuperclass());
  if (visitor.method == null) {
    throw new AssertionError("String_Node_Str" + methodName);
  }
  return new Invoker(visitor.method);
}

Fixed version (ground truth):
public static Invoker getDeclaredMethod(Class<?> clazz,final String methodName,final Class<?>... parameterTypes){
  MethodFinder visitor=new MethodFinder(methodName,parameterTypes);
  visitor.accept(clazz);
  if (visitor.method == null) {
    throw new AssertionError("String_Node_Str" + methodName);
  }
  return new Invoker(visitor.method);
}
Program: 39692
Project: 39692
Buggy source:
/** 
 * when created, starts mindrunner thread
 * @param mind
 * @param period 
 */
public MindRunner(OCMind mind,double period){
  this(mind,period,0,null);
  restart();
}

Fixed version (ground truth):
public MindRunner(OCMind mind,double period,boolean newThread){
  this(mind,period,0,null);
  if (newThread)   restart();
 else {
    running=true;
    run();
  }
}
Program: 39693
Project: 39693
Buggy source:
public void updateAttentionSort(){
  attentionSortedBySTI=new TreeMap<Atom,AttentionValue>(new Comparator<Atom>(){
    @Override public int compare(    Atom a,    Atom b){
      short sa=getSTI(a);
      short sb=getSTI(b);
      if (sa == sb)       return 0;
      return (sa > sb) ? -1 : 1;
    }
  }
);
  attentionSortedBySTI.putAll(attention);
}

Fixed version (ground truth):
public void updateAttentionSort(){
  List<Atom> toRemoveFromAttentionAndTruth=new LinkedList();
  for (  Atom a : attention.keySet()) {
    if (!atomspace.hasAtom(a)) {
      toRemoveFromAttentionAndTruth.add(a);
    }
  }
  for (  Atom a : toRemoveFromAttentionAndTruth) {
    attention.remove(a);
    truth.remove(a);
  }
  attentionSortedBySTI=new TreeMap<Atom,AttentionValue>(new Comparator<Atom>(){
    @Override public int compare(    Atom a,    Atom b){
      short sa=getSTI(a);
      short sb=getSTI(b);
      if (sa == sb)       return 0;
      return (sa > sb) ? -1 : 1;
    }
  }
);
  attentionSortedBySTI.putAll(attention);
}
Program: 39694
Project: 39694
Buggy source:
public Collection<Atom> getAtoms(){
  return atomspace.getAtoms();
}

Fixed version (ground truth):
@Override public List<Atom> getAtoms(Class<? extends AtomType> type,boolean includeSubtypes){
  Builder<Atom> ib=new ImmutableList.Builder<Atom>();
  Collection<Atom> v=atomspace.getAtoms(type,includeSubtypes);
  if (v != null) {
    ib.addAll(v);
    for (    ReadableAtomSpace ra : subspaces) {
      ib.addAll(ra.getAtoms(type,includeSubtypes));
    }
  }
  return ib.build();
}
Program: 39695
Project: 39695
Buggy source:
/** 
 * @param increasingOrDecreasing decreasing=true, increasing=false
 * @param include
 * @return 
 */
public Iterator<Atom> iterateAtomsBySTI(final boolean increasingOrDecreasing,final Predicate<Atom> include){
  return new Iterator<Atom>(){
    Atom next=null;
    @Override public boolean hasNext(){
      if (attentionSortedBySTI == null)       return false;
      if (attentionSortedBySTI.size() == 0)       return false;
      if (next == null) {
        if (increasingOrDecreasing == true)         next=attentionSortedBySTI.firstKey();
 else         next=attentionSortedBySTI.lastKey();
      }
 else {
        if (increasingOrDecreasing == true)         next=attentionSortedBySTI.higherKey(next);
 else         next=attentionSortedBySTI.lowerKey(next);
      }
      if (next == null)       return false;
      if (include == null)       return true;
 else {
        if (include.isTrue(next))         return true;
 else {
          while (!include.isTrue(next)) {
            if (increasingOrDecreasing == true)             next=attentionSortedBySTI.higherKey(next);
 else             next=attentionSortedBySTI.lowerKey(next);
            if (next == null)             return false;
          }
          return true;
        }
      }
    }
    @Override public Atom next(){
      return next;
    }
    @Override public void remove(){
      throw new UnsupportedOperationException("String_Node_Str");
    }
  }
;
}

Fixed version (ground truth):
/** 
 * @param increasingOrDecreasing decreasing=true, increasing=false
 * @param include
 * @return 
 */
public Iterator<Atom> iterateAtomsBySTI(final boolean increasingOrDecreasing,final Predicate<Atom> include){
  Iterator<Atom> i;
  if (increasingOrDecreasing)   i=attentionSortedBySTI.navigableKeySet().iterator();
 else   i=attentionSortedBySTI.navigableKeySet().descendingIterator();
  if (include != null)   return IteratorUtils.filteredIterator(i,include);
 else   return i;
}
Program: 39696
Project: 39696
Buggy source:
public boolean remove(Atom a){
  if (atomspace.remove(a)) {
    attention.remove(a);
    truth.remove(a);
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean remove(Atom a){
  if (atomspace.remove(a)) {
    return true;
  }
  return false;
}
Program: 39697
Project: 39697
Buggy source:
public Iterator<Atom> iterateAtoms(){
  return atomToType.keySet().iterator();
}

Fixed version (ground truth):
public Iterator<Atom> iterateAtoms(){
  return IteratorUtils.chainedIterator(iterateVertices(),iterateEdges());
}
Program: 39698
Project: 39698
Buggy source:
@Override public boolean visitVertices(Predicate<Atom> predicate,Operation<ReadableAtomSpace,Atom> op){
  for (  Atom e : getVertices()) {
    if (predicate.isTrue(e)) {
      boolean result=op.operate(this,e);
      if (!result)       return false;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean visitVertices(Predicate<Atom> predicate,Operation<ReadableAtomSpace,Atom> op){
  for (  Atom e : getVertices()) {
    if (predicate.evaluate(e)) {
      boolean result=op.operate(this,e);
      if (!result)       return false;
    }
  }
  return true;
}
Program: 39699
Project: 39699
Buggy source:
@Override public boolean visitEdges(Predicate<Atom> predicate,Operation<ReadableAtomSpace,Atom> op){
  for (  Atom e : getEdges()) {
    if (predicate.isTrue(e)) {
      boolean result=op.operate(this,e);
      if (!result)       return false;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean visitEdges(Predicate<Atom> predicate,Operation<ReadableAtomSpace,Atom> op){
  for (  Atom e : getEdges()) {
    if (predicate.evaluate(e)) {
      boolean result=op.operate(this,e);
      if (!result)       return false;
    }
  }
  return true;
}
Program: 39700
Project: 39700
Buggy source:
public Collection<Atom> getAtoms(){
  return atomToType.keySet();
}

Fixed version (ground truth):
public Collection<Atom> getAtoms(Class<? extends AtomType> type,boolean includeSubtypes){
  if (!includeSubtypes) {
    return typesToAtom.get(type);
  }
 else {
    logger.error("String_Node_Str");
    return null;
  }
}
Program: 39701
Project: 39701
Buggy source:
@Override protected void run(final OCMind mind){
  Iterator<Atom> ci=mind.iterateAtomsByDecreasingSTI(new Predicate<Atom>(){
    @Override public boolean isTrue(    Atom x){
      return (mind.getType(x).equals(AtomType.conceptNode));
    }
  }
);
  while (ci.hasNext()) {
    Atom leading=ci.next();
    if (speakable(leading)) {
      speak(leading);
      last=leading;
      break;
    }
  }
}

Fixed version (ground truth):
@Override protected void run(final OCMind mind){
  Iterator<Atom> ci=mind.iterateAtomsByDecreasingSTI(new Predicate<Atom>(){
    @Override public boolean evaluate(    Atom x){
      return (mind.getType(x).equals(AtomType.conceptNode));
    }
  }
);
  while (ci.hasNext()) {
    Atom leading=ci.next();
    if (speakable(leading)) {
      speak(leading);
      last=leading;
      break;
    }
  }
}
Program: 39702
Project: 39702
Buggy source:
@Override protected void run(OCMind mind){
  List<Atom> c=new ArrayList(mind.getAtoms());
  if (c != null) {
    if (c.size() > 0) {
      for (int n=0; n < numAtoms; n++) {
        int i=RandomNumber.getInt(0,c.size() - 1);
        Atom x=c.get(i);
        addStimulus(x,getBoost());
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void run(OCMind mind){
  List<Atom> c=IteratorUtils.toList(mind.iterateAtoms());
  if (c != null) {
    if (c.size() > 0) {
      for (int n=0; n < numAtoms; n++) {
        int i=RandomNumber.getInt(0,c.size() - 1);
        Atom x=c.get(i);
        addStimulus(x,getBoost());
      }
    }
  }
}
Program: 39703
Project: 39703
Buggy source:
@Override public void run(OCMind mind){
  for (  Atom a : mind.getAtoms()) {
    final int sti=mind.getSTI(a);
    int avgSurroundingSTI=0;
    int count=0;
    final Collection<Atom> ie=mind.getIncidentEdges(a);
    if (ie != null) {
      for (      Atom e : ie) {
        avgSurroundingSTI+=mind.getSTI(e);
        count++;
      }
    }
    final Collection<Atom> iv=mind.getIncidentVertices(a);
    if (iv != null) {
      for (      Atom e : iv) {
        avgSurroundingSTI+=mind.getSTI(e);
        count++;
      }
    }
    if (count != 0) {
      avgSurroundingSTI/=count;
    }
 else {
      continue;
    }
    final int diffusion_momentum=60;
    short difference=(short)(sti - avgSurroundingSTI);
    if (avgSurroundingSTI < sti) {
      difference/=diffusion_momentum;
      if (difference < 1)       difference=1;
      addStimulus(a,(short)-difference);
      totalSurplus+=difference;
    }
 else     if (avgSurroundingSTI > sti) {
      difference=(short)(avgSurroundingSTI - sti);
      difference/=diffusion_momentum;
      if (difference < 1)       difference=1;
      difference=(short)Math.min(difference,totalSurplus);
      if (totalSurplus >= difference) {
        addStimulus(a,(short)difference);
        totalSurplus-=difference;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(OCMind mind){
  Iterator<Atom> ia=mind.iterateAtoms();
  while (ia.hasNext()) {
    Atom a=ia.next();
    final int sti=mind.getSTI(a);
    int avgSurroundingSTI=0;
    int count=0;
    final Collection<Atom> ie=mind.getIncidentEdges(a);
    if (ie != null) {
      for (      Atom e : ie) {
        avgSurroundingSTI+=mind.getSTI(e);
        count++;
      }
    }
    final Collection<Atom> iv=mind.getIncidentVertices(a);
    if (iv != null) {
      for (      Atom e : iv) {
        avgSurroundingSTI+=mind.getSTI(e);
        count++;
      }
    }
    if (count != 0) {
      avgSurroundingSTI/=count;
    }
 else {
      continue;
    }
    final int diffusion_momentum=60;
    short difference=(short)(sti - avgSurroundingSTI);
    if (avgSurroundingSTI < sti) {
      difference/=diffusion_momentum;
      if (difference < 1)       difference=1;
      addStimulus(a,(short)-difference);
      totalSurplus+=difference;
    }
 else     if (avgSurroundingSTI > sti) {
      difference=(short)(avgSurroundingSTI - sti);
      difference/=diffusion_momentum;
      if (difference < 1)       difference=1;
      difference=(short)Math.min(difference,totalSurplus);
      if (totalSurplus >= difference) {
        addStimulus(a,(short)difference);
        totalSurplus-=difference;
      }
    }
  }
}
Program: 39704
Project: 39704
Buggy source:
public void testForget(){
  final int numVertices=500;
  final int numEdges=2000;
  final int targetVertices=numVertices / 2;
  final int targetEdges=numEdges / 2;
  OCMind m=new OCMind();
  printMemory("String_Node_Str");
  new RandomGraphGenerator(m,numVertices,numEdges);
  assertEquals(m.getVertexCount(),numVertices);
  assertEquals(m.getEdgeCount(),numEdges);
  printMemory("String_Node_Str");
  m.cycle();
  RandomStimulation rs=new RandomStimulation(0,(short)0,numVertices * 10){
    @Override public short getBoost(){
      return (short)RandomNumber.getInt(0,127);
    }
  }
;
  m.addAgent(rs);
  m.cycle();
  m.cycle();
  printGraphSize(m);
  Forget f=new Forget(0,targetVertices,targetEdges){
    @Override public void run(    OCMind mind){
      super.run(mind);
      System.out.println("String_Node_Str" + mind.getVertexCount() + "String_Node_Str"+ mind.getEdgeCount());
      System.out.println(mind.attention.size() + "String_Node_Str" + IteratorUtils.toList(mind.iterateAtomsByIncreasingSTI()).size()+ "String_Node_Str"+ mind.getAtoms().size());
    }
  }
;
  m.addAgent(f);
  int cyclesToFinish=0;
  while ((targetVertices < m.getVertexCount()) || (targetEdges < m.getEdgeCount())) {
    m.cycle();
    cyclesToFinish++;
  }
  System.out.println("String_Node_Str" + cyclesToFinish + "String_Node_Str");
  printGraphSize(m);
}

Fixed version (ground truth):
public void testForget(){
  final int numVertices=1500;
  final int numEdges=3000;
  final int targetVertices=numVertices / 2;
  final int targetEdges=numEdges / 2;
  OCMind m=new OCMind();
  printMemory("String_Node_Str");
  new RandomGraphGenerator(m,numVertices,numEdges);
  assertEquals(m.getVertexCount(),numVertices);
  assertEquals(m.getEdgeCount(),numEdges);
  printMemory("String_Node_Str");
  m.cycle();
  RandomStimulation rs=new RandomStimulation(0,(short)0,numVertices * 100){
    @Override public short getBoost(){
      return (short)RandomNumber.getInt(0,127);
    }
  }
;
  m.addAgent(rs);
  m.cycle();
  m.cycle();
  printGraphSize(m);
  Forget f=new Forget(0,targetVertices,targetEdges);
  m.addAgent(f);
  int cyclesToFinish=0;
  while ((targetVertices < m.getVertexCount()) || (targetEdges < m.getEdgeCount())) {
    m.cycle();
    System.out.println("String_Node_Str" + m.getVertexCount() + "String_Node_Str"+ m.getEdgeCount());
    System.out.println("String_Node_Str" + IteratorUtils.toList(m.iterateAtomsByDecreasingSTI()).size() + "String_Node_Str"+ IteratorUtils.toList(m.iterateAtoms()).size());
    cyclesToFinish++;
  }
  System.out.println("String_Node_Str" + cyclesToFinish + "String_Node_Str");
  printGraphSize(m);
}
Program: 39705
Project: 39705
Buggy source:
@Override public void computeData(Graph g,Network n,HashMap<String,Metric> m){
  this.calculateBC(g);
  double[] cb=new double[cbs.length];
  for (int i=0; i < cbs.length; i++) {
    cb[i]=(double)cbs[i] / (double)this.spSum;
  }
  double[][] binned=gtna.util.Statistics.binnedDistribution(cb,0d,1d,100);
  betweennessCentrality=new NodeValueList("String_Node_Str",cbs);
  binnedBetwennessCentrality=new Distribution("String_Node_Str",binned);
  this.nodes=g.getNodes().length;
  this.edges=g.getEdges().size();
  this.bcMax=getMax(cbs);
  this.bcMin=getMin(cbs);
  this.bcAvg=getAvg(cbs);
  this.bcMed=getMed(cbs);
}

Fixed version (ground truth):
@Override public void computeData(Graph g,Network n,HashMap<String,Metric> m){
  this.calculateBC(g);
  double[][] binned=new double[][]{{}};
  if (this.spSum != 0) {
    double[] cb=new double[cbs.length];
    for (int i=0; i < cbs.length; i++) {
      cb[i]=(double)cbs[i] / (double)this.spSum;
    }
    binned=gtna.util.Statistics.binnedDistribution(cb,0d,1d,100);
  }
  betweennessCentrality=new NodeValueList("String_Node_Str",cbs);
  binnedBetwennessCentrality=new Distribution("String_Node_Str",binned);
  this.nodes=g.getNodes().length;
  this.edges=g.getEdges().size();
  this.bcMax=getMax(cbs);
  this.bcMin=getMin(cbs);
  this.bcAvg=getAvg(cbs);
  this.bcMed=getMed(cbs);
}
Program: 39706
Project: 39706
Buggy source:
private void computeTrustDistributions(Graph g){
  int[] trustedNodes=new int[sampleSize];
  int[] edgesInSubtree=new int[sampleSize];
  int maxTrustedNodes=0;
  int maxEdges=0;
  for (int i=0; i < sampleSize; i++) {
    Node n=getRandomNode(g);
    prepareNode(n);
    trustedNodes[i]=getNoOfTrustedNodes(n);
    edgesInSubtree[i]=getNoOfEdgesInSubtree(n);
    if (trustedNodes[i] > maxTrustedNodes)     maxTrustedNodes=trustedNodes[i];
    if (edgesInSubtree[i] > maxEdges)     maxEdges=edgesInSubtree[i];
  }
  double trustedDist[]=new double[maxTrustedNodes + 1];
  for (  int c : trustedNodes)   trustedDist[c]++;
  for (int i=0; i < trustedDist.length; i++)   trustedDist[i]/=sampleSize;
  double subtreeEdgesDist[]=new double[maxEdges + 1];
  for (  int c : edgesInSubtree)   subtreeEdgesDist[c]++;
  for (int i=0; i < subtreeEdgesDist.length; i++)   subtreeEdgesDist[i]/=sampleSize;
  trustedNodesDistribution=new Distribution("String_Node_Str",trustedDist);
  edgesInSubtreeDistribution=new Distribution("String_Node_Str",subtreeEdgesDist);
}

Fixed version (ground truth):
private void computeTrustDistributions(Graph g){
  int[] trustedNodes=new int[sampleSize];
  int[] edgesInSubtree=new int[sampleSize];
  int maxTrustedNodes=0;
  int maxEdges=0;
  double trustedDist[]=new double[maxTrustedNodes + 1];
  for (  int c : trustedNodes)   trustedDist[c]++;
  for (int i=0; i < trustedDist.length; i++)   trustedDist[i]/=sampleSize;
  double subtreeEdgesDist[]=new double[maxEdges + 1];
  for (  int c : edgesInSubtree)   subtreeEdgesDist[c]++;
  for (int i=0; i < subtreeEdgesDist.length; i++)   subtreeEdgesDist[i]/=sampleSize;
  trustedNodesDistribution=new Distribution("String_Node_Str",trustedDist);
  edgesInSubtreeDistribution=new Distribution("String_Node_Str",subtreeEdgesDist);
}
Program: 39707
Project: 39707
Buggy source:
@Override public void computeData(Graph g,Network n,HashMap<String,Metric> m){
  long t0=System.nanoTime();
  prepareGraph(g);
  long t1=System.nanoTime();
  runtimeGraphPreparation=t1 - t0;
  computeRuntimes(g);
}

Fixed version (ground truth):
@Override public void computeData(Graph g,Network n,HashMap<String,Metric> m){
  long t0=System.nanoTime();
  prepareGraph(g);
  long t1=System.nanoTime();
  runtimeGraphPreparation=t1 - t0;
  computeTrustDistributions(g);
  computeRuntimes(g);
}
Program: 39708
Project: 39708
Buggy source:
private void generateCommunitiySizes(){
  double[] sizeDist=generateSizeDistribution(min,max,ple);
  List<Integer> sizes=new ArrayList<Integer>();
  int largestC=(int)(lc * getNodes());
  if (largestC > 0)   sizes.add(largestC);
  int nodeSum=largestC;
  while (nodeSum < getNodes()) {
    int size=min;
    double z=rnd.nextDouble();
    while (z > sizeDist[size]) {
      size++;
    }
    if ((getNodes() - nodeSum) < size || (getNodes() - nodeSum - size) < min)     size=(getNodes() - nodeSum);
    sizes.add(size);
    nodeSum+=size;
  }
  communitySizes=new int[sizes.size()];
  firstNode=new int[sizes.size()];
  lastNode=new int[sizes.size()];
  for (int i=0; i < sizes.size(); i++) {
    if (i > 0)     firstNode[i]=firstNode[i - 1] + communitySizes[i - 1];
    communitySizes[i]=sizes.get(i);
    lastNode[i]=firstNode[i] + communitySizes[i] - 1;
    System.out.println(i + "String_Node_Str" + firstNode[i]+ "String_Node_Str"+ lastNode[i]);
  }
}

Fixed version (ground truth):
private void generateCommunitiySizes(){
  double[] sizeDist=generateSizeDistribution(min,max,ple);
  List<Integer> sizes=new ArrayList<Integer>();
  int largestC=(int)(lc * getNodes());
  if (largestC > 0)   sizes.add(largestC);
  int nodeSum=largestC;
  while (nodeSum < getNodes()) {
    int size=min;
    double z=rnd.nextDouble();
    while (z > sizeDist[size]) {
      size++;
    }
    if ((getNodes() - nodeSum) < size || (getNodes() - nodeSum - size) < min)     size=(getNodes() - nodeSum);
    sizes.add(size);
    nodeSum+=size;
  }
  communitySizes=new int[sizes.size()];
  firstNode=new int[sizes.size()];
  lastNode=new int[sizes.size()];
  for (int i=0; i < sizes.size(); i++) {
    if (i > 0)     firstNode[i]=firstNode[i - 1] + communitySizes[i - 1];
    communitySizes[i]=sizes.get(i);
    lastNode[i]=firstNode[i] + communitySizes[i] - 1;
  }
}