nus-yam/ex-repair huggingface dataset:
Program: 92875
Project: 92875
Buggy source:
private void processData(){
  String timeStampString=fData.get(CustomTraceDefinition.TAG_TIMESTAMP);
  String timeStampInputFormat=fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
  Date date=null;
  if (timeStampInputFormat != null && timeStampString != null) {
    SimpleDateFormat dateFormat=new SimpleDateFormat(timeStampInputFormat);
    try {
      date=dateFormat.parse(timeStampString);
      fOriginalTimestamp=fEffectiveTimestamp=new TmfTimestamp(date.getTime(),TIMESTAMP_SCALE);
    }
 catch (    ParseException e) {
      fOriginalTimestamp=fEffectiveTimestamp=TmfTimestamp.Zero;
    }
  }
 else {
    fOriginalTimestamp=fEffectiveTimestamp=TmfTimestamp.Zero;
  }
  int i=0;
  fColumnData=new String[fDefinition.outputs.size()];
  for (  OutputColumn outputColumn : fDefinition.outputs) {
    String value=fData.get(outputColumn.name);
    if (outputColumn.name.equals(CustomTraceDefinition.TAG_TIMESTAMP) && date != null) {
      SimpleDateFormat dateFormat=new SimpleDateFormat(fDefinition.timeStampOutputFormat);
      fColumnData[i++]=dateFormat.format(date);
    }
 else {
      fColumnData[i++]=value;
    }
  }
  String message=fData.get(CustomTraceDefinition.TAG_MESSAGE);
  ;
  setContent(new TmfEventContent(this,message));
  fData=null;
}

Fixed version (ground truth):
private void processData(){
  String timeStampString=fData.get(CustomTraceDefinition.TAG_TIMESTAMP);
  String timeStampInputFormat=fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
  Date date=null;
  if (timeStampInputFormat != null && timeStampString != null) {
    SimpleDateFormat dateFormat=new SimpleDateFormat(timeStampInputFormat);
    try {
      date=dateFormat.parse(timeStampString);
      fOriginalTimestamp=fEffectiveTimestamp=new TmfTimestamp(date.getTime(),TIMESTAMP_SCALE);
    }
 catch (    ParseException e) {
      fOriginalTimestamp=fEffectiveTimestamp=TmfTimestamp.Zero;
    }
  }
 else {
    fOriginalTimestamp=fEffectiveTimestamp=TmfTimestamp.Zero;
  }
  int i=0;
  fColumnData=new String[fDefinition.outputs.size()];
  for (  OutputColumn outputColumn : fDefinition.outputs) {
    String value=fData.get(outputColumn.name);
    if (outputColumn.name.equals(CustomTraceDefinition.TAG_TIMESTAMP) && date != null) {
      SimpleDateFormat dateFormat=new SimpleDateFormat(fDefinition.timeStampOutputFormat);
      fColumnData[i++]=dateFormat.format(date);
    }
 else {
      fColumnData[i++]=(value != null ? value : "String_Node_Str");
    }
  }
  fData=null;
}
Program: 92876
Project: 92876
Buggy source:
public CustomEventsTable(CustomTraceDefinition definition,Composite parent,int cacheSize){
  super(parent,cacheSize);
  fDefinition=definition;
  createColumnHeaders();
}

Fixed version (ground truth):
public CustomEventsTable(CustomTraceDefinition definition,Composite parent,int cacheSize){
  super(parent,cacheSize,new ColumnData[0]);
  fDefinition=definition;
  createColumnHeaders();
}
Program: 92878
Project: 92878
Buggy source:
@Override public TmfContext seekLocation(ITmfLocation<?> location){
  CustomTxtTraceContext context=new CustomTxtTraceContext(new TmfLocation<Long>((Long)null),ITmfContext.INITIAL_RANK);
  if (!new File(getPath()).isFile()) {
    return context;
  }
  try {
    RandomAccessFile raFile=new RandomAccessFile(getPath(),"String_Node_Str");
    if (location != null && location.getLocation() instanceof Long) {
      raFile.seek((Long)location.getLocation());
    }
    String line;
    long rawPos=raFile.getFilePointer();
    while ((line=raFile.readLine()) != null) {
      for (      InputLine input : getFirstLines()) {
        Matcher matcher=input.getPattern().matcher(line);
        if (matcher.find()) {
          context.setLocation(new TmfLocation<Long>(rawPos));
          context.raFile=raFile;
          context.firstLineMatcher=matcher;
          context.nextLineLocation=raFile.getFilePointer();
          context.inputLine=input;
          return context;
        }
      }
      rawPos=raFile.getFilePointer();
    }
    return context;
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
    return context;
  }
catch (  IOException e) {
    e.printStackTrace();
    return context;
  }
}

Fixed version (ground truth):
@Override public TmfContext seekLocation(ITmfLocation<?> location){
  CustomTxtTraceContext context=new CustomTxtTraceContext(NULL_LOCATION,ITmfContext.INITIAL_RANK);
  if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile()) {
    return context;
  }
  try {
    BufferedRandomAccessFile raFile=new BufferedRandomAccessFile(getPath(),"String_Node_Str");
    if (location != null && location.getLocation() instanceof Long) {
      raFile.seek((Long)location.getLocation());
    }
    String line;
    long rawPos=raFile.getFilePointer();
    while ((line=raFile.getNextLine()) != null) {
      for (      InputLine input : getFirstLines()) {
        Matcher matcher=input.getPattern().matcher(line);
        if (matcher.find()) {
          context.setLocation(new TmfLocation<Long>(rawPos));
          context.raFile=raFile;
          context.firstLineMatcher=matcher;
          context.firstLine=line;
          context.nextLineLocation=raFile.getFilePointer();
          context.inputLine=input;
          return context;
        }
      }
      rawPos=raFile.getFilePointer();
    }
    return context;
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
    return context;
  }
catch (  IOException e) {
    e.printStackTrace();
    return context;
  }
}
Program: 92880
Project: 92880
Buggy source:
public CustomTxtTrace(String name,CustomTxtTraceDefinition definition,String path,int cacheSize) throws FileNotFoundException {
  super(name,CustomTxtEvent.class,path,cacheSize);
  fDefinition=definition;
}

Fixed version (ground truth):
public CustomTxtTrace(String name,CustomTxtTraceDefinition definition,String path,int cacheSize) throws FileNotFoundException {
  super(name,CustomTxtEvent.class,path,cacheSize);
  fDefinition=definition;
  fEventType=new CustomTxtEventType(fDefinition);
}
Program: 92881
Project: 92881
Buggy source:
public CustomTxtEvent parseFirstLine(CustomTxtTraceContext context){
  CustomTxtEvent event=new CustomTxtEvent(fDefinition,TmfTimestamp.Zero,new TmfEventSource("String_Node_Str"),new TmfEventType(fDefinition.definitionName,new String[0]),new TmfEventReference("String_Node_Str"));
  event.processGroups(context.inputLine,context.firstLineMatcher);
  return event;
}

Fixed version (ground truth):
public CustomTxtEvent parseFirstLine(CustomTxtTraceContext context){
  CustomTxtEvent event=new CustomTxtEvent(fDefinition,TmfTimestamp.Zero,new TmfEventSource("String_Node_Str"),fEventType,new TmfEventReference("String_Node_Str"));
  event.processGroups(context.inputLine,context.firstLineMatcher);
  event.setContent(new CustomEventContent(event,new StringBuffer(context.firstLine)));
  return event;
}
Program: 92882
Project: 92882
Buggy source:
@Override public void handleCompleted(){
  final TmfTimestamp timestamp[]=new TmfTimestamp[1];
  timestamp[0]=signal.getCurrentTime();
  if (timestamp[0].compareTo(fTrace.getStartTime(),true) == -1) {
    timestamp[0]=fTrace.getStartTime();
  }
  if (timestamp[0].compareTo(fTrace.getEndTime(),true) == 1) {
    timestamp[0]=fTrace.getEndTime();
  }
  final int index=(int)fTrace.getRank(timestamp[0]);
  fTable.getDisplay().asyncExec(new Runnable(){
    @Override public void run(){
      if (fTable.isDisposed())       return;
      fTable.setSelection(index);
      if ((index >= fCacheStartIndex) && (index < fCacheEndIndex)) {
        fTable.notifyUpdatedSelection(timestamp[0]);
      }
      if ((index > 0) && (index == fTable.getTopIndex())) {
        fTable.setTopIndex(index - 1);
      }
    }
  }
);
  super.handleCompleted();
}

Fixed version (ground truth):
@Override public void handleCompleted(){
  final TmfTimestamp timestamp[]=new TmfTimestamp[1];
  timestamp[0]=signal.getCurrentTime();
  if (timestamp[0].compareTo(fTrace.getStartTime(),true) == -1) {
    timestamp[0]=fTrace.getStartTime();
  }
  if (timestamp[0].compareTo(fTrace.getEndTime(),true) == 1) {
    timestamp[0]=fTrace.getEndTime();
  }
  final int index=(int)fTrace.getRank(timestamp[0]);
  fTable.getDisplay().asyncExec(new Runnable(){
    @Override public void run(){
      if (fTable.isDisposed())       return;
      fTable.setSelection(index);
      if ((index >= fCacheStartIndex) && (index < fCacheEndIndex)) {
      }
      if ((index > 0) && (index == fTable.getTopIndex())) {
        fTable.setTopIndex(index - 1);
      }
    }
  }
);
  super.handleCompleted();
}
Program: 92883
Project: 92883
Buggy source:
@Override public void run(){
  if (!fTable.isDisposed()) {
    fTable.refresh();
    fTable.notifyUpdatedSelection();
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (!fTable.isDisposed()) {
    fTable.refresh();
  }
}
Program: 92886
Project: 92886
Buggy source:
public TmfEventsTable(Composite parent,int cacheSize,ColumnData[] columnData){
  super("String_Node_Str");
  fCacheSize=cacheSize;
  fCache=new TmfEvent[fCacheSize];
  final int style=SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER;
  fTable=new TmfVirtualTable(parent,style);
  GridData layoutData=new GridData(SWT.FILL,SWT.FILL,true,true);
  fTable.setLayoutData(layoutData);
  fTable.setHeaderVisible(true);
  fTable.setLinesVisible(true);
  setColumnHeaders(columnData);
  fTable.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      TmfTimestamp ts=(TmfTimestamp)fTable.getSelection()[0].getData();
      broadcast(new TmfTimeSynchSignal(fTable,ts));
    }
  }
);
  fTable.addListener(SWT.SetData,new Listener(){
    @Override public void handleEvent(    Event event){
      final TableItem item=(TableItem)event.item;
      final int index=fTable.indexOf(item);
      if ((index >= fCacheStartIndex) && (index < fCacheEndIndex)) {
        int i=index - fCacheStartIndex;
        item.setText(extractItemFields(fCache[i]));
        item.setData(new TmfTimestamp(fCache[i].getTimestamp()));
        return;
      }
      populateCache(index);
    }
  }
);
  fTable.setItemCount(0);
}

Fixed version (ground truth):
public TmfEventsTable(Composite parent,int cacheSize,ColumnData[] columnData){
  super("String_Node_Str");
  fCacheSize=cacheSize;
  fCache=new TmfEvent[fCacheSize];
  final int style=SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE| SWT.FULL_SELECTION;
  fTable=new TmfVirtualTable(parent,style);
  GridData layoutData=new GridData(SWT.FILL,SWT.FILL,true,true);
  fTable.setLayoutData(layoutData);
  fTable.setHeaderVisible(true);
  fTable.setLinesVisible(true);
  setColumnHeaders(columnData);
  fTable.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      TmfTimestamp ts=(TmfTimestamp)fTable.getSelection()[0].getData();
      broadcast(new TmfTimeSynchSignal(fTable,ts));
    }
  }
);
  fTable.addListener(SWT.SetData,new Listener(){
    @Override public void handleEvent(    Event event){
      final TableItem item=(TableItem)event.item;
      final int index=fTable.indexOf(item);
      if ((index >= fCacheStartIndex) && (index < fCacheEndIndex)) {
        int i=index - fCacheStartIndex;
        item.setText(extractItemFields(fCache[i]));
        item.setData(new TmfTimestamp(fCache[i].getTimestamp()));
        return;
      }
      populateCache(index);
    }
  }
);
  fTable.setItemCount(0);
}
Program: 92887
Project: 92887
Buggy source:
@Override public void handleSuccess(){
  updateTraceData();
}

Fixed version (ground truth):
@Override public void handleSuccess(){
  updateTrace();
}
Program: 92888
Project: 92888
Buggy source:
@Override public void handleData(TmfEvent event){
  super.handleData(event);
  if (event != null) {
    TmfTimestamp ts=event.getTimestamp();
    if (startTime == null) {
      startTime=new TmfTimestamp(ts);
      fStartTime=startTime;
    }
    lastTime=new TmfTimestamp(ts);
    if ((getNbRead() % fIndexPageSize) == 0) {
      updateTraceData();
    }
  }
}

Fixed version (ground truth):
@Override public void handleData(T data){
  super.handleData(data);
  eventRequest.handleData(data);
  if (getNbRead() == CHUNK_SIZE[0]) {
    nbRead[0]+=getNbRead();
  }
  if (getNbRead() > CHUNK_SIZE[0]) {
    System.out.println("String_Node_Str");
  }
}
Program: 92889
Project: 92889
Buggy source:
@Override protected void queueBackgroundRequest(final ITmfDataRequest<T> request,final int blockSize,final boolean adjust){
  super.queueBackgroundRequest(request,fIndexPageSize,true);
}

Fixed version (ground truth):
@Override protected void queueBackgroundRequest(final ITmfDataRequest<T> request,final int blockSize,final boolean indexing){
  if (!(request instanceof ITmfEventRequest<?>)) {
    super.queueRequest(request);
    return;
  }
  final ITmfEventRequest<T> eventRequest=(ITmfEventRequest<T>)request;
  Thread thread=new Thread(){
    @Override public void run(){
      final Integer[] CHUNK_SIZE=new Integer[1];
      CHUNK_SIZE[0]=blockSize + ((indexing) ? 1 : 0);
      final Integer[] nbRead=new Integer[1];
      nbRead[0]=0;
      final Boolean[] isFinished=new Boolean[1];
      isFinished[0]=Boolean.FALSE;
      while (!isFinished[0]) {
        TmfDataRequest<T> subRequest=new TmfDataRequest<T>(eventRequest.getDataType(),nbRead[0],CHUNK_SIZE[0],ExecutionType.BACKGROUND){
          @Override public void handleData(          T data){
            super.handleData(data);
            eventRequest.handleData(data);
            if (getNbRead() == CHUNK_SIZE[0]) {
              nbRead[0]+=getNbRead();
            }
            if (getNbRead() > CHUNK_SIZE[0]) {
              System.out.println("String_Node_Str");
            }
          }
          @Override public void handleCompleted(){
            if (getNbRead() < CHUNK_SIZE[0]) {
              if (isCancelled()) {
                eventRequest.cancel();
              }
 else {
                eventRequest.done();
              }
              isFinished[0]=Boolean.TRUE;
              nbRead[0]+=getNbRead();
            }
            super.handleCompleted();
          }
        }
;
        if (!isFinished[0]) {
          queueRequest(subRequest);
          try {
            subRequest.waitForCompletion();
          }
 catch (          InterruptedException e) {
            e.printStackTrace();
          }
          CHUNK_SIZE[0]=blockSize;
        }
      }
    }
  }
;
  thread.start();
}
Program: 92890
Project: 92890
Buggy source:
@SuppressWarnings({"String_Node_Str"}) private void indexTrace(boolean waitForCompletion){
  fCheckpoints.clear();
  ITmfEventRequest<TmfEvent> request=new TmfEventRequest<TmfEvent>(TmfEvent.class,TmfTimeRange.Eternity,TmfDataRequest.ALL_DATA,1,ITmfDataRequest.ExecutionType.BACKGROUND){
    TmfTimestamp startTime=null;
    TmfTimestamp lastTime=null;
    @Override public void handleData(    TmfEvent event){
      super.handleData(event);
      if (event != null) {
        TmfTimestamp ts=event.getTimestamp();
        if (startTime == null)         startTime=new TmfTimestamp(ts);
        lastTime=new TmfTimestamp(ts);
        if ((getNbRead() % DEFAULT_INDEX_PAGE_SIZE) == 0) {
          updateTrace();
        }
      }
    }
    @Override public void handleSuccess(){
      updateTrace();
    }
    private void updateTrace(){
      int nbRead=getNbRead();
      if (nbRead != 0) {
        fStartTime=startTime;
        fEndTime=lastTime;
        fNbEvents=nbRead;
        notifyListeners();
      }
    }
  }
;
  sendRequest((ITmfDataRequest<T>)request);
  if (waitForCompletion)   try {
    request.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str"}) private void indexTrace(boolean waitForCompletion){
  fCheckpoints.clear();
  ITmfEventRequest<TmfEvent> request=new TmfEventRequest<TmfEvent>(TmfEvent.class,TmfTimeRange.Eternity,TmfDataRequest.ALL_DATA,1,ITmfDataRequest.ExecutionType.BACKGROUND){
    TmfTimestamp startTime=null;
    TmfTimestamp lastTime=null;
    @Override public void handleData(    TmfEvent event){
      super.handleData(event);
      if (event != null) {
        TmfTimestamp ts=event.getTimestamp();
        if (startTime == null)         startTime=new TmfTimestamp(ts);
        lastTime=new TmfTimestamp(ts);
        if ((getNbRead() % fIndexPageSize) == 0) {
          updateTrace();
        }
      }
    }
    @Override public void handleSuccess(){
      updateTrace();
    }
    private void updateTrace(){
      int nbRead=getNbRead();
      if (nbRead != 0) {
        fStartTime=startTime;
        fEndTime=lastTime;
        fNbEvents=nbRead;
        notifyListeners();
      }
    }
  }
;
  sendRequest((ITmfDataRequest<T>)request);
  if (waitForCompletion)   try {
    request.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 92891
Project: 92891
Buggy source:
@SuppressWarnings("String_Node_Str") private void indexExperiment(boolean waitForCompletion){
  fCheckpoints.clear();
  ITmfEventRequest<TmfEvent> request=new TmfEventRequest<TmfEvent>(TmfEvent.class,TmfTimeRange.Eternity,TmfDataRequest.ALL_DATA,1,ITmfDataRequest.ExecutionType.BACKGROUND){
    TmfTimestamp startTime=null;
    TmfTimestamp lastTime=null;
    @Override public void handleData(    TmfEvent event){
      super.handleData(event);
      if (event != null) {
        TmfTimestamp ts=event.getTimestamp();
        if (startTime == null)         startTime=new TmfTimestamp(ts);
        lastTime=new TmfTimestamp(ts);
        if ((getNbRead() % fIndexPageSize) == 0) {
          updateExperiment();
        }
      }
    }
    @Override public void handleSuccess(){
      updateExperiment();
      super.handleSuccess();
    }
    private void updateExperiment(){
      int nbRead=getNbRead();
      if (nbRead != 0) {
        fTimeRange=new TmfTimeRange(startTime,new TmfTimestamp(lastTime));
        fNbEvents=nbRead;
        notifyListeners();
      }
    }
  }
;
  sendRequest((ITmfDataRequest<T>)request);
  if (waitForCompletion)   try {
    request.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") protected void indexExperiment(boolean waitForCompletion){
  final Job job=new Job("String_Node_Str" + getName() + "String_Node_Str"){
    @Override protected IStatus run(    IProgressMonitor monitor){
      while (!monitor.isCanceled()) {
        try {
          Thread.sleep(100);
        }
 catch (        InterruptedException e) {
          return Status.OK_STATUS;
        }
      }
      monitor.done();
      return Status.OK_STATUS;
    }
  }
;
  job.schedule();
  fCheckpoints.clear();
  ITmfEventRequest<TmfEvent> request=new TmfEventRequest<TmfEvent>(TmfEvent.class,TmfTimeRange.Eternity,TmfDataRequest.ALL_DATA,1,ITmfDataRequest.ExecutionType.BACKGROUND){
    TmfTimestamp startTime=null;
    TmfTimestamp lastTime=null;
    @Override public void handleData(    TmfEvent event){
      super.handleData(event);
      if (event != null) {
        TmfTimestamp ts=event.getTimestamp();
        if (startTime == null)         startTime=new TmfTimestamp(ts);
        lastTime=new TmfTimestamp(ts);
        if ((getNbRead() % fIndexPageSize) == 0) {
          updateExperiment();
        }
      }
    }
    @Override public void handleSuccess(){
      updateExperiment();
      super.handleSuccess();
    }
    @Override public void handleCompleted(){
      job.cancel();
      super.handleCompleted();
    }
    private void updateExperiment(){
      int nbRead=getNbRead();
      if (nbRead != 0) {
        fTimeRange=new TmfTimeRange(startTime,new TmfTimestamp(lastTime));
        fNbEvents=nbRead;
        notifyListeners();
      }
    }
  }
;
  sendRequest((ITmfDataRequest<T>)request);
  if (waitForCompletion)   try {
    request.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 92892
Project: 92892
Buggy source:
/** 
 * @param path
 * @param cacheSize
 * @throws FileNotFoundException
 */
protected TmfTrace(String name,Class<T> type,String path,int cacheSize) throws FileNotFoundException {
  super(name,type);
  int sep=path.lastIndexOf(File.separator);
  String simpleName=(sep >= 0) ? path.substring(sep + 1) : path;
  setName(simpleName);
  fPath=path;
  fIndexPageSize=(cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE;
}

Fixed version (ground truth):
/** 
 * @param path
 * @param cacheSize
 * @param indexTrace
 * @throws FileNotFoundException
 */
protected TmfTrace(String name,Class<T> type,String path,int cacheSize,boolean indexTrace) throws FileNotFoundException {
  super(name,type);
  int sep=path.lastIndexOf(File.separator);
  String simpleName=(sep >= 0) ? path.substring(sep + 1) : path;
  setName(simpleName);
  fPath=path;
  fIndexPageSize=(cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE;
}
Program: 92893
Project: 92893
Buggy source:
@SuppressWarnings({"String_Node_Str"}) private void indexTrace(boolean waitForCompletion){
  fCheckpoints.clear();
  ITmfEventRequest<TmfEvent> request=new TmfEventRequest<TmfEvent>(TmfEvent.class,TmfTimeRange.Eternity,TmfDataRequest.ALL_DATA,1,ITmfDataRequest.ExecutionType.BACKGROUND){
    TmfTimestamp startTime=null;
    TmfTimestamp lastTime=null;
    @Override public void handleData(    TmfEvent event){
      super.handleData(event);
      if (event != null) {
        TmfTimestamp ts=event.getTimestamp();
        if (startTime == null)         startTime=new TmfTimestamp(ts);
        lastTime=new TmfTimestamp(ts);
        if ((getNbRead() % fIndexPageSize) == 0) {
          updateTrace();
        }
      }
    }
    @Override public void handleSuccess(){
      updateTrace();
    }
    private void updateTrace(){
      int nbRead=getNbRead();
      if (nbRead != 0) {
        fStartTime=startTime;
        fEndTime=lastTime;
        fNbEvents=nbRead;
        notifyListeners();
      }
    }
  }
;
  sendRequest((ITmfDataRequest<T>)request);
  if (waitForCompletion)   try {
    request.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str"}) private void indexTrace(boolean waitForCompletion){
  final Job job=new Job("String_Node_Str" + getName() + "String_Node_Str"){
    @Override protected IStatus run(    IProgressMonitor monitor){
      while (!monitor.isCanceled()) {
        try {
          Thread.sleep(100);
        }
 catch (        InterruptedException e) {
          return Status.OK_STATUS;
        }
      }
      monitor.done();
      return Status.OK_STATUS;
    }
  }
;
  job.schedule();
  fCheckpoints.clear();
  ITmfEventRequest<TmfEvent> request=new TmfEventRequest<TmfEvent>(TmfEvent.class,TmfTimeRange.Eternity,TmfDataRequest.ALL_DATA,1,ITmfDataRequest.ExecutionType.BACKGROUND){
    TmfTimestamp startTime=null;
    TmfTimestamp lastTime=null;
    @Override public void handleData(    TmfEvent event){
      super.handleData(event);
      if (event != null) {
        TmfTimestamp ts=event.getTimestamp();
        if (startTime == null)         startTime=new TmfTimestamp(ts);
        lastTime=new TmfTimestamp(ts);
        if ((getNbRead() % fIndexPageSize) == 0) {
          updateTrace();
        }
      }
    }
    @Override public void handleSuccess(){
      updateTrace();
    }
    @Override public void handleCompleted(){
      job.cancel();
      super.handleCompleted();
    }
    private void updateTrace(){
      int nbRead=getNbRead();
      if (nbRead != 0) {
        fStartTime=startTime;
        fEndTime=lastTime;
        fNbEvents=nbRead;
        notifyListeners();
      }
    }
  }
;
  sendRequest((ITmfDataRequest<T>)request);
  if (waitForCompletion)   try {
    request.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 92897
Project: 92897
Buggy source:
@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  IResource resource=fTrace.getResource();
  if (fTrace.getParent() instanceof TmfExperimentNode) {
    resource=fTrace.getProject().getTracesFolder().getTraceForLocation(resource.getLocation()).getResource();
  }
  ITmfTrace trace=ParserProviderManager.getTrace(resource);
  if (trace == null) {
    return null;
  }
  try {
    IEditorInput editorInput=new TmfEditorInput(resource,trace);
    IWorkbench wb=PlatformUI.getWorkbench();
    IWorkbenchPage activePage=wb.getActiveWorkbenchWindow().getActivePage();
    String editorId=ParserProviderManager.getEditorId(resource);
    IEditorPart editor=activePage.findEditor(editorInput);
    if (editor != null && editor instanceof IReusableEditor) {
      activePage.reuseEditor((IReusableEditor)editor,editorInput);
      activePage.activate(editor);
    }
 else {
      editor=activePage.openEditor(editorInput,editorId);
    }
  }
 catch (  PartInitException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  IResource resource=fTrace.getResource();
  if (fTrace.getParent() instanceof TmfExperimentNode) {
    resource=fTrace.getProject().getTracesFolder().getTraceForLocation(resource.getLocation()).getResource();
  }
  ITmfTrace trace=ParserProviderManager.getTrace(resource);
  if (trace == null) {
    return null;
  }
  try {
    IEditorInput editorInput=new TmfEditorInput(resource,trace);
    IWorkbench wb=PlatformUI.getWorkbench();
    IWorkbenchPage activePage=wb.getActiveWorkbenchWindow().getActivePage();
    String editorId=ParserProviderManager.getEditorId(resource);
    if (resource instanceof IFile) {
      IDE.setDefaultEditor((IFile)resource,editorId);
    }
    IEditorPart editor=activePage.findEditor(editorInput);
    if (editor != null && editor instanceof IReusableEditor) {
      activePage.reuseEditor((IReusableEditor)editor,editorInput);
      activePage.activate(editor);
    }
 else {
      editor=activePage.openEditor(editorInput,editorId);
    }
  }
 catch (  PartInitException e) {
    e.printStackTrace();
  }
  return null;
}
Program: 92898
Project: 92898
Buggy source:
@Override protected IContributionItem[] getContributionItems(){
  Map<String,String> params;
  LinkedList<IContributionItem> list=new LinkedList<IContributionItem>();
  ParserProviderManager.getParserMap();
  for (  Entry<String,Map<String,String>> providerEntry : ParserProviderManager.getParserMap().entrySet()) {
    MenuManager subMenu=new MenuManager(providerEntry.getKey());
    for (    Entry<String,String> entry : providerEntry.getValue().entrySet()) {
      params=new HashMap<String,String>();
      params.put("String_Node_Str",entry.getValue());
      CommandContributionItemParameter param=new CommandContributionItemParameter(PlatformUI.getWorkbench().getActiveWorkbenchWindow(),"String_Node_Str","String_Node_Str",params,null,null,null,entry.getKey().replaceAll("String_Node_Str","String_Node_Str"),null,null,CommandContributionItem.STYLE_PUSH,null,true);
      subMenu.add(new CommandContributionItem(param));
    }
    list.add(subMenu);
  }
  return (IContributionItem[])list.toArray(new IContributionItem[list.size()]);
}

Fixed version (ground truth):
@Override protected IContributionItem[] getContributionItems(){
  Map<String,String> params;
  LinkedList<IContributionItem> list=new LinkedList<IContributionItem>();
  ParserProviderManager.getParserMap();
  String parser=null;
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  IWorkbenchPage page=window.getActivePage();
  ISelection selection=page.getSelection(ProjectView.ID);
  if (selection instanceof StructuredSelection) {
    Object element=((StructuredSelection)selection).getFirstElement();
    if (!(element instanceof TmfTraceNode)) {
      return new IContributionItem[0];
    }
    TmfTraceNode trace=(TmfTraceNode)element;
    IResource resource=trace.getResource();
    if (trace.getParent() instanceof TmfExperimentNode) {
      resource=trace.getProject().getTracesFolder().getTraceForLocation(resource.getLocation()).getResource();
    }
    try {
      parser=resource.getPersistentProperty(ParserProviderManager.PARSER_PROPERTY);
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
  }
  for (  Entry<String,Map<String,String>> providerEntry : ParserProviderManager.getParserMap().entrySet()) {
    MenuManager subMenu=new MenuManager(providerEntry.getKey());
    for (    Entry<String,String> entry : providerEntry.getValue().entrySet()) {
      params=new HashMap<String,String>();
      params.put("String_Node_Str",entry.getValue());
      ImageDescriptor icon=null;
      if (entry.getValue().equals(parser)) {
        icon=SELECTED_ICON;
      }
      CommandContributionItemParameter param=new CommandContributionItemParameter(PlatformUI.getWorkbench().getActiveWorkbenchWindow(),"String_Node_Str","String_Node_Str",params,icon,null,null,entry.getKey().replaceAll("String_Node_Str","String_Node_Str"),null,null,CommandContributionItem.STYLE_PUSH,null,true);
      subMenu.add(new CommandContributionItem(param));
    }
    list.add(subMenu);
  }
  return (IContributionItem[])list.toArray(new IContributionItem[list.size()]);
}
Program: 92899
Project: 92899
Buggy source:
/** 
 */
public TmfProjectLabelProvider(){
  fOpenedProjectIcon=PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
  fClosedProjectIcon=PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED);
  fFolderIcon=PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
  fTraceIcon=loadIcon(fTraceIconFile);
  fUnknownTraceIcon=PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP);
  fExperimentIcon=fFolderIcon;
}

Fixed version (ground truth):
/** 
 */
public TmfProjectLabelProvider(){
  fOpenedProjectIcon=PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
  fClosedProjectIcon=PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED);
  fFolderIcon=PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
  fTraceIcon=loadIcon(fTraceIconFile);
  fUnknownTraceIcon=TmfUiPlugin.getDefault().getImageFromPath("String_Node_Str");
  fExperimentIcon=fFolderIcon;
}
Program: 92900
Project: 92900
Buggy source:
/** 
 * Handling method for the event list. Gets the selection from the listviewer  and updates the UnitMask and event description text box. 
 */
private void _handleEventListSelectionChange(){
  int index=_eventList.getList().getSelectionIndex();
  OpEvent event=(OpEvent)_eventList.getElementAt(index);
  _counter.setEvent(event);
  _eventDescText.setText(event.getTextDescription());
  _unitMaskViewer.displayEvent(event);
  int min=_counter.getEvent().getMinCount();
  if (_counter.getCount() < min) {
    setErrorMessage(getMinCountErrorMessage(min));
  }
  updateLaunchConfigurationDialog();
}

Fixed version (ground truth):
/** 
 * Handling method for the event list. Gets the selection from the listviewer  and updates the UnitMask and event description text box. 
 */
private void _handleEventListSelectionChange(){
  int index=_eventList.getList().getSelectionIndex();
  if (index != -1) {
    OpEvent event=(OpEvent)_eventList.getElementAt(index);
    _counter.setEvent(event);
    _eventDescText.setText(event.getTextDescription());
    _unitMaskViewer.displayEvent(event);
    int min=_counter.getEvent().getMinCount();
    if (_counter.getCount() < min) {
      setErrorMessage(getMinCountErrorMessage(min));
    }
  }
  updateLaunchConfigurationDialog();
}
Program: 92901
Project: 92901
Buggy source:
/** 
 */
public void testSyntheticEventRequest(){
  init();
  IStateExperimentManager expManager=prepareExperimentContext(false);
  TmfExperiment<LttngEvent> experiment=prepareExperimentToTest();
  expManager.experimentSelected_prep(experiment);
  expManager.experimentSelected(this,experiment);
  LttngSyntheticEventProvider synProvider=LttngCoreProviderFactory.getEventProvider();
  boolean printExpectedEvents=false;
  TmfEventRequest<LttngSyntheticEvent> request1=prepareEventRequest(LttngSyntheticEvent.class,5,9,printExpectedEvents);
  TmfEventRequest<LttngSyntheticEvent> request2=prepareEventRequest(LttngSyntheticEvent.class,11,13,printExpectedEvents);
  synProvider.sendRequest(request1);
  try {
    request1.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  System.out.println("String_Node_Str" + feventCount);
  synProvider.sendRequest(request2);
  try {
    request2.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  System.out.println("String_Node_Str" + feventCount);
  assertEquals("String_Node_Str",3002,feventCount);
}

Fixed version (ground truth):
/** 
 */
public void testSyntheticEventRequest(){
}
Program: 92902
Project: 92902
Buggy source:
/** 
 */
public void testSyntheticEventRequest(){
  init();
  LttngSyntheticEventProvider synProvider=LttngCoreProviderFactory.getEventProvider();
  prepareTextExperimentToTest();
  TmfEventRequest<LttngSyntheticEvent> request=prepareEventRequest(LttngSyntheticEvent.class,0,31);
  synProvider.sendRequest(request);
  try {
    request.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  assertEquals("String_Node_Str",15316,feventCount);
}

Fixed version (ground truth):
/** 
 */
public void testSyntheticEventRequest(){
}
Program: 92903
Project: 92903
Buggy source:
/** 
 * Notify listeners to prepare to receive data e.g. clean previous data etc.
 */
public void handleProviderStarted(LttngTraceState traceModel){
  LttngSyntheticEvent startIndEvent=new LttngSyntheticEvent(fStatusEvent);
  startIndEvent.setSequenceInd(SequenceInd.STARTREQ);
  try {
    queueResult(startIndEvent);
    queueResult(fStatusEventAck);
  }
 catch (  InterruptedException e) {
  }
  fstateUpdateProcessor.process(startIndEvent,null);
}

Fixed version (ground truth):
/** 
 * Notify listeners to prepare to receive data e.g. clean previous data etc.
 */
public void handleProviderStarted(LttngTraceState traceModel){
  LttngSyntheticEvent startIndEvent=new LttngSyntheticEvent(fStatusEvent);
  startIndEvent.setSequenceInd(SequenceInd.STARTREQ);
  LttngSyntheticEvent[] result=new LttngSyntheticEvent[1];
  result[0]=startIndEvent;
  fmainRequest.setData(result);
  fmainRequest.handleData();
  result[0]=fStatusEventAck;
  fmainRequest.setData(result);
  fmainRequest.handleData();
  fstateUpdateProcessor.process(startIndEvent,null);
}
Program: 92905
Project: 92905
Buggy source:
/** 
 * Notify listeners, no more events for the current request will be distributed e.g. update view.
 */
public synchronized void handleProviderDone(LttngTraceState traceModel){
  for (  LttngBaseEventRequest subRequest : fEventProviderRequests.values()) {
    if (subRequest != null) {
      if (!subRequest.isCompleted()) {
        return;
      }
    }
  }
  LttngSyntheticEvent finishEvent=new LttngSyntheticEvent(fStatusEvent);
  finishEvent.setSequenceInd(SequenceInd.ENDREQ);
  finishEvent.setTraceModel(traceModel);
  try {
    queueResult(finishEvent);
    queueResult(fStatusEventAck);
    queueResult(LttngSyntheticEvent.NullEvent);
  }
 catch (  InterruptedException e) {
  }
}

Fixed version (ground truth):
/** 
 * Notify listeners, no more events for the current request will be distributed e.g. update view.
 */
public synchronized void handleProviderDone(LttngTraceState traceModel){
  for (  LttngBaseEventRequest subRequest : fEventProviderRequests.values()) {
    if (subRequest != null) {
      if (!subRequest.isCompleted()) {
        return;
      }
    }
  }
  LttngSyntheticEvent finishEvent=new LttngSyntheticEvent(fStatusEvent);
  finishEvent.setSequenceInd(SequenceInd.ENDREQ);
  finishEvent.setTraceModel(traceModel);
  LttngSyntheticEvent[] result=new LttngSyntheticEvent[1];
  result[0]=finishEvent;
  fmainRequest.setData(result);
  fmainRequest.handleData();
  result[0]=fStatusEventAck;
  fmainRequest.setData(result);
  fmainRequest.handleData();
  fmainRequest.done();
}
Program: 92906
Project: 92906
Buggy source:
@Override public LttngSyntheticEvent getNext(ITmfContext context) throws InterruptedException {
  return super.getNext(context);
}

Fixed version (ground truth):
@Override public LttngSyntheticEvent getNext(ITmfContext context){
  try {
    fmainRequest.waitForCompletion();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  return null;
}
Program: 92907
Project: 92907
Buggy source:
/** 
 * Trigger the Analysis and sequential control of the events.
 * @param e
 */
private void handleIncomingData(LttngEvent e){
  long eventTime=e.getTimestamp().getValue();
  TmfTrace<LttngEvent> inTrace=e.getParentTrace();
  if (!(inTrace == getTrace())) {
    return;
  }
  updateSynEvent(e);
  try {
    if (eventTime >= fDispatchTime) {
      syntheticEvent.setSequenceInd(SequenceInd.BEFORE);
      queueResult(syntheticEvent);
      queueResult(syntheticAckIndicator);
      syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
      fstateUpdateProcessor.process(syntheticEvent,fTraceModel);
      syntheticEvent.setSequenceInd(SequenceInd.AFTER);
      queueResult(syntheticEvent);
      queueResult(syntheticAckIndicator);
      incrementSynEvenCount();
      subEventCount++;
    }
 else {
      syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
      fstateUpdateProcessor.process(syntheticEvent,fTraceModel);
    }
  }
 catch (  InterruptedException e1) {
    request.cancel();
  }
}

Fixed version (ground truth):
/** 
 * Trigger the Analysis and sequential control of the events.
 * @param e
 */
private void handleIncomingData(LttngEvent e){
  long eventTime=e.getTimestamp().getValue();
  TmfTrace<LttngEvent> inTrace=e.getParentTrace();
  if (!(inTrace == getTrace())) {
    return;
  }
  updateSynEvent(e);
  if (eventTime >= fDispatchTime) {
    syntheticEvent.setSequenceInd(SequenceInd.BEFORE);
    LttngSyntheticEvent[] result=new LttngSyntheticEvent[1];
    result[0]=syntheticEvent;
    fmainRequest.setData(result);
    fmainRequest.handleData();
    result[0]=syntheticAckIndicator;
    fmainRequest.setData(result);
    fmainRequest.handleData();
    syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
    fstateUpdateProcessor.process(syntheticEvent,fTraceModel);
    syntheticEvent.setSequenceInd(SequenceInd.AFTER);
    result=new LttngSyntheticEvent[1];
    result[0]=syntheticEvent;
    fmainRequest.setData(result);
    fmainRequest.handleData();
    result[0]=syntheticAckIndicator;
    fmainRequest.setData(result);
    fmainRequest.handleData();
    incrementSynEvenCount();
    subEventCount++;
  }
 else {
    syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
    fstateUpdateProcessor.process(syntheticEvent,fTraceModel);
  }
}
Program: 92908
Project: 92908
Buggy source:
public static Test suite(){
  TestSuite suite=new TestSuite(AllLTTngCoreTests.class.getName());
  suite.addTestSuite(LttngTimestampTest.class);
  suite.addTestSuite(LttngEventFieldTest.class);
  suite.addTestSuite(LttngEventContentTest.class);
  suite.addTestSuite(LttngEventReferenceTest.class);
  suite.addTestSuite(LttngEventTypeTest.class);
  suite.addTestSuite(LttngEventTest.class);
  suite.addTestSuite(JniTraceTest.class);
  suite.addTestSuite(JniTracefileTest.class);
  suite.addTestSuite(JniEventTest.class);
  suite.addTestSuite(JniMarkerTest.class);
  suite.addTestSuite(JniMarkerFieldTest.class);
  suite.addTestSuite(LTTngTextTraceTest.class);
  suite.addTestSuite(LTTngTraceTest.class);
  suite.addTestSuite(LTTngTreeNodeTest.class);
  suite.addTestSuite(StateExperimentManagerTextTest.class);
  suite.addTestSuite(LTTngStateResourceTest.class);
  return suite;
}

Fixed version (ground truth):
public static Test suite(){
  TestSuite suite=new TestSuite(AllLTTngCoreTests.class.getName());
  suite.addTestSuite(LttngTimestampTest.class);
  suite.addTestSuite(LttngEventFieldTest.class);
  suite.addTestSuite(LttngEventContentTest.class);
  suite.addTestSuite(LttngEventReferenceTest.class);
  suite.addTestSuite(LttngEventTypeTest.class);
  suite.addTestSuite(LttngEventTest.class);
  suite.addTestSuite(JniTraceTest.class);
  suite.addTestSuite(JniTracefileTest.class);
  suite.addTestSuite(JniEventTest.class);
  suite.addTestSuite(JniMarkerTest.class);
  suite.addTestSuite(JniMarkerFieldTest.class);
  suite.addTestSuite(LTTngTextTraceTest.class);
  suite.addTestSuite(LTTngTraceTest.class);
  suite.addTestSuite(LTTngSyntheticEventProviderTest.class);
  suite.addTestSuite(LTTngSyntheticEventProviderTextTest.class);
  suite.addTestSuite(LTTngTreeNodeTest.class);
  suite.addTestSuite(StateExperimentManagerTextTest.class);
  suite.addTestSuite(LTTngStateResourceTest.class);
  return suite;
}
Program: 92909
Project: 92909
Buggy source:
/** 
 * @param zoomedTRange
 * @param experimentTRange
 */
public void dataRequest(TmfTimeRange zoomedTRange,TmfTimeRange experimentTRange,boolean clearingData){
  boolean sent=processDataRequest(zoomedTRange,experimentTRange,clearingData);
  if (sent) {
    waitCursor(true);
  }
}

Fixed version (ground truth):
/** 
 * @param zoomedTRange
 * @param experimentTRange
 * @param execType 
 */
public void dataRequest(TmfTimeRange zoomedTRange,TmfTimeRange experimentTRange,boolean clearingData,ExecutionType execType){
  boolean sent=processDataRequest(zoomedTRange,experimentTRange,clearingData,execType);
  if (sent) {
    waitCursor(true);
  }
}
Program: 92910
Project: 92910
Buggy source:
/** 
 * Process the reception of time window adjustment in this view if the source of the update is not this view.
 * @param signal
 * @param clearingData
 */
public void synchToTimeRange(TmfRangeSynchSignal signal,boolean clearingData){
  if (synch) {
    Object source=signal.getSource();
    if (signal != null && source != null && source != this) {
      TmfTimeRange trange=signal.getCurrentRange();
      TmfExperiment<?> experiment=TmfExperiment.getCurrentExperiment();
      if (experiment == null) {
        TraceDebug.debug("String_Node_Str");
        return;
      }
      dataRequest(trange,experiment.getTimeRange(),clearingData);
    }
  }
}

Fixed version (ground truth):
/** 
 * Process the reception of time window adjustment in this view if the source of the update is not this view.
 * @param signal
 * @param clearingData
 */
public void synchToTimeRange(TmfRangeSynchSignal signal,boolean clearingData){
  if (synch) {
    Object source=signal.getSource();
    if (signal != null && source != null && source != this) {
      TmfTimeRange trange=signal.getCurrentRange();
      TmfExperiment<?> experiment=TmfExperiment.getCurrentExperiment();
      if (experiment == null) {
        TraceDebug.debug("String_Node_Str");
        return;
      }
      dataRequest(trange,experiment.getTimeRange(),clearingData,ExecutionType.SHORT);
    }
  }
}
Program: 92912
Project: 92912
Buggy source:
/** 
 * @param source
 * @param experimentTRange
 * @return Adjusted time window used for the request (smaller window toinitialize view)
 */
private TmfTimeRange initialExperimentDataRequest(Object source,TmfTimeRange experimentTRange){
  TmfTimeRange initTimeWindow=getInitTRange(experimentTRange);
  dataRequest(initTimeWindow,experimentTRange,true);
  if (TraceDebug.isDEBUG()) {
    TraceDebug.debug("String_Node_Str" + initTimeWindow.getStartTime().toString() + "String_Node_Str"+ initTimeWindow.getEndTime().toString());
  }
  return initTimeWindow;
}

Fixed version (ground truth):
/** 
 * @param source
 * @param experimentTRange
 * @return Adjusted time window used for the request (smaller window toinitialize view)
 */
private TmfTimeRange initialExperimentDataRequest(Object source,TmfTimeRange experimentTRange){
  TmfTimeRange initTimeWindow=getInitTRange(experimentTRange);
  dataRequest(initTimeWindow,experimentTRange,true,ExecutionType.SHORT);
  if (TraceDebug.isDEBUG()) {
    TraceDebug.debug("String_Node_Str" + initTimeWindow.getStartTime().toString() + "String_Node_Str"+ initTimeWindow.getEndTime().toString());
  }
  return initTimeWindow;
}
Program: 92914
Project: 92914
Buggy source:
/** 
 * Compare with another timestamp
 * @param other the other timestamp
 * @param withinPrecision indicates if precision is to be take into consideration
 * @return -1: this timestamp is lower (i.e. anterior)0: timestamps are equal (within precision if requested) 1: this timestamp is higher (i.e. posterior)
 */
public int compareTo(final TmfTimestamp other,boolean withinPrecision){
  if (fScale == other.fScale) {
    if (withinPrecision) {
      if ((fValue + fPrecision) < (other.fValue - other.fPrecision))       return -1;
      if ((fValue - fPrecision) > (other.fValue + other.fPrecision))       return 1;
      return 0;
    }
    return (fValue == other.fValue) ? 0 : (fValue < other.fValue) ? -1 : 1;
  }
  byte newScale=(fScale < other.fScale) ? fScale : other.fScale;
  try {
    TmfTimestamp ts1=this.synchronize(0,newScale);
    TmfTimestamp ts2=other.synchronize(0,newScale);
    return ts1.compareTo(ts2,withinPrecision);
  }
 catch (  ArithmeticException e) {
    if ((fValue == 0) || (other.fValue == 0)) {
      return (fValue == other.fValue) ? 0 : (fValue < other.fValue) ? -1 : 1;
    }
    if ((fValue > 0) && (other.fValue > 0)) {
      return (fScale < other.fScale) ? -1 : 1;
    }
    if ((fValue < 0) && (other.fValue < 0)) {
      return (fScale > other.fScale) ? -1 : 1;
    }
    return (fValue < 0) ? -1 : 1;
  }
}

Fixed version (ground truth):
/** 
 * Compare with another timestamp
 * @param other the other timestamp
 * @param withinPrecision indicates if precision is to be take into consideration
 * @return -1: this timestamp is lower (i.e. anterior)0: timestamps are equal (within precision if requested) 1: this timestamp is higher (i.e. posterior)
 */
public int compareTo(final TmfTimestamp other,boolean withinPrecision){
  if (fScale == other.fScale) {
    if (withinPrecision) {
      if ((fValue + fPrecision) < (other.fValue - other.fPrecision))       return -1;
      if ((fValue - fPrecision) > (other.fValue + other.fPrecision))       return 1;
      return 0;
    }
    return (fValue == other.fValue) ? 0 : (fValue < other.fValue) ? -1 : 1;
  }
  if (Math.abs(fScale - other.fScale) > MAX_SCALING) {
    return simpleCompare(other);
  }
  byte newScale=(fScale < other.fScale) ? fScale : other.fScale;
  try {
    TmfTimestamp ts1=this.synchronize(0,newScale);
    TmfTimestamp ts2=other.synchronize(0,newScale);
    return ts1.compareTo(ts2,withinPrecision);
  }
 catch (  ArithmeticException e) {
    return simpleCompare(other);
  }
}