nus-yam/ex-repair huggingface dataset:
Program: 32729
Project: 32729
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void listChanged(ListEvent listChanges){
  int stateMask=0;
  final int FILTER_RELAXED=1;
  final int FILTER_CONSTRAINED=2;
  final int FILTER_CHANGED=3;
  while (listChanges.next()) {
    int type=listChanges.getType();
    if (listChanges.isReordering()) {
    }
 else     if (type == ListEvent.UPDATE) {
      stateMask=FILTER_CHANGED;
    }
 else     if (type == ListEvent.DELETE) {
      stateMask=stateMask | FILTER_RELAXED;
    }
 else     if (type == ListEvent.INSERT) {
      stateMask=stateMask | FILTER_CONSTRAINED;
    }
  }
  if (stateMask == 0)   return;
  getReadWriteLock().writeLock().lock();
  try {
    if ((stateMask & FILTER_CHANGED) != 0) {
      handleFilterChanged();
    }
 else     if ((stateMask & FILTER_RELAXED) != 0) {
      handleFilterRelaxed();
    }
 else     if ((stateMask & FILTER_CONSTRAINED) != 0) {
      handleFilterConstrained();
    }
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void listChanged(ListEvent listChanges){
  if (listChanges.isReordering())   return;
  boolean constrained=false;
  boolean relaxed=false;
  while (listChanges.next()) {
    int type=listChanges.getType();
    if (type == ListEvent.UPDATE || type == ListEvent.DELETE)     relaxed=true;
    if (type == ListEvent.UPDATE || type == ListEvent.INSERT)     constrained=true;
  }
  getReadWriteLock().writeLock().lock();
  try {
    if (contrained && relaxed)     handleFilterChanged();
 else     if (relaxed)     handleFilterRelaxed();
 else     if (constrained)     handleFilterConstrained();
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32730
Project: 32730
Buggy source:
/** 
 * Handle a column being clicked by sorting that column.
 */
protected void columnClicked(int column,int clicks){
  ColumnClickTracker currentTracker=columnClickTrackers[column];
  if (clicks == 2) {
    for (Iterator i=recentlyClickedColumns.iterator(); i.hasNext(); ) {
      ColumnClickTracker columnClickTracker=(ColumnClickTracker)i.next();
      columnClickTracker.resetClickCount();
    }
    primaryColumn=-1;
    recentlyClickedColumns.clear();
  }
 else   if (!multipleColumnSort) {
    for (Iterator i=recentlyClickedColumns.iterator(); i.hasNext(); ) {
      ColumnClickTracker columnClickTracker=(ColumnClickTracker)i.next();
      if (columnClickTracker != currentTracker) {
        columnClickTracker.resetClickCount();
      }
    }
    primaryColumn=-1;
    recentlyClickedColumns.clear();
  }
  if (!currentTracker.getComparators().isEmpty()) {
    currentTracker.addClick();
    if (recentlyClickedColumns.isEmpty()) {
      recentlyClickedColumns.add(currentTracker);
      primaryColumn=column;
    }
 else     if (!recentlyClickedColumns.contains(currentTracker)) {
      recentlyClickedColumns.add(currentTracker);
    }
  }
  rebuildComparator();
}

Fixed version (ground truth):
/** 
 * Handle a column being clicked by sorting that column.
 */
protected void columnClicked(int column,int clicks){
  ColumnClickTracker currentTracker=columnClickTrackers[column];
  if (currentTracker.getComparators().isEmpty())   return;
  if (clicks == 2) {
    for (Iterator i=recentlyClickedColumns.iterator(); i.hasNext(); ) {
      ColumnClickTracker columnClickTracker=(ColumnClickTracker)i.next();
      columnClickTracker.resetClickCount();
    }
    primaryColumn=-1;
    recentlyClickedColumns.clear();
  }
 else   if (!multipleColumnSort) {
    for (Iterator i=recentlyClickedColumns.iterator(); i.hasNext(); ) {
      ColumnClickTracker columnClickTracker=(ColumnClickTracker)i.next();
      if (columnClickTracker != currentTracker) {
        columnClickTracker.resetClickCount();
      }
    }
    primaryColumn=-1;
    recentlyClickedColumns.clear();
  }
  currentTracker.addClick();
  if (recentlyClickedColumns.isEmpty()) {
    recentlyClickedColumns.add(currentTracker);
    primaryColumn=column;
  }
 else   if (!recentlyClickedColumns.contains(currentTracker)) {
    recentlyClickedColumns.add(currentTracker);
  }
  rebuildComparator();
}
Program: 32731
Project: 32731
Buggy source:
/** 
 * {@inheritDoc} 
 */
public int lastIndexOf(Object object){
  if (comparator != null)   return sorted.lastIndexOf(object);
 else   return source.indexOf(object);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public int lastIndexOf(Object object){
  if (comparator != null)   return sorted.lastIndexOf(object);
 else   return source.lastIndexOf(object);
}
Program: 32732
Project: 32732
Buggy source:
/** 
 * {@inheritDoc} 
 */
public boolean removeAll(Collection collection){
  boolean changed=false;
  updates.beginEvent();
  for (Iterator i=collection.iterator(); i.hasNext(); ) {
    int index=-1;
    if ((index=data.indexOf(i.next())) != -1) {
      updates.addDelete(index);
      data.remove(index);
      changed=true;
    }
  }
  updates.commitEvent();
  return changed;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public boolean removeAll(Collection collection){
  boolean changed=false;
  updates.beginEvent();
  for (Iterator i=collection.iterator(); i.hasNext(); ) {
    Object value=i.next();
    int index=-1;
    while ((index=indexOf(value)) != -1) {
      updates.addDelete(index);
      data.remove(index);
      changed=true;
    }
  }
  updates.commitEvent();
  return changed;
}
Program: 32733
Project: 32733
Buggy source:
/** 
 * {@inheritDoc} 
 */
public int lastIndexOf(Object object){
  return sorted.lastIndexOf(object);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public int lastIndexOf(Object object){
  if (comparator != null)   return sorted.lastIndexOf(object);
 else   return source.indexOf(object);
}
Program: 32734
Project: 32734
Buggy source:
/** 
 * Returns the index in this list of the first occurrence of the specified element, or the index where that element would be in the list if it were inserted.
 * @return the index in this list of the first occurrence of the specifiedelement, or the index where that element would be in the list if it were inserted. This will return a value in <tt>[0, size()]</tt>, inclusive.
 */
public int indexOfSimulated(Object object){
  return sorted.indexOfSimulated(object);
}

Fixed version (ground truth):
/** 
 * Returns the index in this list of the first occurrence of the specified element, or the index where that element would be in the list if it were inserted.
 * @return the index in this list of the first occurrence of the specifiedelement, or the index where that element would be in the list if it were inserted. This will return a value in <tt>[0, size()]</tt>, inclusive.
 */
public int indexOfSimulated(Object object){
  if (comparator != null)   return sorted.indexOfSimulated(object);
 else   return size();
}
Program: 32735
Project: 32735
Buggy source:
/** 
 * {@inheritDoc} 
 */
public int indexOf(Object object){
  return sorted.indexOf(object);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public int indexOf(Object object){
  if (comparator != null)   return sorted.indexOf(object);
 else   return source.indexOf(object);
}
Program: 32736
Project: 32736
Buggy source:
/** 
 * {@inheritDoc} 
 */
public boolean removeAll(Collection values){
  if (!isWritable())   throw new IllegalStateException("String_Node_Str");
  updates.beginEvent(true);
  boolean overallChanged=false;
  for (Iterator i=values.iterator(); i.hasNext(); ) {
    boolean removeChanged=remove(i.next());
    if (removeChanged)     overallChanged=true;
  }
  updates.commitEvent();
  return overallChanged;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public boolean removeAll(Collection collection){
  if (!isWritable())   throw new IllegalStateException("String_Node_Str");
  boolean changed=false;
  updates.beginEvent(true);
  for (Iterator i=collection.iterator(); i.hasNext(); ) {
    Object value=i.next();
    int index=-1;
    while ((index=indexOf(value)) != -1) {
      remove(index);
      changed=true;
    }
  }
  updates.commitEvent();
  return changed;
}
Program: 32737
Project: 32737
Buggy source:
/** 
 * Fires the current event. This needs to be called for each fired event exactly once, even if that event includes nested events.
 */
private void fireEvent(){
  if (atomicChangeBlocks.size() == 0) {
    atomicChangeBlocks=null;
    atomicLatestBlock=null;
    reorderMap=null;
    allowContradictingEvents=false;
    return;
  }
  ListEventBlock.sortListEventBlocks(atomicChangeBlocks,allowContradictingEvents);
  atomicChanges.add(atomicChangeBlocks);
  if (reorderMap != null && atomicChangeBlocks.size() == 2) {
    reorderMaps.add(reorderMap);
  }
 else {
    reorderMaps.add(null);
  }
  try {
    List listenersToNotify=new ArrayList();
    List listenerEventsToNotify=new ArrayList();
    listenersToNotify.addAll(listeners);
    listenerEventsToNotify.addAll(listenerEvents);
    publisher.fireEvent(sourceList,listenersToNotify,listenerEventsToNotify);
  }
  finally {
    atomicChangeBlocks=null;
    atomicLatestBlock=null;
    reorderMap=null;
    allowContradictingEvents=false;
  }
}

Fixed version (ground truth):
/** 
 * Fires the current event. This needs to be called for each fired event exactly once, even if that event includes nested events.
 */
private void fireEvent(){
  ListEventBlock.sortListEventBlocks(atomicChangeBlocks,allowContradictingEvents);
  if (atomicChangeBlocks.size() == 0) {
    atomicChangeBlocks=null;
    atomicLatestBlock=null;
    reorderMap=null;
    allowContradictingEvents=false;
    return;
  }
  atomicChanges.add(atomicChangeBlocks);
  if (reorderMap != null && atomicChangeBlocks.size() == 2) {
    reorderMaps.add(reorderMap);
  }
 else {
    reorderMaps.add(null);
  }
  try {
    List listenersToNotify=new ArrayList();
    List listenerEventsToNotify=new ArrayList();
    listenersToNotify.addAll(listeners);
    listenerEventsToNotify.addAll(listenerEvents);
    publisher.fireEvent(sourceList,listenersToNotify,listenerEventsToNotify);
  }
  finally {
    atomicChangeBlocks=null;
    atomicLatestBlock=null;
    reorderMap=null;
    allowContradictingEvents=false;
  }
}
Program: 32739
Project: 32739
Buggy source:
/** 
 * When there is a sequence of list changes, sometimes these changes are not created in increasing order. Users usually need to receive changes in increasing order, so it becomes necessary to reorder list change blocks.
 * @return true if two adjacent blocks are out of order.
 */
private static boolean requiresSwap(ListEventBlock first,ListEventBlock second){
  if (first.type == ListEvent.INSERT && second.type != ListEvent.INSERT) {
    if (first.endIndex >= second.startIndex && first.startIndex <= second.endIndex) {
      throw new IllegalStateException("String_Node_Str" + first + "String_Node_Str"+ second+ "String_Node_Str");
    }
  }
  if (second.type == ListEvent.INSERT && first.type != ListEvent.DELETE) {
    return second.startIndex <= first.startIndex;
  }
 else {
    return second.startIndex < first.startIndex;
  }
}

Fixed version (ground truth):
/** 
 * When there is a sequence of list changes, sometimes these changes are not created in increasing order. Users usually need to receive changes in increasing order, so it becomes necessary to reorder list change blocks.
 * @return true if two adjacent blocks are out of order.
 */
private static boolean requiresSwap(ListEventBlock first,ListEventBlock second){
  if (second.type == ListEvent.INSERT && first.type != ListEvent.DELETE) {
    return second.startIndex <= first.startIndex;
  }
 else {
    return second.startIndex < first.startIndex;
  }
}
Program: 32740
Project: 32740
Buggy source:
/** 
 * Validates that complex contradicting events can be nested.
 */
public void testComplexContradictingEventsAllowed(){
  List jesse=Arrays.asList(new Character[]{new Character('J'),new Character('E'),new Character('S'),new Character('S'),new Character('E')});
  List wilson=Arrays.asList(new Character[]{new Character('W'),new Character('I'),new Character('L'),new Character('S'),new Character('O'),new Character('N')});
  boolean contradictionsAllowed=true;
  nestingList.beginEvent(contradictionsAllowed);
  source.addAll(jesse);
  source.removeAll(wilson);
  nestingList.commitEvent();
  assertEquals(3,nestingList.size());
  assertEquals(3,counter.getEventCount());
}

Fixed version (ground truth):
/** 
 * Validates that complex contradicting events can be nested.
 */
public void testComplexContradictingEventsAllowed(){
  List jesse=Arrays.asList(new Character[]{new Character('J'),new Character('E'),new Character('S'),new Character('S'),new Character('E')});
  List wilson=Arrays.asList(new Character[]{new Character('W'),new Character('I'),new Character('L'),new Character('S'),new Character('O'),new Character('N')});
  boolean contradictionsAllowed=true;
  nestingList.beginEvent(contradictionsAllowed);
  source.addAll(jesse);
  source.removeAll(wilson);
  nestingList.commitEvent();
  System.out.println(nestingList);
  assertEquals(3,nestingList.size());
  assertEquals(3,counter.getEventCount());
}
Program: 32741
Project: 32741
Buggy source:
public void listChanged(ListEvent listChanges){
  updates.forwardEvent(listChanges);
}

Fixed version (ground truth):
public void listChanged(ListEvent listChanges){
  if (listChanges.isReordering()) {
    int[] reorderMap=listChanges.getReorderMap();
    updates.reorder(reorderMap);
  }
 else {
    while (listChanges.next()) {
      updates.addChange(listChanges.getType(),listChanges.getIndex());
    }
  }
}
Program: 32742
Project: 32742
Buggy source:
/** 
 * Validates that simple contradicting events can be nested.
 */
public void testSimpleContradictingEventsAllowed(){
  boolean contradictionsAllowed=true;
  nestingList.beginEvent(contradictionsAllowed);
  source.add("String_Node_Str");
  source.remove(0);
  nestingList.commitEvent();
  assertEquals(0,nestingList.size());
  assertEquals(0,counter.getEventCount());
}

Fixed version (ground truth):
/** 
 * Validates that simple contradicting events can be nested.
 */
public void testSimpleContradictingEventsAllowed(){
  boolean contradictionsAllowed=true;
  nestingList.beginEvent(false);
  source.addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  nestingList.commitEvent();
  nestingList.beginEvent(contradictionsAllowed);
  source.add(2,"String_Node_Str");
  source.add(3,"String_Node_Str");
  source.add(4,"String_Node_Str");
  source.remove(1);
  source.remove(1);
  source.remove(1);
  nestingList.commitEvent();
  assertEquals(nestingList,Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  assertEquals(2,counter.getEventCount());
  assertEquals(2,counter.getChangeCount(1));
}
Program: 32743
Project: 32743
Buggy source:
/** 
 * Validates that simple contradicting events throw an exception if not allowed.
 */
public void testSimpleContradictingEventsFail(){
  boolean contradictionsAllowed=false;
  try {
    nestingList.beginEvent(contradictionsAllowed);
    source.add("String_Node_Str");
    source.remove(0);
    nestingList.commitEvent();
    fail("String_Node_Str");
  }
 catch (  ConcurrentModificationException e) {
  }
}

Fixed version (ground truth):
/** 
 * Validates that simple contradicting events throw an exception if not allowed.
 */
public void testSimpleContradictingEventsFail(){
  boolean contradictionsAllowed=false;
  try {
    nestingList.beginEvent(contradictionsAllowed);
    source.add("String_Node_Str");
    source.remove(0);
    nestingList.commitEvent();
    fail("String_Node_Str");
  }
 catch (  IllegalStateException e) {
  }
}
Program: 32744
Project: 32744
Buggy source:
/** 
 * Validates that complex contradicting events throw an exception if not allowed.
 */
public void testComplexContradictingEventsFail(){
  List jesse=Arrays.asList(new Character[]{new Character('J'),new Character('E'),new Character('S'),new Character('S'),new Character('E')});
  List wilson=Arrays.asList(new Character[]{new Character('W'),new Character('I'),new Character('L'),new Character('S'),new Character('O'),new Character('N')});
  boolean contradictionsAllowed=false;
  try {
    nestingList.beginEvent(contradictionsAllowed);
    source.addAll(jesse);
    source.removeAll(wilson);
    nestingList.commitEvent();
    fail("String_Node_Str");
  }
 catch (  ConcurrentModificationException e) {
  }
}

Fixed version (ground truth):
/** 
 * Validates that complex contradicting events throw an exception if not allowed.
 */
public void testComplexContradictingEventsFail(){
  List jesse=Arrays.asList(new Character[]{new Character('J'),new Character('E'),new Character('S'),new Character('S'),new Character('E')});
  List wilson=Arrays.asList(new Character[]{new Character('W'),new Character('I'),new Character('L'),new Character('S'),new Character('O'),new Character('N')});
  boolean contradictionsAllowed=false;
  try {
    nestingList.beginEvent(contradictionsAllowed);
    source.addAll(jesse);
    source.removeAll(wilson);
    nestingList.commitEvent();
    fail("String_Node_Str");
  }
 catch (  IllegalStateException e) {
  }
}
Program: 32745
Project: 32745
Buggy source:
/** 
 * Test that the indexOf() and lastIndexOf() methods work if the SortedList is not actually sorted.
 */
public void testIndexOfUnsorted(){
  sortedList.setComparator(null);
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  assertEquals(0,sortedList.indexOf("String_Node_Str"));
  assertEquals(6,sortedList.lastIndexOf("String_Node_Str"));
  assertEquals(8,sortedList.indexOfSimulated("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Test that the indexOf() and lastIndexOf() methods work if the SortedList is not actually sorted.
 * @see <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=170">Bug 170</a>
 */
public void testIndexOfUnsorted(){
  sortedList.setComparator(null);
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  sortedList.add("String_Node_Str");
  assertEquals(0,sortedList.indexOf("String_Node_Str"));
  assertEquals(6,sortedList.lastIndexOf("String_Node_Str"));
  assertEquals(8,sortedList.indexOfSimulated("String_Node_Str"));
}
Program: 32747
Project: 32747
Buggy source:
/** 
 * Get this DependentList for debugging.
 */
public String toString(){
  StringBuffer result=new StringBuffer();
  result.append(listener.getClass().getName());
  result.append("String_Node_Str");
  for (Iterator i=dependencies.iterator(); i.hasNext(); ) {
    EventList dependency=(EventList)i.next();
    result.append(dependency.getClass().getName());
    if (i.hasNext())     result.append("String_Node_Str");
  }
  result.append("String_Node_Str");
  return result.toString();
}

Fixed version (ground truth):
/** 
 * Get this DependentList for debugging.
 */
public String toString(){
  StringBuffer result=new StringBuffer();
  result.append(listener.getClass().getName());
  result.append("String_Node_Str");
  for (Iterator i=dependencies.iterator(); i.hasNext(); ) {
    EventList dependency=(EventList)i.next();
    result.append("String_Node_Str").append(dependency.getClass().getName()).append("String_Node_Str");
  }
  return result.toString();
}
Program: 32748
Project: 32748
Buggy source:
/** 
 * Sets the lower threshold for this list. <p>This list can be used programmatically rather than hooking it up to a UI component. <strong>Calling this method directly while this list is connected to a particular widget could result in errors.</strong> <p><strong><font color="#FF0000">Warning:</font></strong> This method is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public void setLowerThreshold(int threshold){
  int newListIndex=0;
  if (sourceSize == 0) {
    lowerThreshold=threshold;
    lowerThresholdIndex=-1;
    return;
  }
 else   if (threshold == lowerThreshold) {
    return;
  }
 else {
    newListIndex=((SortedList)source).indexOfSimulated(new Integer(threshold));
    if (newListIndex == 0)     newListIndex=source.indexOf(new Integer(threshold));
  }
  lowerThreshold=threshold;
  if (newListIndex == lowerThresholdIndex) {
    return;
  }
  if ((newListIndex == -1 && lowerThresholdIndex == 0) || (newListIndex == 0 && lowerThresholdIndex == -1) || (newListIndex == size() && lowerThresholdIndex == size() - 1)|| (newListIndex == size() - 1 && lowerThresholdIndex == size())) {
    lowerThresholdIndex=newListIndex;
    return;
  }
  updates.beginEvent();
  if (newListIndex < lowerThresholdIndex) {
    updates.addInsert(0,Math.max(lowerThresholdIndex,0) - newListIndex - 1);
  }
 else   if (newListIndex > lowerThresholdIndex) {
    updates.addDelete(0,newListIndex - Math.max(lowerThresholdIndex,0) - 1);
  }
  lowerThresholdIndex=newListIndex;
  updates.commitEvent();
}

Fixed version (ground truth):
/** 
 * Sets the lower threshold for this list. <p>This list can be used programmatically rather than hooking it up to a UI component. <strong>Calling this method directly while this list is connected to a particular widget could result in errors.</strong> <p><strong><font color="#FF0000">Warning:</font></strong> This method is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public void setLowerThreshold(int threshold){
  int newListIndex=0;
  if (sourceSize == 0) {
    lowerThreshold=threshold;
    lowerThresholdIndex=-1;
    return;
  }
 else   if (threshold == lowerThreshold) {
    return;
  }
 else {
    newListIndex=((SortedList)source).indexOfSimulated(new Integer(threshold));
    if (newListIndex == 0)     newListIndex=source.indexOf(new Integer(threshold));
  }
  lowerThreshold=threshold;
  if (newListIndex == lowerThresholdIndex) {
    return;
  }
  if ((newListIndex == -1 && lowerThresholdIndex == 0) || (newListIndex == 0 && lowerThresholdIndex == -1)) {
    lowerThresholdIndex=newListIndex;
    return;
  }
  updates.beginEvent();
  if (newListIndex < lowerThresholdIndex) {
    updates.addInsert(0,Math.max(lowerThresholdIndex,0) - newListIndex - 1);
  }
 else   if (newListIndex > lowerThresholdIndex) {
    updates.addDelete(0,newListIndex - Math.max(lowerThresholdIndex,0) - 1);
  }
  lowerThresholdIndex=newListIndex;
  updates.commitEvent();
}
Program: 32750
Project: 32750
Buggy source:
/** 
 * Sets the upper threshold for this list. <p><strong><font color="#FF0000">Warning:</font></strong> This method is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public void setUpperThreshold(int threshold){
  int newListIndex=0;
  if (sourceSize == 0) {
    upperThreshold=threshold;
    upperThresholdIndex=-1;
    return;
  }
 else   if (threshold == upperThreshold) {
    return;
  }
 else {
    if (threshold == Integer.MAX_VALUE) {
      newListIndex=sourceSize - 1;
    }
 else {
      newListIndex=((SortedList)source).indexOfSimulated(new Integer(threshold + 1)) - 1;
    }
  }
  upperThreshold=threshold;
  if (newListIndex == upperThresholdIndex) {
    return;
  }
  if ((newListIndex == -1 && upperThresholdIndex == 0) || (newListIndex == 0 && upperThresholdIndex == -1) || (newListIndex == size() && upperThresholdIndex == size() - 1)|| (newListIndex == size() - 1 && upperThresholdIndex == size())) {
    upperThresholdIndex=newListIndex;
    return;
  }
  updates.beginEvent();
  if (newListIndex < upperThresholdIndex) {
    updates.addDelete(newListIndex + 1,upperThresholdIndex - Math.max(lowerThresholdIndex,0));
  }
 else   if (newListIndex > upperThresholdIndex) {
    updates.addInsert(upperThresholdIndex - Math.max(lowerThresholdIndex,0) + 1,newListIndex);
  }
  upperThresholdIndex=newListIndex;
  updates.commitEvent();
}

Fixed version (ground truth):
/** 
 * Sets the upper threshold for this list. <p><strong><font color="#FF0000">Warning:</font></strong> This method is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public void setUpperThreshold(int threshold){
  int newListIndex=0;
  if (sourceSize == 0) {
    upperThreshold=threshold;
    upperThresholdIndex=-1;
    return;
  }
 else   if (threshold == upperThreshold) {
    return;
  }
 else {
    if (threshold == Integer.MAX_VALUE) {
      newListIndex=sourceSize - 1;
    }
 else {
      newListIndex=((SortedList)source).indexOfSimulated(new Integer(threshold + 1)) - 1;
    }
  }
  upperThreshold=threshold;
  if (newListIndex == upperThresholdIndex) {
    return;
  }
  if ((newListIndex == size() && upperThresholdIndex == size() - 1) || (newListIndex == size() - 1 && upperThresholdIndex == size())) {
    upperThresholdIndex=newListIndex;
    return;
  }
  updates.beginEvent();
  if (newListIndex < upperThresholdIndex) {
    updates.addDelete(newListIndex + 1,upperThresholdIndex - Math.max(lowerThresholdIndex,0));
  }
 else   if (newListIndex > upperThresholdIndex) {
    updates.addInsert(upperThresholdIndex - Math.max(lowerThresholdIndex,0) + 1,newListIndex);
  }
  upperThresholdIndex=newListIndex;
  updates.commitEvent();
}
Program: 32751
Project: 32751
Buggy source:
private void remoteSubscribeConfirm(ResourceConnection publisher,PeerBlock block){
  resource.getReadWriteLock().writeLock().lock();
  try {
    System.out.print("String_Node_Str" + (block.getUpdateId()) + "String_Node_Str");
    resource.fromSnapshot(block.getPayload());
    resourceUpdateId=block.getUpdateId() - 1;
    resourceListener.resourceUpdated(resource,block.getPayload());
  }
  finally {
    resource.getReadWriteLock().writeLock().unlock();
  }
  sessionId=block.getSessionId();
  resourceStatus.setConnected(true,null);
}

Fixed version (ground truth):
private void remoteSubscribeConfirm(ResourceConnection publisher,PeerBlock block){
  resource.getReadWriteLock().writeLock().lock();
  try {
    resource.fromSnapshot(block.getPayload());
    resourceUpdateId=block.getUpdateId();
    System.err.println("String_Node_Str" + (block.getUpdateId()) + "String_Node_Str"+ resourceUpdateId+ "String_Node_Str"+ resource);
  }
  finally {
    resource.getReadWriteLock().writeLock().unlock();
  }
  sessionId=block.getSessionId();
  resourceStatus.setConnected(true,null);
}
Program: 32752
Project: 32752
Buggy source:
private void remoteUpdate(ResourceConnection publisher,PeerBlock block){
  if (block.getSessionId() != sessionId)   throw new IllegalStateException();
  resource.getReadWriteLock().writeLock().lock();
  try {
    if (block.getUpdateId() != (resourceUpdateId + 1))     throw new IllegalStateException("String_Node_Str" + (resourceUpdateId + 1) + "String_Node_Str"+ block.getUpdateId());
    resource.update(block.getPayload());
    resourceListener.resourceUpdated(resource,block.getPayload());
  }
  finally {
    resource.getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
private void remoteUpdate(ResourceConnection publisher,PeerBlock block){
  if (block.getSessionId() != sessionId)   throw new IllegalStateException();
  resource.getReadWriteLock().writeLock().lock();
  try {
    if (block.getUpdateId() != (resourceUpdateId + 1)) {
      if (block.getUpdateId() < (resourceUpdateId + 1)) {
        logger.warning("String_Node_Str" + (resourceUpdateId + 1) + "String_Node_Str"+ block.getUpdateId());
        return;
      }
 else {
        throw new IllegalStateException("String_Node_Str" + (resourceUpdateId + 1) + "String_Node_Str"+ block.getUpdateId());
      }
    }
    resource.update(block.getPayload());
    resourceListener.resourceUpdated(resource,block.getPayload());
  }
  finally {
    resource.getReadWriteLock().writeLock().unlock();
  }
}
Program: 32753
Project: 32753
Buggy source:
private void remoteSubscribe(ResourceConnection subscriber,PeerBlock block){
  if (resourceStatus.isConnected()) {
    int updateId=-1;
    Bufferlo snapshot=null;
    resource.getReadWriteLock().writeLock().lock();
    try {
      updateId=resourceUpdateId;
      snapshot=resource.toSnapshot();
    }
  finally {
      resource.getReadWriteLock().writeLock().unlock();
    }
    subscriber.setUpdateId(updateId);
    subscriber.getConnection().outgoingPublications.put(resourceUri,subscriber);
    subscribers.add(subscriber);
    PeerBlock subscribeConfirm=PeerBlock.subscribeConfirm(resourceUri,sessionId,updateId,snapshot);
    subscriber.getConnection().writeBlock(this,subscribeConfirm);
  }
 else {
    PeerBlock unpublish=PeerBlock.unpublish(resourceUri);
    subscriber.getConnection().writeBlock(this,unpublish);
    if (subscriber.getConnection().isIdle())     subscriber.getConnection().close();
  }
}

Fixed version (ground truth):
private void remoteSubscribe(ResourceConnection subscriber,PeerBlock block){
  if (resourceStatus.isConnected()) {
    int updateId=-1;
    Bufferlo snapshot=null;
    resource.getReadWriteLock().writeLock().lock();
    try {
      System.out.println("String_Node_Str" + resourceUpdateId + "String_Node_Str"+ resource);
      updateId=resourceUpdateId;
      snapshot=resource.toSnapshot();
    }
  finally {
      resource.getReadWriteLock().writeLock().unlock();
    }
    subscriber.setUpdateId(updateId);
    subscriber.getConnection().outgoingPublications.put(resourceUri,subscriber);
    subscribers.add(subscriber);
    PeerBlock subscribeConfirm=PeerBlock.subscribeConfirm(resourceUri,sessionId,updateId,snapshot);
    subscriber.getConnection().writeBlock(this,subscribeConfirm);
  }
 else {
    PeerBlock unpublish=PeerBlock.unpublish(resourceUri);
    subscriber.getConnection().writeBlock(this,unpublish);
    if (subscriber.getConnection().isIdle())     subscriber.getConnection().close();
  }
}
Program: 32754
Project: 32754
Buggy source:
/** 
 * Handles a change in a resource contained by the specified delta. This method will be called while holding the Resource's write lock.
 */
public void resourceUpdated(Resource resource,Bufferlo delta){
  resourceUpdateId++;
  peer.invokeLater(new UpdatedRunnable(delta,resourceUpdateId));
}

Fixed version (ground truth):
/** 
 * Handles a change in a resource contained by the specified delta. This method will be called while holding the Resource's write lock.
 */
public void resourceUpdated(Resource resource,Bufferlo delta){
  resourceUpdateId++;
  if (resourceUri.isLocal())   System.out.println("String_Node_Str" + resourceUpdateId + "String_Node_Str"+ resource);
 else   System.err.println("String_Node_Str" + resourceUpdateId + "String_Node_Str"+ resource);
  peer.invokeLater(new UpdatedRunnable(delta,resourceUpdateId));
}
Program: 32755
Project: 32755
Buggy source:
/** 
 * Verifies that nothing breaks when a client subscribes during a flurry of updates.
 */
public void testFrequentUpdates(){
  try {
    String path="String_Node_Str";
    NetworkList sourceList=peer.publish(new BasicEventList(),path,ByteCoderFactory.serializable());
    NetworkList targetList=peer.subscribe("String_Node_Str",serverPort,path,ByteCoderFactory.serializable());
    targetList.disconnect();
    for (int j=0; j < 5; j++) {
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      waitFor(1000);
      sourceList.clear();
      targetList.connect();
      for (int i=0; i < 25; i++) {
        sourceList.add(new Integer(i));
      }
      waitFor(1000);
      assertEquals(sourceList,targetList);
      targetList.disconnect();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Verifies that nothing breaks when a client subscribes during a flurry of updates.
 */
public void testFrequentUpdates(){
  try {
    String path="String_Node_Str";
    EventList sourceListTS=new ThreadSafeList(new BasicEventList());
    NetworkList sourceList=peer.publish(sourceListTS,path,ByteCoderFactory.serializable());
    NetworkList targetList=peer.subscribe("String_Node_Str",serverPort,path,ByteCoderFactory.serializable());
    targetList.disconnect();
    for (int j=0; j < 5; j++) {
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      waitFor(1000);
      sourceListTS.clear();
      targetList.connect();
      for (int i=0; i < 25; i++) {
        sourceListTS.add(new Integer(i));
      }
      waitFor(1000);
      assertEquals(sourceList,targetList);
      targetList.disconnect();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}
Program: 32756
Project: 32756
Buggy source:
/** 
 * Creates a   {@link ThreadSafeList} that provides thread safe access to allmethods in the source  {@link EventList}.
 */
public ThreadSafeList(EventList source){
  super(source);
  source.addListEventListener(this);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Creates a   {@link ThreadSafeList} that provides thread safe access to allmethods in the source  {@link EventList}.
 */
public ThreadSafeList(EventList source){
  super(source);
  source.addListEventListener(this);
}
Program: 32757
Project: 32757
Buggy source:
/** 
 * {@inheritDoc} 
 */
public String toString(){
  getReadWriteLock().readLock().lock();
  try {
    StringBuffer result=new StringBuffer();
    result.append("String_Node_Str");
    for (int i=0; i < size(); i++) {
      if (i != 0)       result.append("String_Node_Str");
      result.append(get(i));
    }
    result.append("String_Node_Str");
    return result.toString();
  }
  finally {
    getReadWriteLock().readLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public String toString(){
  getReadWriteLock().readLock().lock();
  try {
    return source.toString();
  }
  finally {
    getReadWriteLock().readLock().unlock();
  }
}
Program: 32758
Project: 32758
Buggy source:
/** 
 * Apply the specified list event to the specified target list. The write lock for this list must already be acquired if the list is shared between threads.
 */
public static void toListEvent(Bufferlo listEvent,EventList target,ByteCoder byteCoder) throws IOException {
  List parts=bytesToParts(listEvent,byteCoder);
  for (Iterator i=parts.iterator(); i.hasNext(); ) {
    ListEventPart part=(ListEventPart)i.next();
    System.out.print("String_Node_Str");
    if (part.isDelete()) {
      System.out.print("String_Node_Str" + part.getIndex());
      target.remove(part.getIndex());
    }
 else     if (part.isUpdate()) {
      System.out.print("String_Node_Str" + part.getIndex());
      target.set(part.getIndex(),part.getValue());
    }
 else     if (part.isInsert()) {
      System.out.print("String_Node_Str" + part.getIndex() + "String_Node_Str"+ part.getValue()+ "String_Node_Str");
      target.add(part.getIndex(),part.getValue());
    }
 else     if (part.isClear()) {
      System.out.print("String_Node_Str");
      target.clear();
    }
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Apply the specified list event to the specified target list. The write lock for this list must already be acquired if the list is shared between threads.
 */
public static void toListEvent(Bufferlo listEvent,EventList target,ByteCoder byteCoder) throws IOException {
  List parts=bytesToParts(listEvent,byteCoder);
  for (Iterator i=parts.iterator(); i.hasNext(); ) {
    ListEventPart part=(ListEventPart)i.next();
    if (part.isDelete()) {
      target.remove(part.getIndex());
    }
 else     if (part.isUpdate()) {
      target.set(part.getIndex(),part.getValue());
    }
 else     if (part.isInsert()) {
      target.add(part.getIndex(),part.getValue());
    }
 else     if (part.isClear()) {
      target.clear();
    }
  }
}
Program: 32759
Project: 32759
Buggy source:
private void remoteSubscribeConfirm(ResourceConnection publisher,PeerBlock block){
  resource.getReadWriteLock().writeLock().lock();
  try {
    resource.fromSnapshot(block.getPayload());
    resourceUpdateId=block.getUpdateId();
    System.err.println("String_Node_Str" + (block.getUpdateId()) + "String_Node_Str"+ resourceUpdateId+ "String_Node_Str"+ resource);
  }
  finally {
    resource.getReadWriteLock().writeLock().unlock();
  }
  sessionId=block.getSessionId();
  resourceStatus.setConnected(true,null);
}

Fixed version (ground truth):
private void remoteSubscribeConfirm(ResourceConnection publisher,PeerBlock block){
  resource.getReadWriteLock().writeLock().lock();
  try {
    resource.fromSnapshot(block.getPayload());
    resourceUpdateId=block.getUpdateId();
  }
  finally {
    resource.getReadWriteLock().writeLock().unlock();
  }
  sessionId=block.getSessionId();
  resourceStatus.setConnected(true,null);
}
Program: 32760
Project: 32760
Buggy source:
private void remoteSubscribe(ResourceConnection subscriber,PeerBlock block){
  if (resourceStatus.isConnected()) {
    int updateId=-1;
    Bufferlo snapshot=null;
    resource.getReadWriteLock().writeLock().lock();
    try {
      System.out.println("String_Node_Str" + resourceUpdateId + "String_Node_Str"+ resource);
      updateId=resourceUpdateId;
      snapshot=resource.toSnapshot();
    }
  finally {
      resource.getReadWriteLock().writeLock().unlock();
    }
    subscriber.setUpdateId(updateId);
    subscriber.getConnection().outgoingPublications.put(resourceUri,subscriber);
    subscribers.add(subscriber);
    PeerBlock subscribeConfirm=PeerBlock.subscribeConfirm(resourceUri,sessionId,updateId,snapshot);
    subscriber.getConnection().writeBlock(this,subscribeConfirm);
  }
 else {
    PeerBlock unpublish=PeerBlock.unpublish(resourceUri);
    subscriber.getConnection().writeBlock(this,unpublish);
    if (subscriber.getConnection().isIdle())     subscriber.getConnection().close();
  }
}

Fixed version (ground truth):
private void remoteSubscribe(ResourceConnection subscriber,PeerBlock block){
  if (resourceStatus.isConnected()) {
    int updateId=-1;
    Bufferlo snapshot=null;
    resource.getReadWriteLock().writeLock().lock();
    try {
      updateId=resourceUpdateId;
      snapshot=resource.toSnapshot();
    }
  finally {
      resource.getReadWriteLock().writeLock().unlock();
    }
    subscriber.setUpdateId(updateId);
    subscriber.getConnection().outgoingPublications.put(resourceUri,subscriber);
    subscribers.add(subscriber);
    PeerBlock subscribeConfirm=PeerBlock.subscribeConfirm(resourceUri,sessionId,updateId,snapshot);
    subscriber.getConnection().writeBlock(this,subscribeConfirm);
  }
 else {
    PeerBlock unpublish=PeerBlock.unpublish(resourceUri);
    subscriber.getConnection().writeBlock(this,unpublish);
    if (subscriber.getConnection().isIdle())     subscriber.getConnection().close();
  }
}
Program: 32761
Project: 32761
Buggy source:
/** 
 * Handles a change in a resource contained by the specified delta. This method will be called while holding the Resource's write lock.
 */
public void resourceUpdated(Resource resource,Bufferlo delta){
  resourceUpdateId++;
  if (resourceUri.isLocal())   System.out.println("String_Node_Str" + resourceUpdateId + "String_Node_Str"+ resource);
 else   System.err.println("String_Node_Str" + resourceUpdateId + "String_Node_Str"+ resource);
  peer.invokeLater(new UpdatedRunnable(delta,resourceUpdateId));
}

Fixed version (ground truth):
/** 
 * Handles a change in a resource contained by the specified delta. This method will be called while holding the Resource's write lock.
 */
public void resourceUpdated(Resource resource,Bufferlo delta){
  resourceUpdateId++;
  peer.invokeLater(new UpdatedRunnable(delta,resourceUpdateId));
}
Program: 32762
Project: 32762
Buggy source:
/** 
 * Verifies that nothing breaks when a client subscribes during a flurry of updates.
 */
public void testFrequentUpdates(){
  try {
    String path="String_Node_Str";
    EventList sourceListTS=new ThreadSafeList(new BasicEventList());
    NetworkList sourceList=peer.publish(sourceListTS,path,ByteCoderFactory.serializable());
    NetworkList targetList=peer.subscribe("String_Node_Str",serverPort,path,ByteCoderFactory.serializable());
    targetList.disconnect();
    for (int j=0; j < 5; j++) {
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      waitFor(1000);
      sourceListTS.clear();
      targetList.connect();
      for (int i=0; i < 25; i++) {
        sourceListTS.add(new Integer(i));
      }
      waitFor(1000);
      assertEquals(sourceList,targetList);
      targetList.disconnect();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Verifies that nothing breaks when a client subscribes during a flurry of updates.
 */
public void testFrequentUpdates(){
  try {
    String path="String_Node_Str";
    EventList sourceListTS=new ThreadSafeList(new BasicEventList());
    NetworkList sourceList=peer.publish(sourceListTS,path,ByteCoderFactory.serializable());
    NetworkList targetList=peer.subscribe("String_Node_Str",serverPort,path,ByteCoderFactory.serializable());
    targetList.disconnect();
    for (int j=0; j < 5; j++) {
      waitFor(1000);
      sourceListTS.clear();
      targetList.connect();
      for (int i=0; i < 25; i++) {
        sourceListTS.add(new Integer(i));
      }
      waitFor(1000);
      assertEquals(sourceList,targetList);
      targetList.disconnect();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}
Program: 32763
Project: 32763
Buggy source:
/** 
 * Gets the black index of the element with the given real index or the black index of the previous or next BLACK element if that element is WHITE.
 * @param left true for WHITE elements to return the black index of thefirst BLACK element before it in the list. Such values will range from <code>-1</code> through <code>size()-1</code>. False for WHITE elements to return the black index of the first BLACK element after it in the list. Such values will range from <code>0</code> through <code>size()</code>.
 */
public int getBlackIndex(int index,boolean left){
  if (root == null) {
    if (left)     return -1;
 else     return 0;
  }
 else   if (index >= treeSize) {
    if (left)     return treeSize - 1;
    return treeSize;
  }
 else {
    return root.getBlackIndex(index,left);
  }
}

Fixed version (ground truth):
/** 
 * Gets the black index of the element with the given real index or the black index of the previous or next BLACK element if that element is WHITE.
 * @param left true for WHITE elements to return the black index of thefirst BLACK element before it in the list. Such values will range from <code>-1</code> through <code>size()-1</code>. False for WHITE elements to return the black index of the first BLACK element after it in the list. Such values will range from <code>0</code> through <code>size()</code>.
 */
public int getBlackIndex(int index,boolean left){
  if (root == null) {
    if (left)     return -1;
 else     return 0;
  }
 else   if (index >= treeSize) {
    if (left)     return root.blackSize() - 1;
    return root.blackSize();
  }
 else {
    return root.getBlackIndex(index,left);
  }
}
Program: 32764
Project: 32764
Buggy source:
/** 
 * Get the bytes for this block.
 */
public Bufferlo getBytes(){
  Bufferlo writer=new Bufferlo();
  Map headers=new TreeMap();
  if (resourceName != null)   headers.put(RESOURCE_NAME,resourceName);
  if (sessionId != -1)   headers.put(SESSION_ID,new Integer(sessionId));
  if (action != null)   headers.put(ACTION,action);
  if (updateId != -1)   headers.put(UPDATE_ID,new Integer(updateId));
  for (Iterator i=headers.entrySet().iterator(); i.hasNext(); ) {
    Map.Entry mapEntry=(Map.Entry)i.next();
    writer.write(mapEntry.getKey().toString());
    writer.write("String_Node_Str");
    writer.write(mapEntry.getValue().toString());
    writer.write("String_Node_Str");
  }
  writer.write("String_Node_Str");
  if (payload != null) {
    writer.append(payload);
  }
  Bufferlo writerWithSize=new Bufferlo();
  writerWithSize.write("String_Node_Str" + writer.length());
  writerWithSize.write("String_Node_Str");
  writerWithSize.append(writer);
  writerWithSize.write("String_Node_Str");
  return writerWithSize;
}

Fixed version (ground truth):
/** 
 * Get the bytes for this block.
 */
public Bufferlo getBytes(){
  Bufferlo writer=new Bufferlo();
  Map headers=new TreeMap();
  if (resourceName != null)   headers.put(RESOURCE_NAME,resourceName);
  if (sessionId != -1)   headers.put(SESSION_ID,new Integer(sessionId));
  if (action != null)   headers.put(ACTION,action);
  if (updateId != -1)   headers.put(UPDATE_ID,new Integer(updateId));
  for (Iterator i=headers.entrySet().iterator(); i.hasNext(); ) {
    Map.Entry mapEntry=(Map.Entry)i.next();
    writer.write(mapEntry.getKey().toString());
    writer.write("String_Node_Str");
    writer.write(mapEntry.getValue().toString());
    writer.write("String_Node_Str");
  }
  writer.write("String_Node_Str");
  if (payload != null) {
    writer.append(payload.duplicate());
  }
  Bufferlo writerWithSize=new Bufferlo();
  writerWithSize.write("String_Node_Str" + writer.length());
  writerWithSize.write("String_Node_Str");
  writerWithSize.append(writer);
  writerWithSize.write("String_Node_Str");
  return writerWithSize;
}
Program: 32765
Project: 32765
Buggy source:
/** 
 * Starts the CTPConnectionManager listening to incoming connections and managing outgoing connections.
 * @return true if the server successfully binds to the listen port.
 */
public synchronized boolean start() throws IOException {
  if (networkThread != null)   throw new IllegalStateException();
  ServerSocketChannel serverChannel=ServerSocketChannel.open();
  ServerSocket serverSocket=serverChannel.socket();
  InetSocketAddress listenAddress=new InetSocketAddress(listenPort);
  serverSocket.bind(listenAddress);
  logger.info("String_Node_Str" + listenAddress);
  selector=Selector.open();
  serverChannel.configureBlocking(false);
  serverChannel.register(selector,SelectionKey.OP_ACCEPT);
  keepRunning=true;
  networkThread=new Thread(this,"String_Node_Str");
  networkThread.start();
  return true;
}

Fixed version (ground truth):
/** 
 * Starts the CTPConnectionManager listening to incoming connections and managing outgoing connections.
 * @return true if the server successfully binds to the listen port.
 */
public synchronized boolean start() throws IOException {
  if (networkThread != null)   throw new IllegalStateException();
  ServerSocketChannel serverChannel=ServerSocketChannel.open();
  ServerSocket serverSocket=serverChannel.socket();
  serverSocket.setReuseAddress(false);
  InetSocketAddress listenAddress=new InetSocketAddress(listenPort);
  serverSocket.bind(listenAddress);
  logger.info("String_Node_Str" + listenAddress);
  selector=Selector.open();
  serverChannel.configureBlocking(false);
  serverChannel.register(selector,SelectionKey.OP_ACCEPT);
  keepRunning=true;
  networkThread=new Thread(this,"String_Node_Str");
  networkThread.start();
  return true;
}
Program: 32766
Project: 32766
Buggy source:
/** 
 * Handles a change in a local resource contained by the specified delta.
 */
public void resourceUpdated(Resource resource,Bufferlo delta){
  updateId++;
  if (subscribers.isEmpty())   return;
  PeerBlock block=peerBlockFactory.update(updateId,delta);
  for (int s=0; s < subscribers.size(); s++) {
    PeerConnection subscriber=(PeerConnection)subscribers.get(s);
    subscriber.writeBlock(this,block);
  }
}

Fixed version (ground truth):
/** 
 * Handles a change in a local resource contained by the specified delta.
 */
public void resourceUpdated(Resource resource,Bufferlo delta){
  if (publisher == null)   updateId++;
  if (subscribers.isEmpty())   return;
  PeerBlock block=peerBlockFactory.update(updateId,delta);
  for (int s=0; s < subscribers.size(); s++) {
    PeerConnection subscriber=(PeerConnection)subscribers.get(s);
    subscriber.writeBlock(this,block);
  }
}