Program: 139833
Project: 139833
Buggy source:
@Override public void mouseDown(MouseEvent e){
  ExecutionLanguage currentEngine=analysis.getParameters().getExecutionLanguage();
  if (e.button == 3 && ExecutionLanguage.JAVA != currentEngine) {
    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(DefaultMessagesImpl.getString("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 (table.getMenu() != null) {
    table.getMenu().setVisible(false);
  }
  ExecutionLanguage currentEngine=analysis.getParameters().getExecutionLanguage();
  if (e.button == 3 && ExecutionLanguage.JAVA != currentEngine) {
    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(DefaultMessagesImpl.getString("String_Node_Str"));
          itemCreatePatt.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected(            SelectionEvent e){
              createPattern(analysis,itemEntity,pattTransformer);
            }
          }
);
        }
      }
      createPatternFlag++;
      menu.setVisible(true);
    }
  }
}