Program: 135976
Project: 135976
Buggy source:
/** 
 * Installs a new marker on the obligation in the message or updates the existing marker on that obligation (if there is one) with the information contained in message. The message location should be for a module in the currently opened spec. If no such module exists, this method returns null. Returns the marker created or updated.
 * @param message must not be null
 */
public static IMarker newObligationStatus(ObligationStatusMessage message){
  Location location=message.getLocation();
  IResource module=ResourceHelper.getResourceByModuleName(location.source());
  if (module != null && module instanceof IFile && module.exists()) {
    FileEditorInput fileEditorInput=new FileEditorInput((IFile)module);
    FileDocumentProvider fileDocumentProvider=new FileDocumentProvider();
    try {
      IMarker[] markers=module.findMarkers(OBLIGATION_MARKER,false,IResource.DEPTH_ZERO);
      IMarker marker=null;
      for (int i=0; i < markers.length; i++) {
        if (markers[i].getAttribute(OBLIGATION_ID,-1) == message.getID()) {
          marker=markers[i];
          break;
        }
      }
      if (marker == null) {
        marker=module.createMarker(OBLIGATION_MARKER);
        marker.setAttribute(OBLIGATION_ID,message.getID());
      }
      marker.setAttribute(OBLIGATION_METHOD,message.getMethod());
      marker.setAttribute(OBLIGATION_STATUS,message.getStatus());
      marker.setAttribute(OBLIGATION_STRING,message.getObString());
      fileDocumentProvider.connect(fileEditorInput);
      IDocument document=fileDocumentProvider.getDocument(fileEditorInput);
      IRegion obRegion=AdapterFactory.locationToRegion(document,location);
      marker.setAttribute(IMarker.CHAR_START,obRegion.getOffset());
      marker.setAttribute(IMarker.CHAR_END,obRegion.getOffset() + obRegion.getLength() - 1);
      return marker;
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
catch (    BadLocationException e) {
      e.printStackTrace();
    }
 finally {
      fileDocumentProvider.disconnect(fileEditorInput);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Installs a new marker on the obligation in the message or updates the existing marker on that obligation (if there is one) with the information contained in message. The message location should be for a module in the currently opened spec. If no such module exists, this method returns null. Returns the marker created or updated.
 * @param message must not be null
 */
public static IMarker newObligationStatus(ObligationStatusMessage message){
  Location location=message.getLocation();
  IResource module=ResourceHelper.getResourceByModuleName(location.source());
  if (module != null && module instanceof IFile && module.exists()) {
    FileEditorInput fileEditorInput=new FileEditorInput((IFile)module);
    FileDocumentProvider fileDocumentProvider=new FileDocumentProvider();
    try {
      IMarker[] markers=module.findMarkers(OBLIGATION_MARKER,false,IResource.DEPTH_ZERO);
      IMarker marker=null;
      for (int i=0; i < markers.length; i++) {
        if (markers[i].getAttribute(OBLIGATION_ID,-1) == message.getID()) {
          marker=markers[i];
          break;
        }
      }
      if (marker == null) {
        marker=module.createMarker(OBLIGATION_MARKER);
        marker.setAttribute(OBLIGATION_ID,message.getID());
      }
      marker.setAttribute(OBLIGATION_METHOD,message.getMethod());
      marker.setAttribute(OBLIGATION_STATUS,message.getStatus());
      marker.setAttribute(OBLIGATION_STRING,message.getObString());
      fileDocumentProvider.connect(fileEditorInput);
      IDocument document=fileDocumentProvider.getDocument(fileEditorInput);
      IRegion obRegion=AdapterFactory.locationToRegion(document,location);
      marker.setAttribute(IMarker.CHAR_START,obRegion.getOffset());
      marker.setAttribute(IMarker.CHAR_END,obRegion.getOffset() + obRegion.getLength());
      return marker;
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
catch (    BadLocationException e) {
      e.printStackTrace();
    }
 finally {
      fileDocumentProvider.disconnect(fileEditorInput);
    }
  }
  return null;
}