Program: 140104
Project: 140104
Buggy source:
@Override public void mouseDown(MouseEvent e){
  if (e.button == 3) {
    StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
    ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
    final Indicator indicator=dataEntity.getIndicator();
    if (indicator != null) {
      Menu menu=new Menu(table.getShell(),SWT.POP_UP);
      table.setMenu(menu);
      int createPatternFlag=0;
      MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(explorer,analysis,dataEntity);
      for (      final MenuItemEntity itemEntity : itemEntities) {
        MenuItem item=new MenuItem(menu,SWT.PUSH);
        item.setText(itemEntity.getLabel());
        item.setImage(itemEntity.getIcon());
        item.addListener(SWT.Selection,new Listener(){
          public void handleEvent(          Event event){
            TdDataProvider tdDataProvider=SwitchHelpers.TDDATAPROVIDER_SWITCH.doSwitch(analysis.getContext().getConnection());
            String query=itemEntity.getQuery();
            String editorName=indicator.getName();
            CorePlugin.getDefault().runInDQViewer(tdDataProvider,query,editorName);
          }
        }
);
        if (((indicator instanceof PatternFreqIndicator || indicator instanceof PatternLowFreqIndicator)) && createPatternFlag == 0) {
          MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
          final PatternTransformer pattTransformer=new PatternTransformer(DbmsLanguageFactory.createDbmsLanguage(analysis));
          itemCreatePatt.setText("String_Node_Str");
          itemCreatePatt.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected(            SelectionEvent e){
              createPattern(analysis,itemEntity,pattTransformer);
            }
          }
);
        }
      }
      createPatternFlag++;
      menu.setVisible(true);
    }
  }
}

Fixed version (ground truth):
@Override public void mouseDown(MouseEvent e){
  if (e.button == 3) {
    StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
    ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
    if (dataEntity == null) {
      return;
    }
    final Indicator indicator=dataEntity.getIndicator();
    if (indicator != null) {
      Menu menu=new Menu(table.getShell(),SWT.POP_UP);
      table.setMenu(menu);
      int createPatternFlag=0;
      MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(explorer,analysis,dataEntity);
      for (      final MenuItemEntity itemEntity : itemEntities) {
        MenuItem item=new MenuItem(menu,SWT.PUSH);
        item.setText(itemEntity.getLabel());
        item.setImage(itemEntity.getIcon());
        item.addListener(SWT.Selection,new Listener(){
          public void handleEvent(          Event event){
            TdDataProvider tdDataProvider=SwitchHelpers.TDDATAPROVIDER_SWITCH.doSwitch(analysis.getContext().getConnection());
            String query=itemEntity.getQuery();
            String editorName=indicator.getName();
            CorePlugin.getDefault().runInDQViewer(tdDataProvider,query,editorName);
          }
        }
);
        if (((indicator instanceof PatternFreqIndicator || indicator instanceof PatternLowFreqIndicator)) && createPatternFlag == 0) {
          MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
          final PatternTransformer pattTransformer=new PatternTransformer(DbmsLanguageFactory.createDbmsLanguage(analysis));
          itemCreatePatt.setText("String_Node_Str");
          itemCreatePatt.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected(            SelectionEvent e){
              createPattern(analysis,itemEntity,pattTransformer);
            }
          }
);
        }
      }
      createPatternFlag++;
      menu.setVisible(true);
    }
  }
}