Program: 94519
Project: 94519
Buggy source:
/** 
 * Handles proper transformation of incoming <code>ColaDocumentChangeMessage</code>s. Returned <code>DocumentChangeMessage</code>s can be applied directly to the shared document. The method implements the concurrency algorithm described in <code>http://wiki.eclipse.org/RT_Shared_Editing</code>
 * @param remoteMsg 
 * @return List contains <code>DocumentChangeMessage</code>s ready for sequential application to document
 */
public List transformIncomingMessage(final DocumentChangeMessage remoteMsg){
  if (!(remoteMsg instanceof ColaDocumentChangeMessage)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Trace.entering(Activator.PLUGIN_ID,SyncDebugOptions.METHODS_ENTERING,this.getClass(),"String_Node_Str",remoteMsg);
  ColaDocumentChangeMessage transformedRemote=(ColaDocumentChangeMessage)remoteMsg;
  final List transformedRemotes=new LinkedList();
  transformedRemotes.add(transformedRemote);
  remoteOperationsCount++;
  if (!unacknowledgedLocalOperations.isEmpty()) {
    for (final Iterator it=unacknowledgedLocalOperations.iterator(); it.hasNext(); ) {
      final ColaDocumentChangeMessage unackedLocalOp=(ColaDocumentChangeMessage)it.next();
      if (transformedRemote.getRemoteOperationsCount() > unackedLocalOp.getLocalOperationsCount()) {
        Trace.trace(Activator.PLUGIN_ID,NLS.bind("String_Node_Str",unackedLocalOp));
        it.remove();
      }
 else {
        Trace.trace(Activator.PLUGIN_ID,"String_Node_Str");
        break;
      }
    }
    if (!unacknowledgedLocalOperations.isEmpty()) {
      ColaDocumentChangeMessage localOp=(ColaDocumentChangeMessage)unacknowledgedLocalOperations.getFirst();
      Assert.isTrue(transformedRemote.getRemoteOperationsCount() == localOp.getLocalOperationsCount());
      for (final ListIterator unackOpsListIt=unacknowledgedLocalOperations.listIterator(); unackOpsListIt.hasNext(); ) {
        for (final ListIterator trafoRemotesIt=transformedRemotes.listIterator(); trafoRemotesIt.hasNext(); ) {
          localOp=(ColaDocumentChangeMessage)unackOpsListIt.next();
          transformedRemote=(ColaDocumentChangeMessage)trafoRemotesIt.next();
          transformedRemote=transformedRemote.transformAgainst(localOp,isInitiator);
          if (transformedRemote.isSplitUp()) {
            trafoRemotesIt.remove();
            for (final Iterator splitUpIterator=transformedRemote.getSplitUpRepresentation().iterator(); splitUpIterator.hasNext(); ) {
              trafoRemotesIt.add(splitUpIterator.next());
            }
          }
          if (localOp.isSplitUp()) {
            unackOpsListIt.remove();
            for (final Iterator splitUpOpIterator=localOp.getSplitUpRepresentation().iterator(); splitUpOpIterator.hasNext(); ) {
              unackOpsListIt.add(splitUpOpIterator.next());
            }
          }
        }
      }
    }
  }
  Trace.exiting(Activator.PLUGIN_ID,SyncDebugOptions.METHODS_EXITING,this.getClass(),"String_Node_Str",transformedRemote);
  if (transformedRemotes.size() > 1) {
    final ColaDocumentChangeMessage firstOp=(ColaDocumentChangeMessage)transformedRemotes.get(0);
    if (firstOp.isDeletion()) {
      final ListIterator deletionFinalizerIt=transformedRemotes.listIterator();
      ColaDocumentChangeMessage previousDel=(ColaDocumentChangeMessage)deletionFinalizerIt.next();
      ColaDocumentChangeMessage currentDel;
      for (; deletionFinalizerIt.hasNext(); ) {
        currentDel=(ColaDocumentChangeMessage)deletionFinalizerIt.next();
        currentDel.setOffset(currentDel.getOffset() - previousDel.getLengthOfReplacedText());
        previousDel=currentDel;
      }
    }
  }
  return transformedRemotes;
}

Fixed version (ground truth):
/** 
 * Handles proper transformation of incoming <code>ColaDocumentChangeMessage</code>s. Returned <code>DocumentChangeMessage</code>s can be applied directly to the shared document. The method implements the concurrency algorithm described in <code>http://wiki.eclipse.org/RT_Shared_Editing</code>
 * @param remoteMsg 
 * @return List contains <code>DocumentChangeMessage</code>s ready for sequential application to document
 */
public List transformIncomingMessage(final DocumentChangeMessage remoteMsg){
  if (!(remoteMsg instanceof ColaDocumentChangeMessage)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Trace.entering(Activator.PLUGIN_ID,SyncDebugOptions.METHODS_ENTERING,this.getClass(),"String_Node_Str",remoteMsg);
  ColaDocumentChangeMessage transformedRemote=(ColaDocumentChangeMessage)remoteMsg;
  final List transformedRemotes=new LinkedList();
  transformedRemotes.add(transformedRemote);
  remoteOperationsCount++;
  Trace.trace(Activator.PLUGIN_ID,"String_Node_Str" + unacknowledgedLocalOperations);
  if (!unacknowledgedLocalOperations.isEmpty()) {
    for (final Iterator it=unacknowledgedLocalOperations.iterator(); it.hasNext(); ) {
      final ColaDocumentChangeMessage unackedLocalOp=(ColaDocumentChangeMessage)it.next();
      if (transformedRemote.getRemoteOperationsCount() > unackedLocalOp.getLocalOperationsCount()) {
        Trace.trace(Activator.PLUGIN_ID,NLS.bind("String_Node_Str",unackedLocalOp));
        it.remove();
      }
 else {
        Trace.trace(Activator.PLUGIN_ID,"String_Node_Str");
        break;
      }
    }
    if (!unacknowledgedLocalOperations.isEmpty()) {
      ColaDocumentChangeMessage localOp=(ColaDocumentChangeMessage)unacknowledgedLocalOperations.get(0);
      Assert.isTrue(transformedRemote.getRemoteOperationsCount() == localOp.getLocalOperationsCount());
      for (final ListIterator unackOpsListIt=unacknowledgedLocalOperations.listIterator(); unackOpsListIt.hasNext(); ) {
        for (final ListIterator trafoRemotesIt=transformedRemotes.listIterator(); trafoRemotesIt.hasNext(); ) {
          localOp=(ColaDocumentChangeMessage)unackOpsListIt.next();
          transformedRemote=(ColaDocumentChangeMessage)trafoRemotesIt.next();
          transformedRemote=transformedRemote.transformAgainst(localOp,isInitiator);
          if (transformedRemote.isSplitUp()) {
            trafoRemotesIt.remove();
            for (final Iterator splitUpIterator=transformedRemote.getSplitUpRepresentation().iterator(); splitUpIterator.hasNext(); ) {
              trafoRemotesIt.add(splitUpIterator.next());
            }
          }
          if (localOp.isSplitUp()) {
            unackOpsListIt.remove();
            for (final Iterator splitUpOpIterator=localOp.getSplitUpRepresentation().iterator(); splitUpOpIterator.hasNext(); ) {
              unackOpsListIt.add(splitUpOpIterator.next());
            }
          }
        }
      }
    }
  }
  Trace.exiting(Activator.PLUGIN_ID,SyncDebugOptions.METHODS_EXITING,this.getClass(),"String_Node_Str",transformedRemote);
  if (transformedRemotes.size() > 1) {
    final ColaDocumentChangeMessage firstOp=(ColaDocumentChangeMessage)transformedRemotes.get(0);
    if (firstOp.isDeletion()) {
      final ListIterator deletionFinalizerIt=transformedRemotes.listIterator();
      ColaDocumentChangeMessage previousDel=(ColaDocumentChangeMessage)deletionFinalizerIt.next();
      ColaDocumentChangeMessage currentDel;
      for (; deletionFinalizerIt.hasNext(); ) {
        currentDel=(ColaDocumentChangeMessage)deletionFinalizerIt.next();
        currentDel.setOffset(currentDel.getOffset() - previousDel.getLengthOfReplacedText());
        previousDel=currentDel;
      }
    }
  }
  return transformedRemotes;
}