Program: 102965
Project: 102965
Buggy source:
/** 
 * Initializes a new <tt>Component</tt> which.is to preview and/or allow detailed configuration of an audio or video <tt>DeviceSystem</tt>.
 * @param type either {@link DeviceConfigurationComboBoxModel#AUDIO} or{@link DeviceConfigurationComboBoxModel#VIDEO}
 * @param comboBox the <tt>JComboBox</tt> which lists the availablealternatives and the selection which is to be previewed. May be <tt>null</tt> in the case of audio in which case it is assumed that the user is not allowed to set the <tt>AudioSystem</tt> to be used and the selection is determined by the <tt>DeviceConfiguration</tt> of the <tt>MediaService</tt>.
 * @param prefSize the preferred size to be applied to the preview
 * @return a new <tt>Component</tt> which is to preview and/or allowdetailed configuration of the <tt>DeviceSystem</tt> identified by <tt>type</tt> and <tt>comboBox</tt>
 */
private Component createPreview(int type,JComboBox comboBox,Dimension prefSize){
  JComponent preview=null;
  if (type == DeviceConfigurationComboBoxModel.AUDIO) {
    AudioSystem audioSystem=null;
    if ((comboBox == null) || !comboBox.isEnabled()) {
      audioSystem=mediaService.getDeviceConfiguration().getAudioSystem();
    }
 else {
      Object selectedItem=comboBox.getSelectedItem();
      if (selectedItem instanceof AudioSystem) {
        audioSystem=(AudioSystem)selectedItem;
        AudioSystem mediaServiceDeviceConfigurationAudioSystem=mediaService.getDeviceConfiguration().getAudioSystem();
        if (audioSystem != mediaServiceDeviceConfigurationAudioSystem) {
          logger.warn("String_Node_Str" + "String_Node_Str");
        }
      }
    }
    if ((audioSystem != null) && !NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase(audioSystem.getLocatorProtocol())) {
      preview=new TransparentPanel(new GridBagLayout());
      createAudioSystemControls(audioSystem,preview);
    }
 else {
      AudioSystem[] audioSystems=AudioSystem.getAudioSystems();
      if ((audioSystems != null) && (audioSystems.length != 1)) {
        AudioSystem[] availableAudioSystems=mediaService.getDeviceConfiguration().getAvailableAudioSystems();
        if ((availableAudioSystems != null) && (availableAudioSystems.length == 1)) {
          String noAvailableAudioDevice=NeomediaActivator.getResources().getI18NString("String_Node_Str" + "String_Node_Str");
          preview=new TransparentPanel(new GridBagLayout());
          preview.add(new JLabel(noAvailableAudioDevice));
        }
      }
    }
  }
 else   if (type == DeviceConfigurationComboBoxModel.VIDEO) {
    JLabel noPreview=new JLabel(NeomediaActivator.getResources().getI18NString("String_Node_Str"));
    noPreview.setHorizontalAlignment(SwingConstants.CENTER);
    noPreview.setVerticalAlignment(SwingConstants.CENTER);
    preview=createVideoContainer(noPreview);
    preview.setPreferredSize(prefSize);
    Object selectedItem=comboBox.getSelectedItem();
    CaptureDeviceInfo device=null;
    if (selectedItem instanceof DeviceConfigurationComboBoxModel.CaptureDevice)     device=((DeviceConfigurationComboBoxModel.CaptureDevice)selectedItem).info;
    Exception exception;
    try {
      createVideoPreview(device,preview);
      exception=null;
    }
 catch (    IOException ex) {
      exception=ex;
    }
catch (    MediaException ex) {
      exception=ex;
    }
    if (exception != null) {
      logger.error("String_Node_Str" + device,exception);
    }
  }
  return preview;
}

Fixed version (ground truth):
/** 
 * Initializes a new <tt>Component</tt> which.is to preview and/or allow detailed configuration of an audio or video <tt>DeviceSystem</tt>.
 * @param type either {@link DeviceConfigurationComboBoxModel#AUDIO} or{@link DeviceConfigurationComboBoxModel#VIDEO}
 * @param comboBox the <tt>JComboBox</tt> which lists the availablealternatives and the selection which is to be previewed. May be <tt>null</tt> in the case of audio in which case it is assumed that the user is not allowed to set the <tt>AudioSystem</tt> to be used and the selection is determined by the <tt>DeviceConfiguration</tt> of the <tt>MediaService</tt>.
 * @param prefSize the preferred size to be applied to the preview
 * @return a new <tt>Component</tt> which is to preview and/or allowdetailed configuration of the <tt>DeviceSystem</tt> identified by <tt>type</tt> and <tt>comboBox</tt>
 */
private Component createPreview(int type,DeviceComboBoxField comboBox,Dimension prefSize){
  JComponent preview=null;
  if (type == DeviceConfigurationComboBoxModel.AUDIO) {
    AudioSystem audioSystem=null;
    if ((comboBox == null) || !comboBox.getComponent().isEnabled()) {
      audioSystem=mediaService.getDeviceConfiguration().getAudioSystem();
    }
 else {
      Object selectedItem=comboBox.getSelectedItem();
      if (selectedItem instanceof AudioSystem) {
        audioSystem=(AudioSystem)selectedItem;
        AudioSystem mediaServiceDeviceConfigurationAudioSystem=mediaService.getDeviceConfiguration().getAudioSystem();
        if (audioSystem != mediaServiceDeviceConfigurationAudioSystem) {
          logger.warn("String_Node_Str" + "String_Node_Str");
        }
      }
    }
    if ((audioSystem != null) && !NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase(audioSystem.getLocatorProtocol())) {
      preview=new TransparentPanel(new GridBagLayout());
      createAudioSystemControls(audioSystem,preview);
    }
 else {
      AudioSystem[] audioSystems=AudioSystem.getAudioSystems();
      if ((audioSystems != null) && (audioSystems.length != 1)) {
        AudioSystem[] availableAudioSystems=mediaService.getDeviceConfiguration().getAvailableAudioSystems();
        if ((availableAudioSystems != null) && (availableAudioSystems.length == 1)) {
          String noAvailableAudioDevice=NeomediaActivator.getResources().getI18NString("String_Node_Str" + "String_Node_Str");
          preview=new TransparentPanel(new GridBagLayout());
          preview.add(new JLabel(noAvailableAudioDevice));
        }
      }
    }
  }
 else   if (type == DeviceConfigurationComboBoxModel.VIDEO) {
    JLabel noPreview=new JLabel(NeomediaActivator.getResources().getI18NString("String_Node_Str"));
    noPreview.setHorizontalAlignment(SwingConstants.CENTER);
    noPreview.setVerticalAlignment(SwingConstants.CENTER);
    preview=createVideoContainer(noPreview);
    preview.setPreferredSize(prefSize);
    Object selectedItem=comboBox.getSelectedItem();
    CaptureDeviceInfo device=null;
    if (selectedItem instanceof DeviceConfigurationComboBoxModel.CaptureDevice)     device=((DeviceConfigurationComboBoxModel.CaptureDevice)selectedItem).info;
    Exception exception;
    try {
      createVideoPreview(device,preview);
      exception=null;
    }
 catch (    IOException ex) {
      exception=ex;
    }
catch (    MediaException ex) {
      exception=ex;
    }
    if (exception != null) {
      logger.error("String_Node_Str" + device,exception);
    }
  }
  return preview;
}