nus-yam/ex-repair huggingface dataset:
Program: 168398
Project: 168398
Buggy source:
/** 
 * Displays the track of the current exercise, if available. This method will be executed only once and should be called when the user wants to see the track (to prevent long startup delays).
 */
public void showTrack(){
  if (!showTrackExecuted) {
    showTrackExecuted=true;
    EVExercise exercise=getDocument().getExercise();
    if (exercise.getRecordingMode().isLocation()) {
      javax.swing.SwingUtilities.invokeLater(() -> {
        List<GeoPosition> sampleGeoPositions=createSampleGeoPositionList(exercise);
        List<GeoPosition> lapGeoPositions=createLapGeoPositionList(exercise);
        if (!sampleGeoPositions.isEmpty()) {
          setupZoomAndCenterPosition(sampleGeoPositions);
          setupTrackPainter(sampleGeoPositions,lapGeoPositions);
        }
      }
);
    }
  }
}

Fixed version (ground truth):
/** 
 * Displays the track of the current exercise, if available. This method will be executed only once and should be called when the user wants to see the track (to prevent long startup delays).
 */
public void showTrack(){
  if (!showTrackExecuted) {
    showTrackExecuted=true;
    EVExercise exercise=getDocument().getExercise();
    if (exercise.getRecordingMode().isLocation()) {
      javax.swing.SwingUtilities.invokeLater(() -> {
        List<GeoPosition> sampleGeoPositions=createSampleGeoPositionList(exercise);
        List<GeoPosition> lapGeoPositions=createLapGeoPositionList(exercise);
        if (!sampleGeoPositions.isEmpty()) {
          setupZoomAndCenterPosition(sampleGeoPositions);
          setupTrackPainter(sampleGeoPositions,lapGeoPositions);
        }
        mapKit.setVisible(true);
      }
);
    }
  }
}
Program: 168399
Project: 168399
Buggy source:
/** 
 * Cleanup of the JXMapViewer component. Needs to be called when the dialog is closed, otherwise there will be memory leaks. Normally there is nothing to do, but here are problems which are probably caused by the Swing -> JavaFX integration.
 */
public void cleanupPanel(){
  spTrack.getChildren().clear();
  snMapViewer.setContent(null);
  snMapViewer=null;
  javax.swing.SwingUtilities.invokeLater(() -> {
    mapKit.getMainMap().removeMouseMotionListener(mouseMotionListener);
    mapKit.getMainMap().setOverlayPainter(null);
    mapKit.getMainMap().setToolTipText(null);
    mapKit.getMainMap().getTileFactory().dispose();
    mapKit.getMiniMap().getTileFactory().dispose();
    mapKit=null;
  }
);
}

Fixed version (ground truth):
/** 
 * Cleanup of the JXMapViewer component, if it is displayed. Needs to be called when the dialog is closed, otherwise there will be memory leaks. Normally there is nothing to do, but here are problems which are probably caused by the Swing -> JavaFX integration.
 */
public void cleanupPanel(){
  if (mapKit != null) {
    spTrack.getChildren().clear();
    snMapViewer.setContent(null);
    snMapViewer=null;
    javax.swing.SwingUtilities.invokeLater(() -> {
      mapKit.getMainMap().removeMouseMotionListener(mouseMotionListener);
      mapKit.getMainMap().setOverlayPainter(null);
      mapKit.getMainMap().setToolTipText(null);
      mapKit.getMainMap().getTileFactory().dispose();
      mapKit.getMiniMap().getTileFactory().dispose();
      mapKit=null;
    }
);
  }
}
Program: 168400
Project: 168400
Buggy source:
private MenuItem createContextMenuItem(final String id,final String resourceKey,final EventHandler<ActionEvent> handler){
  final MenuItem menuItem=new MenuItem(getContext().getResources().getString(resourceKey));
  menuItem.setId(id);
  menuItem.setOnAction(handler);
  return menuItem;
}

Fixed version (ground truth):
private MenuItem createContextMenuItem(final String id,final String resourceKey,final EventHandler<ActionEvent> handler){
  final MenuItem menuItem=new MenuItem(getContext().getResources().getString(resourceKey));
  menuItem.setId(id);
  menuItem.setOnAction(handler);
  menuItem.getStyleClass().add("String_Node_Str");
  return menuItem;
}
Program: 168401
Project: 168401
Buggy source:
/** 
 * Removes all calendar entry selections of this day cell, except the specified calendar entry.
 * @param calendarEntryExcept entry for which the selection must not be removed (can be null)
 */
public void removeSelectionExcept(final CalendarEntry calendarEntryExcept){
  calendarEntryLabels.stream().filter(calendarEntryLabel -> calendarEntryLabel.selected.get() && !calendarEntryLabel.entry.getEntry().equals(calendarEntryExcept.getEntry())).forEach(calendarEntryLabel -> calendarEntryLabel.selected.set(false));
}

Fixed version (ground truth):
/** 
 * Removes all calendar entry selections of this day cell, except the specified calendar entry.
 * @param calendarEntryExcept entry for which the selection must not be removed (can be null)
 */
public void removeSelectionExcept(final CalendarEntry calendarEntryExcept){
  final IdObject entryExcept=calendarEntryExcept == null ? null : calendarEntryExcept.getEntry();
  calendarEntryLabels.stream().filter(entryLabel -> entryLabel.selected.get() && (entryExcept == null || !entryExcept.equals(entryLabel.entry.getEntry()))).forEach(calendarEntryLabel -> calendarEntryLabel.selected.set(false));
}
Program: 168402
Project: 168402
Buggy source:
/** 
 * Test of method evaluateCommandLineParameters().
 */
@Test public void testEvaluateCommandLineParameters(){
  final String defaultDataDirectory=System.getProperty("String_Node_Str") + "String_Node_Str";
  STDocumentImpl documentImpl=(STDocumentImpl)document;
  document.evaluateCommandLineParameters(null);
  assertEquals(defaultDataDirectory,documentImpl.getDataDirectory());
  document.evaluateCommandLineParameters(new String[]{"String_Node_Str","String_Node_Str"});
  assertEquals(defaultDataDirectory,documentImpl.getDataDirectory());
  document.evaluateCommandLineParameters(new String[]{"String_Node_Str","String_Node_Str"});
  assertEquals("String_Node_Str",documentImpl.getDataDirectory());
}

Fixed version (ground truth):
/** 
 * Test of method evaluateCommandLineParameters().
 */
@Test public void testEvaluateCommandLineParameters(){
  final String defaultDataDirectory=System.getProperty("String_Node_Str") + "String_Node_Str";
  STDocumentImpl documentImpl=(STDocumentImpl)document;
  document.evaluateCommandLineParameters(new ArrayList<>());
  assertEquals(defaultDataDirectory,documentImpl.getDataDirectory());
  document.evaluateCommandLineParameters(Arrays.asList("String_Node_Str","String_Node_Str"));
  assertEquals(defaultDataDirectory,documentImpl.getDataDirectory());
  document.evaluateCommandLineParameters(Arrays.asList("String_Node_Str","String_Node_Str"));
  assertEquals("String_Node_Str",documentImpl.getDataDirectory());
}
Program: 168403
Project: 168403
Buggy source:
/** 
 * Loads the scene object hierarchy from the specified FXML document. This is a wrapper for the   {@link FXMLLoader#load(URL,ResourceBundle)} method. It uses the passed controllerinstead of creating a new controller class specified in the FXML file. The passed controller needs to be an instance of the same class.
 * @param url URL of the FXML resource
 * @param resBundle the ResourceBundle to use for the FXML document
 * @param controller controller to be used for the loaded hierarchy
 * @return the loaded scene object hierarchy
 * @throws IOException
 */
public static Parent load(final URL url,final ResourceBundle resBundle,final Object controller) throws IOException {
  final FXMLLoader loader=new FXMLLoader();
  loader.setLocation(url);
  loader.setResources(resBundle);
  loader.setController(controller);
  return (Parent)loader.load();
}

Fixed version (ground truth):
/** 
 * Loads the scene object hierarchy from the specified FXML document. This is a wrapper for the   {@link FXMLLoader#load(URL,ResourceBundle)} method. It uses the passed controllerinstead of creating a new controller class specified in the FXML file. The passed controller needs to be an instance of the same class.
 * @param url URL of the FXML resource
 * @param resBundle the ResourceBundle to use for the FXML document
 * @param controller controller to be used for the loaded hierarchy
 * @return the loaded scene object hierarchy
 * @throws IOException
 */
public static Parent load(final URL url,final ResourceBundle resBundle,final Object controller) throws IOException {
  Objects.requireNonNull(url);
  Objects.requireNonNull(controller);
  final FXMLLoader loader=new FXMLLoader();
  loader.setLocation(url);
  loader.setResources(resBundle);
  loader.setControllerFactory(controllerClass -> {
    if (controllerClass != null && !controllerClass.isInstance(controller)) {
      throw new IllegalArgumentException("String_Node_Str" + controllerClass.getName() + "String_Node_Str");
    }
    return controller;
  }
);
  return (Parent)loader.load();
}
Program: 168404
Project: 168404
Buggy source:
/** 
 * Creates the PreferencesViewModel with JavaFX properties for the passed STOptions object.
 * @param options options to be edited
 */
public PreferencesViewModel(final STOptions options){
  this.initialView=new SimpleObjectProperty<>(options.getInitialView());
  this.defaultAutoCalculation=new SimpleObjectProperty<>(options.getDefaultAutoCalcuation());
  this.saveOnExit=new SimpleBooleanProperty(options.isSaveOnExit());
  this.unitSystem=new SimpleObjectProperty<>(options.getUnitSystem());
  this.speedView=new SimpleObjectProperty<>(options.getSpeedView());
  this.weekStart=new SimpleObjectProperty<>(options.isWeekStartSunday() ? WeekStart.SUNDAY : WeekStart.MONDAY);
  this.listViewShowAvgHeartrate=new SimpleBooleanProperty(options.isListViewShowAvgHeartrate());
  this.listViewShowAscent=new SimpleBooleanProperty(options.isListViewShowAscent());
  this.listViewShowEnergy=new SimpleBooleanProperty(options.isListViewShowEnergy());
  this.listViewShowEquipment=new SimpleBooleanProperty(options.isListViewShowEquipment());
  this.listViewShowComment=new SimpleBooleanProperty(options.isDisplaySecondDiagram());
  this.evDisplaySecondDiagram=new SimpleBooleanProperty(options.isDisplaySecondDiagram());
}

Fixed version (ground truth):
/** 
 * Creates the PreferencesViewModel with JavaFX properties for the passed STOptions object.
 * @param options options to be edited
 */
public PreferencesViewModel(final STOptions options){
  this.initialView=new SimpleObjectProperty<>(options.getInitialView());
  this.defaultAutoCalculation=new SimpleObjectProperty<>(options.getDefaultAutoCalcuation());
  this.saveOnExit=new SimpleBooleanProperty(options.isSaveOnExit());
  this.unitSystem=new SimpleObjectProperty<>(options.getUnitSystem());
  this.speedView=new SimpleObjectProperty<>(options.getSpeedView());
  this.weekStart=new SimpleObjectProperty<>(options.isWeekStartSunday() ? WeekStart.SUNDAY : WeekStart.MONDAY);
  this.listViewShowAvgHeartrate=new SimpleBooleanProperty(options.isListViewShowAvgHeartrate());
  this.listViewShowAscent=new SimpleBooleanProperty(options.isListViewShowAscent());
  this.listViewShowEnergy=new SimpleBooleanProperty(options.isListViewShowEnergy());
  this.listViewShowEquipment=new SimpleBooleanProperty(options.isListViewShowEquipment());
  this.listViewShowComment=new SimpleBooleanProperty(options.isListViewShowComment());
  this.evDisplaySecondDiagram=new SimpleBooleanProperty(options.isDisplaySecondDiagram());
}
Program: 168405
Project: 168405
Buggy source:
/** 
 * Action for open the exercise HRM file in the ExerciseViewer sub-application (dialog).
 */
@Action(name=ACTION_OPEN_EXERCISEVIEWER) public void openExerciseViewer(){
  Platform.runLater(() -> {
    final File selectedFile=prHRMFileOpenDialog.get().selectHRMFile(document.getOptions(),null);
    if (selectedFile != null) {
      SwingUtilities.invokeLater(() -> {
        EVMain pv=prExerciseViewer.get();
        pv.showExercise(selectedFile.getAbsolutePath(),document.getOptions(),false);
      }
);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Action for open the exercise HRM file in the ExerciseViewer sub-application (dialog).
 */
@Action(name=ACTION_OPEN_EXERCISEVIEWER) public void openExerciseViewer(){
  Platform.runLater(() -> {
    final File selectedFile=prHRMFileOpenDialog.get().selectHRMFile(context.getPrimaryStage(),document.getOptions(),null);
    if (selectedFile != null) {
      SwingUtilities.invokeLater(() -> {
        EVMain pv=prExerciseViewer.get();
        pv.showExercise(selectedFile.getAbsolutePath(),document.getOptions(),false);
      }
);
    }
  }
);
}
Program: 168406
Project: 168406
Buggy source:
/** 
 * Action handler for selecting an HRM exercise file in the FileChooser.
 */
@FXML private void onBrowseHrmFile(final ActionEvent event){
  final String hrmFile=StringUtils.getTrimmedTextOrNull(exerciseViewModel.hrmFile.get());
  final File selectedFile=prHRMFileOpenDialog.get().selectHRMFile(document.getOptions(),hrmFile);
  if (selectedFile != null) {
    exerciseViewModel.hrmFile.set(selectedFile.getAbsolutePath());
  }
}

Fixed version (ground truth):
/** 
 * Action handler for selecting an HRM exercise file in the FileChooser.
 */
@FXML private void onBrowseHrmFile(final ActionEvent event){
  final String hrmFile=StringUtils.getTrimmedTextOrNull(exerciseViewModel.hrmFile.get());
  final File selectedFile=prHRMFileOpenDialog.get().selectHRMFile(getWindow(tfHrmFile),document.getOptions(),hrmFile);
  if (selectedFile != null) {
    exerciseViewModel.hrmFile.set(selectedFile.getAbsolutePath());
  }
}
Program: 168407
Project: 168407
Buggy source:
/** 
 * Displays the HRM File Open dialog and returns the selected file or null when the user has nothing selected.
 * @param options the application options
 * @param initialFile the filename to be initially selected (optional)
 * @return the selected file or null when nothing selected
 */
public File selectHRMFile(final STOptions options,final String initialFile){
  final FileChooser fileChooser=new FileChooser();
  fileChooser.setTitle(context.getResReader().getString("String_Node_Str"));
  addFileExtensionFilters(fileChooser);
  final File fInitialFile=initialFile == null ? null : new File(initialFile);
  if (fInitialFile != null && fInitialFile.exists() && fInitialFile.isFile()) {
    fileChooser.setInitialDirectory(fInitialFile.getParentFile());
  }
 else {
    File initialDirectory;
    String strPreviousExerciseDirectory=options.getPreviousExerciseDirectory();
    if (strPreviousExerciseDirectory != null) {
      initialDirectory=new File(strPreviousExerciseDirectory);
    }
 else {
      initialDirectory=new File(System.getProperty("String_Node_Str"));
    }
    if (initialDirectory.exists()) {
      fileChooser.setInitialDirectory(initialDirectory);
    }
  }
  final File selectedFile=fileChooser.showOpenDialog(context.getPrimaryStage());
  if (selectedFile == null) {
    return null;
  }
  options.setPreviousExerciseDirectory(selectedFile.getParentFile().getAbsolutePath());
  return selectedFile;
}

Fixed version (ground truth):
/** 
 * Displays the HRM File Open dialog and returns the selected file or null when the user has nothing selected.
 * @param parent the parent window
 * @param options the application options
 * @param initialFile the filename to be initially selected (optional)
 * @return the selected file or null when nothing selected
 */
public File selectHRMFile(final Window parent,final STOptions options,final String initialFile){
  final FileChooser fileChooser=new FileChooser();
  fileChooser.setTitle(context.getResReader().getString("String_Node_Str"));
  addFileExtensionFilters(fileChooser);
  final File fInitialFile=initialFile == null ? null : new File(initialFile);
  if (fInitialFile != null && fInitialFile.exists() && fInitialFile.isFile()) {
    fileChooser.setInitialDirectory(fInitialFile.getParentFile());
  }
 else {
    File initialDirectory;
    String strPreviousExerciseDirectory=options.getPreviousExerciseDirectory();
    if (strPreviousExerciseDirectory != null) {
      initialDirectory=new File(strPreviousExerciseDirectory);
    }
 else {
      initialDirectory=new File(System.getProperty("String_Node_Str"));
    }
    if (initialDirectory.exists()) {
      fileChooser.setInitialDirectory(initialDirectory);
    }
  }
  final File selectedFile=fileChooser.showOpenDialog(parent);
  if (selectedFile == null) {
    return null;
  }
  options.setPreviousExerciseDirectory(selectedFile.getParentFile().getAbsolutePath());
  return selectedFile;
}
Program: 168408
Project: 168408
Buggy source:
/** 
 * Setup of the sportTypeRecordDistance property. It will be updated every time the sport type changes. When the new sport type does not record the distance, then the distance and avg speed values will be set to 0.
 */
private void setupSportTypeRecordDistance(){
  sportTypeRecordDistance.set(sportType.get().isRecordDistance());
  sportType.addListener((observable,oldValue,newValue) -> {
    sportTypeRecordDistance.set(newValue.isRecordDistance());
    if (!sportTypeRecordDistance.get()) {
      distance.set(0);
      avgSpeed.set(0);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Setup of the sportTypeRecordDistance property. It will be updated every time the sport type changes. When the new sport type does not record the distance, then the distance and avg speed values will be set to 0.
 */
private void setupSportTypeRecordDistance(){
  sportTypeRecordDistance.set(sportType.get() == null || sportType.get().isRecordDistance());
  sportType.addListener((observable,oldValue,newValue) -> {
    sportTypeRecordDistance.set(newValue.isRecordDistance());
    if (!sportTypeRecordDistance.get()) {
      distance.set(0);
      avgSpeed.set(0);
    }
  }
);
}
Program: 168409
Project: 168409
Buggy source:
/** 
 * Unfortunately it's not possible to show a modal JavaFX dialog on top of a Swing main window (JFrame). The workaround is to disable main Swing window and it's menu when the dialog is shown. And enable them again when the dialog has been closed.
 * @param dialog Dialog
 */
private void fakeModalDialog(final Dialog dialog){
  final javax.swing.JFrame swingMainFrame=context.getMainFrame();
  dialog.getWindow().setOnShown(e -> {
    swingMainFrame.setEnabled(false);
    swingMainFrame.getJMenuBar().setEnabled(false);
  }
);
  dialog.getWindow().setOnHidden(e -> {
    swingMainFrame.setEnabled(true);
    swingMainFrame.getJMenuBar().setEnabled(true);
    swingMainFrame.toFront();
  }
);
}

Fixed version (ground truth):
/** 
 * Unfortunately it's not possible to show a modal JavaFX dialog on top of a Swing main window (JFrame). The workaround is to disable main Swing window and it's menu when the dialog is shown. And enable them again when the dialog has been closed.
 * @param dialog Dialog
 */
private void fakeModalDialog(final Dialog dialog){
  final javax.swing.JFrame swingMainFrame=context.getMainFrame();
  dialog.getWindow().setOnShown(e -> {
    javax.swing.SwingUtilities.invokeLater(() -> {
      swingMainFrame.setEnabled(false);
      swingMainFrame.getJMenuBar().setEnabled(false);
    }
);
  }
);
  dialog.getWindow().setOnHidden(e -> {
    javax.swing.SwingUtilities.invokeLater(() -> {
      swingMainFrame.setEnabled(true);
      swingMainFrame.getJMenuBar().setEnabled(true);
      swingMainFrame.toFront();
    }
);
  }
);
}
Program: 168412
Project: 168412
Buggy source:
/** 
 * Updates the state of the selection widgets for the diagram content.
 */
private void updateSelectionControlsState(){
  spYear.setVisible(getCurrentTimeRangeType() != TimeRangeType.LAST_12_MONTHS);
  boolean sssEnabled=getCurrentValueType() != ValueType.WEIGHT;
  laFor.setVisible(sssEnabled);
  cbSportTypeMode.setVisible(sssEnabled);
  cbSportTypeList.setVisible(sssEnabled);
  if (sssEnabled) {
    boolean equipmentSelected=getCurrentValueType() == ValueType.EQUIPMENT;
    laFor.setText(context.getResReader().getString(!equipmentSelected ? "String_Node_Str" : "String_Node_Str"));
    cbSportTypeMode.setVisible(!equipmentSelected);
    cbSportTypeList.setVisible(equipmentSelected);
  }
}

Fixed version (ground truth):
/** 
 * Updates the state of the selection widgets for the diagram content.
 */
private void updateSelectionControlsState(){
  spYear.setVisible(getCurrentTimeRangeType() != TimeRangeType.LAST_12_MONTHS);
  boolean sssEnabled=getCurrentValueType() != ValueType.WEIGHT;
  laFor.setVisible(sssEnabled);
  cbSportTypeMode.setVisible(sssEnabled);
  cbSportTypeList.setVisible(sssEnabled);
  if (sssEnabled) {
    boolean showSportTypeModes=getCurrentValueType() != ValueType.SPORTSUBTYPE && getCurrentValueType() != ValueType.EQUIPMENT;
    laFor.setText(context.getResReader().getString(showSportTypeModes ? "String_Node_Str" : "String_Node_Str"));
    cbSportTypeMode.setVisible(showSportTypeModes);
    cbSportTypeList.setVisible(!showSportTypeModes);
  }
}
Program: 168414
Project: 168414
Buggy source:
/** 
 * Returns the cell component for the specified value and position. 
 */
@Override public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int rowIndex,int vColIndex){
  Component component=super.getTableCellRendererComponent(table,value,isSelected,hasFocus,rowIndex,vColIndex);
  String text=null;
switch (vColIndex) {
case COLUMN_LAP:
    text=value.toString();
  break;
case COLUMN_LAP_TIME:
case COLUMN_SPLIT_TIME:
text=formatUtils.tenthSeconds2TimeString((Integer)value);
break;
case COLUMN_HEARTRATE:
case COLUMN_AVG_HEARTRATE:
case COLUMN_MAX_HEARTRATE:
text=formatUtils.heartRateToString((Short)value);
break;
case COLUMN_END_SPEED:
case COLUMN_AVG_SPEED:
if (value != null) {
text=formatUtils.speedToString((Float)value,2);
}
break;
case COLUMN_DISTANCE:
if (value != null) {
text=formatUtils.distanceToString((Integer)value / 1000f,3);
}
break;
case COLUMN_CADENCE:
if (value != null) {
text=formatUtils.cadenceToString((Short)value);
}
break;
case COLUMN_ALTITUDE:
if (value != null) {
text=formatUtils.heightToString((Short)value);
}
break;
case COLUMN_ASCENT:
if (value != null) {
text=formatUtils.heightToString((Integer)value);
}
break;
case COLUMN_TEMPERATURE:
if (value != null) {
text=formatUtils.temperatureToString((Short)value);
}
break;
}
setText(text);
return component;
}

Fixed version (ground truth):
/** 
 * Returns the cell component for the specified value and position. 
 */
@Override public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int rowIndex,int vColIndex){
  Component component=super.getTableCellRendererComponent(table,value,isSelected,hasFocus,rowIndex,vColIndex);
  String text=null;
switch (vColIndex) {
case COLUMN_LAP:
    text=value.toString();
  break;
case COLUMN_LAP_TIME:
case COLUMN_SPLIT_TIME:
text=formatUtils.tenthSeconds2TimeString((Integer)value);
break;
case COLUMN_HEARTRATE:
case COLUMN_AVG_HEARTRATE:
case COLUMN_MAX_HEARTRATE:
text=formatUtils.heartRateToString((Short)value);
break;
case COLUMN_END_SPEED:
case COLUMN_AVG_SPEED:
if (value != null) {
text=formatUtils.speedToString((Float)value,2);
}
break;
case COLUMN_DISTANCE:
if (value != null) {
text=formatUtils.distanceToString((Integer)value / 1000f,3);
}
break;
case COLUMN_CADENCE:
if (value != null) {
text=formatUtils.cadenceToString((Short)value);
}
break;
case COLUMN_ALTITUDE:
if (value != null) {
text=formatUtils.heightToString((Short)value);
}
break;
case COLUMN_ASCENT:
if (value != null) {
text=formatUtils.heightToString((Integer)value);
}
break;
case COLUMN_TEMPERATURE:
if (value != null) {
text=formatUtils.temperatureToString((Short)value);
}
break;
default :
throw new IllegalArgumentException("String_Node_Str" + vColIndex);
}
setText(text);
return component;
}
Program: 168416
Project: 168416
Buggy source:
@Override public Object getValueAt(int row,int col){
  ExerciseSample sample=exercise.getSampleList()[row];
switch (col) {
case COLUMN_TIME:
    return Integer.valueOf((int)(sample.getTimestamp() / 1000));
case COLUMN_HEARTRATE:
  return Short.valueOf(sample.getHeartRate());
case COLUMN_ALTITUDE:
if (exercise.getRecordingMode().isAltitude()) {
  return Short.valueOf(sample.getAltitude());
}
break;
case COLUMN_SPEED:
if (exercise.getRecordingMode().isSpeed()) {
return new Float(sample.getSpeed());
}
break;
case COLUMN_DISTANCE:
if (exercise.getRecordingMode().isSpeed()) {
return Integer.valueOf(sample.getDistance());
}
break;
case COLUMN_CADENCE:
if (exercise.getRecordingMode().isCadence()) {
return Short.valueOf(sample.getCadence());
}
break;
case COLUMN_TEMPERATURE:
if (exercise.getRecordingMode().isTemperature()) {
return Short.valueOf(sample.getTemperature());
}
break;
}
return null;
}

Fixed version (ground truth):
@Override public Object getValueAt(int row,int col){
  ExerciseSample sample=exercise.getSampleList()[row];
switch (col) {
case COLUMN_TIME:
    return Integer.valueOf((int)(sample.getTimestamp() / 1000));
case COLUMN_HEARTRATE:
  return Short.valueOf(sample.getHeartRate());
case COLUMN_ALTITUDE:
if (exercise.getRecordingMode().isAltitude()) {
  return Short.valueOf(sample.getAltitude());
}
break;
case COLUMN_SPEED:
if (exercise.getRecordingMode().isSpeed()) {
return Float.valueOf(sample.getSpeed());
}
break;
case COLUMN_DISTANCE:
if (exercise.getRecordingMode().isSpeed()) {
return Integer.valueOf(sample.getDistance());
}
break;
case COLUMN_CADENCE:
if (exercise.getRecordingMode().isCadence()) {
return Short.valueOf(sample.getCadence());
}
break;
case COLUMN_TEMPERATURE:
if (exercise.getRecordingMode().isTemperature()) {
return Short.valueOf(sample.getTemperature());
}
break;
}
return null;
}
Program: 168417
Project: 168417
Buggy source:
/** 
 * Returns the cell component for the specified value and position. 
 */
@Override public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int rowIndex,int vColIndex){
  Component component=super.getTableCellRendererComponent(table,value,isSelected,hasFocus,rowIndex,vColIndex);
  String text=null;
switch (vColIndex) {
case COLUMN_TIME:
    text=formatUtils.seconds2TimeString((Integer)value);
  break;
case COLUMN_HEARTRATE:
text=formatUtils.heartRateToString((Short)value);
break;
case COLUMN_ALTITUDE:
if (value != null) {
text=formatUtils.heightToString((Short)value);
}
break;
case COLUMN_SPEED:
if (value != null) {
text=formatUtils.speedToString((Float)value,2);
}
break;
case COLUMN_DISTANCE:
if (value != null) {
text=formatUtils.distanceToString((Integer)value / 1000f,3);
}
break;
case COLUMN_CADENCE:
if (value != null) {
text=formatUtils.cadenceToString((Short)value);
}
break;
case COLUMN_TEMPERATURE:
if (value != null) {
text=formatUtils.temperatureToString((Short)value);
}
break;
}
setText(text);
return component;
}

Fixed version (ground truth):
/** 
 * Returns the cell component for the specified value and position. 
 */
@Override public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int rowIndex,int vColIndex){
  Component component=super.getTableCellRendererComponent(table,value,isSelected,hasFocus,rowIndex,vColIndex);
  String text=null;
switch (vColIndex) {
case COLUMN_TIME:
    text=formatUtils.seconds2TimeString((Integer)value);
  break;
case COLUMN_HEARTRATE:
text=formatUtils.heartRateToString((Short)value);
break;
case COLUMN_ALTITUDE:
if (value != null) {
text=formatUtils.heightToString((Short)value);
}
break;
case COLUMN_SPEED:
if (value != null) {
text=formatUtils.speedToString((Float)value,2);
}
break;
case COLUMN_DISTANCE:
if (value != null) {
text=formatUtils.distanceToString((Integer)value / 1000f,3);
}
break;
case COLUMN_CADENCE:
if (value != null) {
text=formatUtils.cadenceToString((Short)value);
}
break;
case COLUMN_TEMPERATURE:
if (value != null) {
text=formatUtils.temperatureToString((Short)value);
}
break;
default :
throw new IllegalArgumentException("String_Node_Str" + vColIndex);
}
setText(text);
return component;
}
Program: 168420
Project: 168420
Buggy source:
private SummaryData parseSummaryData(Node summaryDataNode){
  SummaryData nodeSummaryData=new SummaryData();
  NodeList children=summaryDataNode.getChildNodes();
  String childName;
  for (int i=0; i < children.getLength(); i++) {
    childName=children.item(i).getNodeName();
    if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setBeginning(Double.valueOf(children.item(i).getTextContent()));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setDuration(Double.valueOf(children.item(i).getTextContent()));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setHr(Node2MinMaxAvg(children.item(i)));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setWork(Integer.valueOf(children.item(i).getTextContent()));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setSpeed(Node2MinMaxAvg(children.item(i)));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setAltitude(Node2MinMaxAvg(children.item(i)));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setDistance(Float.valueOf(children.item(i).getTextContent()));
    }
  }
  return nodeSummaryData;
}

Fixed version (ground truth):
private SummaryData parseSummaryData(Node summaryDataNode){
  SummaryData nodeSummaryData=new SummaryData();
  NodeList children=summaryDataNode.getChildNodes();
  String childName;
  for (int i=0; i < children.getLength(); i++) {
    childName=children.item(i).getNodeName();
    if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setBeginning(Double.valueOf(children.item(i).getTextContent()));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setDuration(Double.valueOf(children.item(i).getTextContent()));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setHr(node2MinMaxAvg(children.item(i)));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setWork(Integer.valueOf(children.item(i).getTextContent()));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setSpeed(node2MinMaxAvg(children.item(i)));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setAltitude(node2MinMaxAvg(children.item(i)));
    }
 else     if (childName.equals("String_Node_Str")) {
      nodeSummaryData.setDistance(Float.valueOf(children.item(i).getTextContent()));
    }
  }
  return nodeSummaryData;
}
Program: 168421
Project: 168421
Buggy source:
/** 
 * Stores the lap data in the exercise and calculate the missing values. 
 */
private void storeLaps(){
  int lapDistanceSum=0;
  List<Lap> lLaps=new LinkedList<>();
  long startTime=exercise.getDate().getTime();
  for (  FitLap fitLap : lFitLaps) {
    Lap lap=fitLap.getLap();
    lLaps.add(lap);
    lap.setTimeSplit((int)((fitLap.getSplitTime().getTime() - startTime) / 100));
    ExerciseSample sampleAtLapEnd=getExerciseSampleForLapEnd(lap);
    lap.setHeartRateSplit(sampleAtLapEnd.getHeartRate());
    if (lap.getSpeed() != null) {
      lapDistanceSum+=lap.getSpeed().getDistance();
      lap.getSpeed().setDistance(lapDistanceSum);
      lap.getSpeed().setSpeedEnd(sampleAtLapEnd.getSpeed());
      lap.getSpeed().setCadence(sampleAtLapEnd.getCadence());
    }
    if (lap.getAltitude() != null) {
      lap.getAltitude().setAltitude(sampleAtLapEnd.getAltitude());
    }
    if (temperatureAvailable) {
      lap.setTemperature(new LapTemperature());
      lap.getTemperature().setTemperature(sampleAtLapEnd.getTemperature());
    }
  }
  exercise.setLapList(lLaps.toArray(new Lap[0]));
}

Fixed version (ground truth):
/** 
 * Stores the lap data in the exercise and calculate the missing values. 
 */
private void storeLaps(){
  int lapDistanceSum=0;
  List<Lap> lLaps=new LinkedList<>();
  long startTime=exercise.getDate().getTime();
  for (  FitLap fitLap : lFitLaps) {
    Lap lap=fitLap.getLap();
    lLaps.add(lap);
    lap.setTimeSplit((int)((fitLap.getSplitTime().getTime() - startTime) / 100));
    ExerciseSample sampleAtLapEnd=getExerciseSampleForLapEnd(lap);
    lap.setHeartRateSplit(sampleAtLapEnd.getHeartRate());
    if (lap.getSpeed() != null) {
      lapDistanceSum+=lap.getSpeed().getDistance();
      lap.getSpeed().setDistance(lapDistanceSum);
      lap.getSpeed().setSpeedEnd(sampleAtLapEnd.getSpeed());
      lap.getSpeed().setCadence(sampleAtLapEnd.getCadence());
    }
    if (lap.getAltitude() != null) {
      lap.getAltitude().setAltitude(sampleAtLapEnd.getAltitude());
    }
    if (temperatureAvailable) {
      lap.setTemperature(new LapTemperature());
      lap.getTemperature().setTemperature(sampleAtLapEnd.getTemperature());
    }
  }
  exercise.setLapList(lLaps.toArray(new Lap[lLaps.size()]));
}
Program: 168422
Project: 168422
Buggy source:
/** 
 * Stores the sample data in the exercise. It also fixes the timestamps in all  ExerciseSamples, it must be the offset from the start time.
 */
private void storeSamples(){
  long startTime=exercise.getDate().getTime();
  for (  ExerciseSample sample : lSamples) {
    sample.setTimestamp(sample.getTimestamp() - startTime);
  }
  exercise.setSampleList(lSamples.toArray(new ExerciseSample[0]));
}

Fixed version (ground truth):
/** 
 * Stores the sample data in the exercise. It also fixes the timestamps in all  ExerciseSamples, it must be the offset from the start time.
 */
private void storeSamples(){
  long startTime=exercise.getDate().getTime();
  for (  ExerciseSample sample : lSamples) {
    sample.setTimestamp(sample.getTimestamp() - startTime);
  }
  exercise.setSampleList(lSamples.toArray(new ExerciseSample[lSamples.size()]));
}
Program: 168423
Project: 168423
Buggy source:
/** 
 * Tests of getParser() method.
 */
@Test public void testGetParser() throws EVException {
  ExerciseParser parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof PolarSRawParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof PolarSRawParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof TimexPwxParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof GarminFitParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertEquals("String_Node_Str",parser.getClass().getName());
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertEquals("String_Node_Str",parser.getClass().getName());
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertEquals("String_Node_Str",parser.getClass().getName());
  try {
    parser=ExerciseParserFactory.getParser("String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  EVException e) {
  }
}

Fixed version (ground truth):
/** 
 * Tests of getParser() method.
 */
@Test public void testGetParser() throws EVException {
  ExerciseParser parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof PolarSRawParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof PolarSRawParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof TimexPwxParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertTrue(parser instanceof GarminFitParser);
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertEquals("String_Node_Str",parser.getClass().getName());
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertEquals("String_Node_Str",parser.getClass().getName());
  parser=ExerciseParserFactory.getParser("String_Node_Str");
  assertEquals("String_Node_Str",parser.getClass().getName());
  try {
    ExerciseParserFactory.getParser("String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  EVException e) {
  }
}
Program: 168425
Project: 168425
Buggy source:
/** 
 * Reads sample-level data from the specified Record message.
 * @param mesg Record message
 */
private void readRecordMessage(RecordMesg mesg){
  ExerciseSample sample=new ExerciseSample();
  lSamples.add(sample);
  if (mesg.getHeartRate() != null) {
    sample.setHeartRate(mesg.getHeartRate());
  }
  if (mesg.getDistance() != null) {
    sample.setDistance(Math.round(mesg.getDistance()));
  }
  if (mesg.getSpeed() != null) {
    sample.setSpeed(ConvertUtils.convertMeterPerSecond2KilometerPerHour(mesg.getSpeed()));
  }
  if (mesg.getAltitude() != null) {
    sample.setAltitude((short)Math.round(mesg.getAltitude()));
  }
  if (mesg.getCadence() != null) {
    sample.setCadence(mesg.getCadence());
  }
  if (mesg.getTemperature() != null) {
    sample.setTemperature(mesg.getTemperature());
  }
}

Fixed version (ground truth):
/** 
 * Reads sample-level data from the specified Record message.
 * @param mesg Record message
 */
private void readRecordMessage(RecordMesg mesg){
  ExerciseSample sample=new ExerciseSample();
  lSamples.add(sample);
  sample.setTimestamp(mesg.getTimestamp().getDate().getTime());
  if (mesg.getHeartRate() != null) {
    sample.setHeartRate(mesg.getHeartRate());
  }
  if (mesg.getDistance() != null) {
    sample.setDistance(Math.round(mesg.getDistance()));
  }
  if (mesg.getSpeed() != null) {
    sample.setSpeed(ConvertUtils.convertMeterPerSecond2KilometerPerHour(mesg.getSpeed()));
  }
  if (mesg.getAltitude() != null) {
    sample.setAltitude((short)Math.round(mesg.getAltitude()));
  }
  if (mesg.getCadence() != null) {
    sample.setCadence(mesg.getCadence());
  }
  if (mesg.getTemperature() != null) {
    sample.setTemperature(mesg.getTemperature());
  }
}
Program: 168426
Project: 168426
Buggy source:
/** 
 * Returns the EVExercise created from the received message. It sets up all lap and sample data and calculates the missing data before.
 * @return
 */
public EVExercise getExercise(){
  exercise.setFileType(EVExercise.ExerciseFileType.GARMIN_FIT);
  exercise.setLapList(lLaps.toArray(new Lap[0]));
  exercise.setSampleList(lSamples.toArray(new ExerciseSample[0]));
  return exercise;
}

Fixed version (ground truth):
/** 
 * Returns the EVExercise created from the received message. It sets up all lap and sample data and calculates the missing data before.
 * @return
 */
public EVExercise getExercise(){
  exercise.setFileType(EVExercise.ExerciseFileType.GARMIN_FIT);
  fixSampleTimestamps();
  exercise.setLapList(lLaps.toArray(new Lap[0]));
  exercise.setSampleList(lSamples.toArray(new ExerciseSample[0]));
  return exercise;
}
Program: 168427
Project: 168427
Buggy source:
@Override public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
  String exceptionMessage="String_Node_Str";
  if (exceptionRaised.compareAndSet(false,true)) {
    if (methodInfo != null) {
      LOG.error(exceptionMessage,cause);
      methodInfo.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR,cause);
      methodInfo=null;
    }
 else {
      if (cause instanceof HandlerException) {
        HttpResponse response=((HandlerException)cause).createFailureResponse();
        if (isUserError(response)) {
          LOG.trace(exceptionMessage,cause);
        }
 else {
          LOG.error(exceptionMessage,cause);
        }
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        LOG.error(exceptionMessage,cause);
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.INTERNAL_SERVER_ERROR);
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
    }
  }
 else {
    LOG.trace(exceptionMessage,cause);
  }
}

Fixed version (ground truth):
@Override public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
  String exceptionMessage="String_Node_Str";
  if (exceptionRaised.compareAndSet(false,true)) {
    if (methodInfo != null) {
      methodInfo.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR,cause);
      methodInfo=null;
    }
 else {
      if (cause instanceof HandlerException) {
        HttpResponse response=((HandlerException)cause).createFailureResponse();
        if (isUserError(response)) {
          LOG.trace(exceptionMessage,cause);
        }
 else {
          LOG.error(exceptionMessage,cause);
        }
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        LOG.error(exceptionMessage,cause);
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.INTERNAL_SERVER_ERROR);
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
    }
  }
 else {
    LOG.trace(exceptionMessage,cause);
  }
}
Program: 168428
Project: 168428
Buggy source:
/** 
 * If the HttpRequest is valid and handled it will be sent upstream, if it cannot be invoked the response will be written back immediately.
 */
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  try {
    if (exceptionRaised.get()) {
      return;
    }
    if (!(msg instanceof HttpRequest)) {
      if (methodInfo != null) {
        ReferenceCountUtil.retain(msg);
        ctx.fireChannelRead(msg);
      }
      return;
    }
    HttpRequest request=(HttpRequest)msg;
    BasicHttpResponder responder=new BasicHttpResponder(ctx.channel(),sslEnabled);
    methodInfo=prepareHandleMethod(request,responder,ctx);
    if (methodInfo != null) {
      ReferenceCountUtil.retain(msg);
      ctx.fireChannelRead(msg);
    }
 else {
      if (!responder.isResponded()) {
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.NOT_FOUND);
        ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        ctx.channel().close();
      }
    }
  }
  finally {
    ReferenceCountUtil.release(msg);
  }
}

Fixed version (ground truth):
/** 
 * If the HttpRequest is valid and handled it will be sent upstream, if it cannot be invoked the response will be written back immediately.
 */
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  try {
    if (exceptionRaised.get()) {
      return;
    }
    if (!(msg instanceof HttpRequest)) {
      if (methodInfo != null) {
        ReferenceCountUtil.retain(msg);
        ctx.fireChannelRead(msg);
      }
      return;
    }
    HttpRequest request=(HttpRequest)msg;
    BasicHttpResponder responder=new BasicHttpResponder(ctx.channel(),sslEnabled);
    methodInfo=null;
    methodInfo=prepareHandleMethod(request,responder,ctx);
    if (methodInfo != null) {
      ReferenceCountUtil.retain(msg);
      ctx.fireChannelRead(msg);
    }
 else {
      if (!responder.isResponded()) {
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.NOT_FOUND);
        ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        ctx.channel().close();
      }
    }
  }
  finally {
    ReferenceCountUtil.release(msg);
  }
}
Program: 168429
Project: 168429
Buggy source:
@Test public void testNonExistingEndPoints() throws IOException {
  HttpURLConnection urlConn=request("String_Node_Str",HttpMethod.POST);
  writeContent(urlConn,"String_Node_Str");
  Assert.assertEquals(404,urlConn.getResponseCode());
  urlConn.disconnect();
}

Fixed version (ground truth):
@Test public void testNonExistingEndPoints() throws IOException {
  HttpURLConnection urlConn=request("String_Node_Str",HttpMethod.POST);
  writeContent(urlConn,"String_Node_Str");
  Assert.assertEquals(404,urlConn.getResponseCode());
  urlConn.disconnect();
  urlConn=request("String_Node_Str",HttpMethod.GET,true);
  Assert.assertEquals(200,urlConn.getResponseCode());
  urlConn.getInputStream().close();
  urlConn.disconnect();
  urlConn=request("String_Node_Str",HttpMethod.GET);
  Assert.assertEquals(404,urlConn.getResponseCode());
}
Program: 168430
Project: 168430
Buggy source:
@Override public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
  String exceptionMessage="String_Node_Str";
  if (exceptionRaised.compareAndSet(false,true)) {
    if (methodInfo != null) {
      LOG.error(exceptionMessage,cause);
      methodInfo.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR,cause);
      methodInfo=null;
    }
 else {
      if (cause instanceof HandlerException) {
        HttpResponse response=((HandlerException)cause).createFailureResponse();
        if (isUserError(response)) {
          LOG.trace(exceptionMessage,cause);
        }
 else {
          LOG.error(exceptionMessage,cause);
        }
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        LOG.error(exceptionMessage,cause);
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.INTERNAL_SERVER_ERROR);
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
    }
  }
 else {
    LOG.trace(exceptionMessage,cause);
  }
}

Fixed version (ground truth):
@Override public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
  String exceptionMessage="String_Node_Str";
  if (exceptionRaised.compareAndSet(false,true)) {
    if (methodInfo != null) {
      methodInfo.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR,cause);
      methodInfo=null;
    }
 else {
      if (cause instanceof HandlerException) {
        HttpResponse response=((HandlerException)cause).createFailureResponse();
        if (isUserError(response)) {
          LOG.trace(exceptionMessage,cause);
        }
 else {
          LOG.error(exceptionMessage,cause);
        }
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        LOG.error(exceptionMessage,cause);
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.INTERNAL_SERVER_ERROR);
        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
    }
  }
 else {
    LOG.trace(exceptionMessage,cause);
  }
}
Program: 168431
Project: 168431
Buggy source:
/** 
 * If the HttpRequest is valid and handled it will be sent upstream, if it cannot be invoked the response will be written back immediately.
 */
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  try {
    if (exceptionRaised.get()) {
      return;
    }
    if (!(msg instanceof HttpRequest)) {
      if (methodInfo != null) {
        ReferenceCountUtil.retain(msg);
        ctx.fireChannelRead(msg);
      }
      return;
    }
    HttpRequest request=(HttpRequest)msg;
    BasicHttpResponder responder=new BasicHttpResponder(ctx.channel(),sslEnabled);
    methodInfo=prepareHandleMethod(request,responder,ctx);
    if (methodInfo != null) {
      ReferenceCountUtil.retain(msg);
      ctx.fireChannelRead(msg);
    }
 else {
      if (!responder.isResponded()) {
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.NOT_FOUND);
        ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        ctx.channel().close();
      }
    }
  }
  finally {
    ReferenceCountUtil.release(msg);
  }
}

Fixed version (ground truth):
/** 
 * If the HttpRequest is valid and handled it will be sent upstream, if it cannot be invoked the response will be written back immediately.
 */
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  try {
    if (exceptionRaised.get()) {
      return;
    }
    if (!(msg instanceof HttpRequest)) {
      if (methodInfo != null) {
        ReferenceCountUtil.retain(msg);
        ctx.fireChannelRead(msg);
      }
      return;
    }
    HttpRequest request=(HttpRequest)msg;
    BasicHttpResponder responder=new BasicHttpResponder(ctx.channel(),sslEnabled);
    methodInfo=null;
    methodInfo=prepareHandleMethod(request,responder,ctx);
    if (methodInfo != null) {
      ReferenceCountUtil.retain(msg);
      ctx.fireChannelRead(msg);
    }
 else {
      if (!responder.isResponded()) {
        HttpResponse response=new DefaultHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.NOT_FOUND);
        ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
      }
 else {
        ctx.channel().close();
      }
    }
  }
  finally {
    ReferenceCountUtil.release(msg);
  }
}