Program: 133669
Project: 133669
Buggy source:
/** 
 * This method attempts to create a plot   {@code Composite} for the specifiedresource. If one could be created, it will be added to the map of {@link #plotComposites}. <p> <b>Note (1):</b> This method assumes it is called from the UI thread. </p> <p> <b>Note (2):</b> If there is not a corresponding   {@link IPlot} in the mapof  {@link #plots}, no   {@code Composite} will be created.</p>
 * @param parent The parent  {@code Composite} in which to draw the new plot{@code Composite}.
 * @param resource The resource that needs a plot  {@code Composite}.
 * @return The plot {@code Composite}, or   {@code null} if one could not becreated.
 */
private Composite createPlotComposite(Composite parent,VizResource resource){
  Composite plotComposite=null;
  final String key=getPlotKey(resource);
  IPlot plot=plots.get(key);
  if (plot != null) {
    try {
      Map<String,String[]> plotTypes=plot.getPlotTypes();
      String category=null;
      String[] types=null;
      Iterator<Entry<String,String[]>> iter=plotTypes.entrySet().iterator();
      while (iter.hasNext() && (types == null || types.length == 0)) {
        Entry<String,String[]> entry=iter.next();
        category=entry.getKey();
        types=entry.getValue();
      }
      if (types != null && types.length > 0) {
        String plotType=types[0];
        try {
          FormToolkit toolkit=getManagedForm().getToolkit();
          plotComposite=toolkit.createComposite(parent);
          plotComposite.setLayout(new FillLayout());
          plotComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
          final Composite child;
          child=plot.draw(category,plotType,plotComposite);
          parent.pack();
          plotComposites.put(key,plotComposite);
          gridManager.add(plotComposite);
          child.addMouseTrackListener(closeButtonListener);
          plotComposite.addDisposeListener(new DisposeListener(){
            @Override public void widgetDisposed(            DisposeEvent e){
              Composite c=(Composite)e.widget;
              gridManager.remove(c);
              addEmptyControls(gridComposite);
              Display display=pageComposite.getDisplay();
              display.asyncExec(new Runnable(){
                @Override public void run(){
                  if (!pageComposite.isDisposed()) {
                    gridComposite.pack();
                    drawingComposite.pack();
                    pageComposite.layout();
                    child.removeMouseTrackListener(closeButtonListener);
                  }
                  return;
                }
              }
);
            }
          }
);
        }
 catch (        Exception drawException) {
          drawException.printStackTrace();
          plotComposite.dispose();
          plotComposite=null;
        }
      }
    }
 catch (    Exception plotTypeException) {
      plotTypeException.printStackTrace();
    }
  }
  return plotComposite;
}

Fixed version (ground truth):
/** 
 * This method attempts to create a plot   {@code Composite} for the specifiedresource. If one could be created, it will be added to the map of {@link #plotComposites}. <p> <b>Note (1):</b> This method assumes it is called from the UI thread. </p> <p> <b>Note (2):</b> If there is not a corresponding   {@link IPlot} in the mapof  {@link #plots}, no   {@code Composite} will be created.</p>
 * @param parent The parent  {@code Composite} in which to draw the new plot{@code Composite}.
 * @param resource The resource that needs a plot  {@code Composite}.
 * @return The plot {@code Composite}, or   {@code null} if one could not becreated.
 */
private Composite createPlotComposite(Composite parent,VizResource resource){
  Composite plotComposite=null;
  final String key=getPlotKey(resource);
  IPlot plot=plots.get(key);
  if (plot != null) {
    try {
      Map<String,String[]> plotTypes=plot.getPlotTypes();
      String category=null;
      String[] types=null;
      Iterator<Entry<String,String[]>> iter=plotTypes.entrySet().iterator();
      while (iter.hasNext() && (types == null || types.length == 0)) {
        Entry<String,String[]> entry=iter.next();
        category=entry.getKey();
        types=entry.getValue();
      }
      if (types != null && types.length > 0) {
        String plotType=types[0];
        try {
          FormToolkit toolkit=getManagedForm().getToolkit();
          plotComposite=toolkit.createComposite(parent);
          plotComposite.setLayout(new FillLayout());
          plotComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
          final Composite child;
          child=plot.draw(category,plotType,plotComposite);
          parent.pack();
          plotComposites.put(key,plotComposite);
          gridManager.add(plotComposite);
          child.addMouseTrackListener(closeButtonListener);
          plotComposite.addDisposeListener(new DisposeListener(){
            @Override public void widgetDisposed(            DisposeEvent e){
              Composite c=(Composite)e.widget;
              gridManager.remove(c);
              addEmptyControls(gridComposite);
              Display display=pageComposite.getDisplay();
              display.asyncExec(new Runnable(){
                @Override public void run(){
                  if (!pageComposite.isDisposed()) {
                    gridComposite.pack();
                    drawingComposite.pack();
                    pageComposite.layout();
                  }
                  return;
                }
              }
);
            }
          }
);
        }
 catch (        Exception drawException) {
          drawException.printStackTrace();
          plotComposite.dispose();
          plotComposite=null;
        }
      }
    }
 catch (    Exception plotTypeException) {
      plotTypeException.printStackTrace();
    }
  }
  return plotComposite;
}