nus-yam/ex-repair huggingface dataset:
Program: 45184
Project: 45184
Buggy source:
/** 
 * Returns this FileURL's parent, or null if this FileURL has no parent (path is "/"). The returned parent will have the same protocol, host, port, credentials and properties as this FileURL. The filename and query parts of this FileURL (if any) will not be set in the returned parent, both will be null. <p>Note: this method returns a new FileURL instance everytime it is called, and all mutable fields of this FileURL are cloned. Therefore the returned parent can be safely modified without risking to modify other FileURL instances.
 */
public FileURL getParent(){
  if (!(path.equals("String_Node_Str") || path.equals("String_Node_Str"))) {
    String separator=getPathSeparator();
    String parentPath=path.endsWith(separator) ? path.substring(0,path.length() - separator.length()) : path;
    int lastSeparatorPos=parentPath.lastIndexOf(separator);
    if (lastSeparatorPos != -1) {
      FileURL parentURL=new FileURL();
      parentURL.protocol=protocol;
      parentURL.host=host;
      parentURL.port=port;
      parentURL.path=parentPath.substring(0,lastSeparatorPos + 1);
      parentURL.credentials=credentials;
      if (properties != null)       parentURL.properties=new Hashtable(properties);
      return parentURL;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns this FileURL's parent, or null if this FileURL has no parent (path is "/"). The returned parent will have the same protocol, host, port, credentials and properties as this FileURL. The filename and query parts of this FileURL (if any) will not be set in the returned parent, both will be null. <p>Note: this method returns a new FileURL instance everytime it is called, and all mutable fields of this FileURL are cloned. Therefore the returned parent can be safely modified without risking to modify other FileURL instances.</p>
 */
public FileURL getParent(){
  if (!(path.equals("String_Node_Str") || path.equals("String_Node_Str"))) {
    String separator=getPathSeparator();
    String parentPath=path.endsWith(separator) ? path.substring(0,path.length() - separator.length()) : path;
    int lastSeparatorPos=parentPath.lastIndexOf(separator);
    if (lastSeparatorPos != -1) {
      FileURL parentURL=new FileURL();
      parentURL.protocol=protocol;
      parentURL.host=host;
      parentURL.port=port;
      parentURL.path=parentPath.substring(0,lastSeparatorPos + 1);
      parentURL.filename=getFilenameFromPath(parentURL.path,separator);
      parentURL.credentials=credentials;
      if (properties != null)       parentURL.properties=new Hashtable(properties);
      return parentURL;
    }
  }
  return null;
}
Program: 45185
Project: 45185
Buggy source:
public void focusLost(FocusEvent e){
  if (e.getSource() == fileTable) {
    ((MutableLineBorder)scrollPane.getBorder()).setLineColor(unfocusedBorderColor);
    scrollPane.getViewport().setBackground(unfocusedBackgroundColor);
  }
  fileTable.getQuickSearch().cancel();
}

Fixed version (ground truth):
public void focusLost(FocusEvent e){
  if (e.getSource() == fileTable) {
    setBorderColor(unfocusedBorderColor);
    scrollPane.getViewport().setBackground(unfocusedBackgroundColor);
  }
  fileTable.getQuickSearch().cancel();
}
Program: 45186
Project: 45186
Buggy source:
/** 
 * Receives theme color changes notifications.
 */
public void colorChanged(ColorChangedEvent event){
switch (event.getColorId()) {
case Theme.FILE_TABLE_BORDER_COLOR:
    borderColor=event.getColor();
  if (fileTable.hasFocus()) {
    ((MutableLineBorder)scrollPane.getBorder()).setLineColor(borderColor);
    scrollPane.repaint();
  }
break;
case Theme.FILE_TABLE_INACTIVE_BORDER_COLOR:
unfocusedBorderColor=event.getColor();
if (!fileTable.hasFocus()) {
((MutableLineBorder)scrollPane.getBorder()).setLineColor(unfocusedBorderColor);
scrollPane.repaint();
}
break;
case Theme.FILE_TABLE_BACKGROUND_COLOR:
backgroundColor=event.getColor();
if (fileTable.hasFocus()) scrollPane.getViewport().setBackground(backgroundColor);
break;
case Theme.FILE_TABLE_INACTIVE_BACKGROUND_COLOR:
unfocusedBackgroundColor=event.getColor();
if (!fileTable.hasFocus()) scrollPane.getViewport().setBackground(unfocusedBackgroundColor);
break;
case Theme.FILE_TABLE_UNMATCHED_BACKGROUND_COLOR:
unmatchedBackgroundColor=event.getColor();
break;
}
}

Fixed version (ground truth):
/** 
 * Receives theme color changes notifications.
 */
public void colorChanged(ColorChangedEvent event){
switch (event.getColorId()) {
case Theme.FILE_TABLE_BORDER_COLOR:
    borderColor=event.getColor();
  if (fileTable.hasFocus()) {
    setBorderColor(borderColor);
    scrollPane.repaint();
  }
break;
case Theme.FILE_TABLE_INACTIVE_BORDER_COLOR:
unfocusedBorderColor=event.getColor();
if (!fileTable.hasFocus()) {
setBorderColor(unfocusedBorderColor);
scrollPane.repaint();
}
break;
case Theme.FILE_TABLE_BACKGROUND_COLOR:
backgroundColor=event.getColor();
if (fileTable.hasFocus()) scrollPane.getViewport().setBackground(backgroundColor);
break;
case Theme.FILE_TABLE_INACTIVE_BACKGROUND_COLOR:
unfocusedBackgroundColor=event.getColor();
if (!fileTable.hasFocus()) scrollPane.getViewport().setBackground(unfocusedBackgroundColor);
break;
case Theme.FILE_TABLE_UNMATCHED_BACKGROUND_COLOR:
unmatchedBackgroundColor=event.getColor();
break;
}
}
Program: 45187
Project: 45187
Buggy source:
public void focusGained(FocusEvent e){
  mainFrame.setActiveTable(fileTable);
  if (e.getSource() == fileTable) {
    ((MutableLineBorder)scrollPane.getBorder()).setLineColor(borderColor);
    scrollPane.getViewport().setBackground(backgroundColor);
  }
}

Fixed version (ground truth):
public void focusGained(FocusEvent e){
  mainFrame.setActiveTable(fileTable);
  if (e.getSource() == fileTable) {
    setBorderColor(borderColor);
    scrollPane.getViewport().setBackground(backgroundColor);
  }
}
Program: 45188
Project: 45188
Buggy source:
public void colorChanged(ColorChangedEvent event){
switch (event.getColorId()) {
case Theme.STATUS_BAR_BACKGROUND_COLOR:
    backgroundColor=event.getColor();
  break;
case Theme.STATUS_BAR_BORDER_COLOR:
((MutableLineBorder)getBorder()).setLineColor(event.getColor());
break;
case Theme.STATUS_BAR_OK_COLOR:
okColor=event.getColor();
break;
case Theme.STATUS_BAR_WARNING_COLOR:
warningColor=event.getColor();
break;
case Theme.STATUS_BAR_CRITICAL_COLOR:
criticalColor=event.getColor();
break;
default :
return;
}
repaint();
}

Fixed version (ground truth):
public void colorChanged(ColorChangedEvent event){
switch (event.getColorId()) {
case Theme.STATUS_BAR_BACKGROUND_COLOR:
    backgroundColor=event.getColor();
  break;
case Theme.STATUS_BAR_BORDER_COLOR:
if (getBorder() instanceof MutableLineBorder) ((MutableLineBorder)getBorder()).setLineColor(event.getColor());
break;
case Theme.STATUS_BAR_OK_COLOR:
okColor=event.getColor();
break;
case Theme.STATUS_BAR_WARNING_COLOR:
warningColor=event.getColor();
break;
case Theme.STATUS_BAR_CRITICAL_COLOR:
criticalColor=event.getColor();
break;
default :
return;
}
repaint();
}
Program: 45189
Project: 45189
Buggy source:
public void propertyChange(PropertyChangeEvent event){
  if (event.getPropertyName().equals(PreviewLabel.BACKGROUND_COLOR_PROPERTY_NAME))   getViewport().setBackground(data.getColor(isActive ? Theme.FILE_TABLE_BACKGROUND_COLOR : Theme.FILE_TABLE_INACTIVE_BACKGROUND_COLOR));
 else   if (event.getPropertyName().equals(PreviewLabel.BORDER_COLOR_PROPERTY_NAME))   ((MutableLineBorder)getBorder()).setLineColor(data.getColor(isActive ? Theme.FILE_TABLE_BORDER_COLOR : Theme.FILE_TABLE_INACTIVE_BORDER_COLOR));
 else   if (!event.getPropertyName().equals(PreviewLabel.FOREGROUND_COLOR_PROPERTY_NAME))   return;
  repaint();
}

Fixed version (ground truth):
public void propertyChange(PropertyChangeEvent event){
  if (event.getPropertyName().equals(PreviewLabel.BACKGROUND_COLOR_PROPERTY_NAME))   getViewport().setBackground(data.getColor(isActive ? Theme.FILE_TABLE_BACKGROUND_COLOR : Theme.FILE_TABLE_INACTIVE_BACKGROUND_COLOR));
 else   if (event.getPropertyName().equals(PreviewLabel.BORDER_COLOR_PROPERTY_NAME)) {
    if (getBorder() instanceof MutableLineBorder)     ((MutableLineBorder)getBorder()).setLineColor(data.getColor(isActive ? Theme.FILE_TABLE_BORDER_COLOR : Theme.FILE_TABLE_INACTIVE_BORDER_COLOR));
  }
 else   if (!event.getPropertyName().equals(PreviewLabel.FOREGROUND_COLOR_PROPERTY_NAME))   return;
  repaint();
}
Program: 45191
Project: 45191
Buggy source:
/** 
 * Creates a new <code>EditAction</code>.
 */
public EditAction(MainFrame mainFrame,Hashtable properties){
  super(mainFrame,properties);
  String iconPath;
  iconPath=getIconPath(InternalEditAction.class);
  if (ResourceLoader.getResourceAsURL(iconPath) != null)   setIcon(IconManager.getIcon(iconPath));
  useCustomEditor=MuConfiguration.getVariable(MuConfiguration.USE_CUSTOM_EDITOR,MuConfiguration.DEFAULT_USE_CUSTOM_EDITOR);
  setCustomEditor(MuConfiguration.getVariable(MuConfiguration.CUSTOM_EDITOR));
}

Fixed version (ground truth):
/** 
 * Creates a new <code>EditAction</code>.
 */
public EditAction(MainFrame mainFrame,Hashtable properties){
  super(mainFrame,properties);
  String iconPath;
  iconPath=getIconPath(InternalEditAction.class);
  if (ResourceLoader.getResourceAsURL(iconPath) != null)   setIcon(IconManager.getIcon(iconPath));
  useCustomEditor=MuConfiguration.getVariable(MuConfiguration.USE_CUSTOM_EDITOR,MuConfiguration.DEFAULT_USE_CUSTOM_EDITOR);
  setCustomEditor(MuConfiguration.getVariable(MuConfiguration.CUSTOM_EDITOR));
  MuConfiguration.addConfigurationListener(this);
}
Program: 45192
Project: 45192
Buggy source:
/** 
 * Creates a new <code>ViewAction</code>.
 */
public ViewAction(MainFrame mainFrame,Hashtable properties){
  super(mainFrame,properties);
  String iconPath;
  iconPath=getIconPath(InternalViewAction.class);
  if (ResourceLoader.getResourceAsURL(iconPath) != null)   setIcon(IconManager.getIcon(iconPath));
  useCustomViewer=MuConfiguration.getVariable(MuConfiguration.USE_CUSTOM_VIEWER,MuConfiguration.DEFAULT_USE_CUSTOM_VIEWER);
  setCustomViewer(MuConfiguration.getVariable(MuConfiguration.CUSTOM_VIEWER));
}

Fixed version (ground truth):
/** 
 * Creates a new <code>ViewAction</code>.
 */
public ViewAction(MainFrame mainFrame,Hashtable properties){
  super(mainFrame,properties);
  String iconPath;
  iconPath=getIconPath(InternalViewAction.class);
  if (ResourceLoader.getResourceAsURL(iconPath) != null)   setIcon(IconManager.getIcon(iconPath));
  useCustomViewer=MuConfiguration.getVariable(MuConfiguration.USE_CUSTOM_VIEWER,MuConfiguration.DEFAULT_USE_CUSTOM_VIEWER);
  setCustomViewer(MuConfiguration.getVariable(MuConfiguration.CUSTOM_VIEWER));
  MuConfiguration.addConfigurationListener(this);
}
Program: 45193
Project: 45193
Buggy source:
/** 
 * Enables or disables this action based on the history of the currently active FolderPanel: if there is a previous folder in the history, this action will be enabled, if not it will be disabled.
 */
private void toggleEnabledState(){
  setEnabled(mainFrame.getActiveTable().getFolderPanel().getFolderHistory().hasBackFolder());
}

Fixed version (ground truth):
/** 
 * Enables or disables this action based on the history of the currently active FolderPanel: if there is a previous folder in the history, this action will be enabled, if not it will be disabled.
 */
protected void toggleEnabledState(){
  setEnabled(mainFrame.getActiveTable().getFolderPanel().getFolderHistory().hasBackFolder());
}
Program: 45194
Project: 45194
Buggy source:
/** 
 * Enables or disables this action based on the history of the currently active FolderPanel: if there is a next folder in the history, this action will be enabled, if not it will be disabled.
 */
private void toggleEnabledState(){
  setEnabled(mainFrame.getActiveTable().getFolderPanel().getFolderHistory().hasForwardFolder());
}

Fixed version (ground truth):
/** 
 * Enables or disables this action based on the history of the currently active FolderPanel: if there is a next folder in the history, this action will be enabled, if not it will be disabled.
 */
protected void toggleEnabledState(){
  setEnabled(mainFrame.getActiveTable().getFolderPanel().getFolderHistory().hasForwardFolder());
}
Program: 45195
Project: 45195
Buggy source:
/** 
 * Enables or disables this action based on the history of the currently active FolderPanel: if there is a previous folder in the history, this action will be enabled, if not it will be disabled.
 */
private abstract void toggleEnabledState();

Fixed version (ground truth):
/** 
 * Enables or disables this action based on the history of the currently active FolderPanel: if there is a previous folder in the history, this action will be enabled, if not it will be disabled.
 */
protected abstract void toggleEnabledState();
Program: 45196
Project: 45196
Buggy source:
/** 
 * Enables or disables this action based on the currently active folder's has a parent, this action will be enabled, if not it will be disabled.
 */
private void toggleEnabledState(){
  setEnabled(mainFrame.getActiveTable().getFolderPanel().getCurrentFolder().getParentSilently() != null);
}

Fixed version (ground truth):
/** 
 * Enables or disables this action based on the currently active folder's has a parent, this action will be enabled, if not it will be disabled.
 */
protected void toggleEnabledState(){
  setEnabled(mainFrame.getActiveTable().getFolderPanel().getCurrentFolder().getParentSilently() != null);
}
Program: 45197
Project: 45197
Buggy source:
public void mousePressed(MouseEvent e){
  if (PlatformManager.isLeftMouseButton(e)) {
    fileTable.requestFocus();
  }
 else   if (PlatformManager.isRightMouseButton(e)) {
    AbstractFile currentFolder=getCurrentFolder();
    new TablePopupMenu(FolderPanel.this.mainFrame,currentFolder,null,false,fileTable.getFileTableModel().getMarkedFiles()).show(scrollPane,e.getX(),e.getY());
  }
}

Fixed version (ground truth):
public void mousePressed(MouseEvent e){
  if (PlatformManager.isLeftMouseButton(e)) {
    fileTable.requestFocus();
  }
 else   if (PlatformManager.isRightMouseButton(e)) {
    if (!fileTable.hasFocus())     fileTable.requestFocus();
    AbstractFile currentFolder=getCurrentFolder();
    new TablePopupMenu(FolderPanel.this.mainFrame,currentFolder,null,false,fileTable.getFileTableModel().getMarkedFiles()).show(scrollPane,e.getX(),e.getY());
  }
}
Program: 45199
Project: 45199
Buggy source:
/** 
 * Returns an   {@link AbstractFile} to the root package of the given <code>Class</code>. For example, if thespecified <code>Class</code> is <code>java.lang.Object</code>'s, the returned file will be the Java runtime JAR file, which on most platforms is <code>$JAVA_HOME/lib/jre/rt.jar</code>.<br/> The returned file can be used to list or manipulate all resource files contained in a particular classpath's location, including the .class files.
 * @param aClass the class for which to locate the root package.
 * @return an AbstractFile to the root package of the given <code>Class</code>
 */
public static AbstractFile getRootPackageAsFile(Class aClass){
  ClassLoader classLoader=aClass.getClassLoader();
  if (classLoader == null)   classLoader=ClassLoader.getSystemClassLoader();
  String aClassRelPath=aClass.getName().replace('.','/') + "String_Node_Str";
  URL aClassURL=getResourceAsURL(aClassRelPath,classLoader);
  if (aClassURL == null)   return null;
  if ("String_Node_Str".equals(aClassURL.getProtocol()))   return FileFactory.getFile(getJarPath(aClassURL));
  String aClassPath=getDecodedURLPath(aClassURL);
  return FileFactory.getFile(aClassPath.substring(0,aClassPath.length() - aClassRelPath.length()));
}

Fixed version (ground truth):
/** 
 * Returns an   {@link AbstractFile} to the root package of the given <code>Class</code>. For example, if thespecified <code>Class</code> is <code>java.lang.Object</code>'s, the returned file will be the Java runtime JAR file, which on most platforms is <code>$JAVA_HOME/lib/jre/rt.jar</code>.<br/> The returned file can be used to list or manipulate all resource files contained in a particular classpath's location, including the .class files.
 * @param aClass the class for which to locate the root package.
 * @return an AbstractFile to the root package of the given <code>Class</code>
 */
public static AbstractFile getRootPackageAsFile(Class aClass){
  ClassLoader classLoader=aClass.getClassLoader();
  if (classLoader == null)   classLoader=ClassLoader.getSystemClassLoader();
  String aClassRelPath=aClass.getName().replace('.','/') + "String_Node_Str";
  URL aClassURL=getResourceAsURL(aClassRelPath,classLoader);
  if (aClassURL == null)   return null;
  if ("String_Node_Str".equals(aClassURL.getProtocol()))   return FileFactory.getFile(getJarFilePath(aClassURL));
  String aClassPath=getLocalFilePath(aClassURL);
  return FileFactory.getFile(aClassPath.substring(0,aClassPath.length() - aClassRelPath.length()));
}
Program: 45200
Project: 45200
Buggy source:
/** 
 * Finds the resource with the given path and returns a URL pointing to its location, or <code>null</code> if the resource couldn't be located. The given <code>ClassLoader</code> is used for locating the resource. <p>The given path may or may not start with a leading slash character ('/'), this doesn't affect the way it is interpreted.</p>
 * @param path a path to the resource, relative to the system ClassLoader's classpath
 * @param classLoader the ClassLoader used for locating the resource
 * @return a URL pointing to the resource, or null if the resource couldn't be located
 */
public static URL getResourceAsURL(String path,ClassLoader classLoader){
  return classLoader.getResource(normalizePath(path));
}

Fixed version (ground truth):
/** 
 * Finds the resource with the given path and returns a URL pointing to its location, or <code>null</code> if the resource couldn't be located. The given <code>ClassLoader</code> is used for locating the resource. <p>The given path may or may not start with a leading slash character ('/'), this doesn't affect the way it is interpreted.</p>
 * @param path a path to the resource, relative to the system ClassLoader's classpath
 * @param classLoader the ClassLoader used for locating the resource
 * @return a URL pointing to the resource, or null if the resource couldn't be located
 */
public static URL getResourceAsURL(String path,ClassLoader classLoader){
  return classLoader.getResource(removeLeadingSlash(path));
}
Program: 45201
Project: 45201
Buggy source:
/** 
 * Finds the resource with the given path and returns an <code>InputStream</code> to read from it, or <code>null</code> if the resource couldn't be located. The given <code>ClassLoader</code> is used for locating the resource. <p>The given path may or may not start with a leading slash character ('/'), this doesn't affect the way it is interpreted.</p>
 * @param path a path to the resource, relative to the system ClassLoader's classpath
 * @param classLoader the Class whose ClassLoader is used for locating the resource
 * @return an InputStream that allows to read from the resource, or null if the resource couldn't be located
 */
public static InputStream getResourceAsStream(String path,ClassLoader classLoader){
  return classLoader.getResourceAsStream(normalizePath(path));
}

Fixed version (ground truth):
/** 
 * Finds the resource with the given path and returns an <code>InputStream</code> to read from it, or <code>null</code> if the resource couldn't be located. The given <code>ClassLoader</code> is used for locating the resource. <p>The given path may or may not start with a leading slash character ('/'), this doesn't affect the way it is interpreted.</p>
 * @param path a path to the resource, relative to the system ClassLoader's classpath
 * @param classLoader the Class whose ClassLoader is used for locating the resource
 * @return an InputStream that allows to read from the resource, or null if the resource couldn't be located
 */
public static InputStream getResourceAsStream(String path,ClassLoader classLoader){
  return classLoader.getResourceAsStream(removeLeadingSlash(path));
}
Program: 45202
Project: 45202
Buggy source:
/** 
 * Finds the resource with the given path and returns an   {@link AbstractFile} that gives full access to it,or <code>null</code> if the resource couldn't be located. The given <code>ClassLoader</code> is used for locating the resource. <p>The given path may or may not start with a leading slash character ('/'), this doesn't affect the way it is interpreted. Also noteworthy is this method may be slower than  {@link #getResourceAsStream(String)} ifthe resource is located inside a JAR file, because the Zip file headers will have to be parsed the first time the archive is accessed. So this latter method should be favored if the file is simply used for reading the resource.</p>
 * @param path a path to the resource, relative to the system ClassLoader's classpath
 * @param classLoader the ClassLoader is used for locating the resource
 * @return an AbstractFile that allows to access the resource, or null if the resource couldn't be located
 */
public static AbstractFile getResourceAsFile(String path,ClassLoader classLoader){
  path=normalizePath(path);
  URL aClassURL=getResourceAsURL(path,classLoader);
  if (aClassURL == null)   return null;
  if ("String_Node_Str".equals(aClassURL.getProtocol())) {
    try {
      return ((AbstractArchiveFile)FileFactory.getFile(getJarPath(aClassURL))).getArchiveEntryFile(path);
    }
 catch (    Exception e) {
      return null;
    }
  }
  return FileFactory.getFile(getDecodedURLPath(aClassURL));
}

Fixed version (ground truth):
/** 
 * Finds the resource with the given path and returns an   {@link AbstractFile} that gives full access to it,or <code>null</code> if the resource couldn't be located. The given <code>ClassLoader</code> is used for locating the resource. <p>The given path may or may not start with a leading slash character ('/'), this doesn't affect the way it is interpreted. Also noteworthy is this method may be slower than  {@link #getResourceAsStream(String)} ifthe resource is located inside a JAR file, because the Zip file headers will have to be parsed the first time the archive is accessed. So this latter method should be favored if the file is simply used for reading the resource.</p>
 * @param path a path to the resource, relative to the system ClassLoader's classpath
 * @param classLoader the ClassLoader is used for locating the resource
 * @return an AbstractFile that allows to access the resource, or null if the resource couldn't be located
 */
public static AbstractFile getResourceAsFile(String path,ClassLoader classLoader){
  path=removeLeadingSlash(path);
  URL aClassURL=getResourceAsURL(path,classLoader);
  if (aClassURL == null)   return null;
  if ("String_Node_Str".equals(aClassURL.getProtocol())) {
    try {
      return ((AbstractArchiveFile)FileFactory.getFile(getJarFilePath(aClassURL))).getArchiveEntryFile(path);
    }
 catch (    Exception e) {
      return null;
    }
  }
  return FileFactory.getFile(getLocalFilePath(aClassURL));
}
Program: 45203
Project: 45203
Buggy source:
private static String getThemeName(String path){
  return path.substring(path.lastIndexOf('/') + 1,path.lastIndexOf('.'));
}

Fixed version (ground truth):
private static String getThemeName(AbstractFile themeFile){
  return themeFile.getNameWithoutExtension();
}
Program: 45204
Project: 45204
Buggy source:
private static Iterator predefinedThemeNames(){
  AbstractFile[] files;
  Vector names;
  try {
    files=ResourceLoader.getResourceAsFile(RuntimeConstants.THEMES_PATH).ls(new ExtensionFilenameFilter("String_Node_Str"));
    names=new Vector();
    for (int i=0; i < files.length; i++)     names.add(getThemeName(files[i].getAbsolutePath()));
    return names.iterator();
  }
 catch (  Exception e) {
    return new Vector().iterator();
  }
}

Fixed version (ground truth):
private static Iterator predefinedThemeNames(){
  return getThemeNames(ResourceLoader.getResourceAsFile(RuntimeConstants.THEMES_PATH));
}
Program: 45205
Project: 45205
Buggy source:
private static Iterator customThemeNames(){
  String[] files;
  Vector names;
  names=new Vector();
  files=getCustomThemesFolder().list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.toLowerCase().endsWith("String_Node_Str");
    }
  }
);
  for (int i=0; i < files.length; i++)   names.add(getThemeName(files[i]));
  return names.iterator();
}

Fixed version (ground truth):
private static Iterator customThemeNames(){
  return getThemeNames(FileFactory.getFile(getCustomThemesFolder().getAbsolutePath()));
}
Program: 45206
Project: 45206
Buggy source:
/** 
 * Overridden for performance reasons.
 */
public boolean isOpaque(){
  if (gradient == null) {
    Color back;
    Component p;
    back=lastBackgroundColor;
    if ((p=getParent()) != null)     p=p.getParent();
    return !((back != null) && (p != null) && back.equals(p.getBackground())&& p.isOpaque());
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Overridden for performance reasons.
 */
public boolean isOpaque(){
  if (gradientColor == null) {
    Color back;
    Component p;
    back=lastBackgroundColor;
    if ((p=getParent()) != null)     p=p.getParent();
    return !((back != null) && (p != null) && back.equals(p.getBackground())&& p.isOpaque());
  }
  return false;
}
Program: 45207
Project: 45207
Buggy source:
/** 
 * Paints the label.
 * @param g where to paint the label.
 */
public void paint(Graphics g){
  if (gradient != null) {
    Graphics2D g2;
    Paint oldPaint;
    g2=(Graphics2D)g;
    oldPaint=g2.getPaint();
    g2.setPaint(gradient);
    g2.fillRect(0,0,getWidth(),getHeight());
    g2.setPaint(oldPaint);
  }
  super.paint(g);
  if (outlineColor != null && !outlineColor.equals(lastBackgroundColor)) {
    g.setColor(outlineColor);
    g.drawLine(0,0,getWidth(),0);
    g.drawLine(0,getHeight() - 1,getWidth(),getHeight() - 1);
  }
}

Fixed version (ground truth):
/** 
 * Paints the label.
 * @param g where to paint the label.
 */
public void paint(Graphics g){
  if (gradientColor != null) {
    Graphics2D g2;
    Paint oldPaint;
    g2=(Graphics2D)g;
    oldPaint=g2.getPaint();
    g2.setPaint(new GradientPaint(0,0,lastBackgroundColor,0,getHeight(),gradientColor,false));
    g2.fillRect(0,0,getWidth(),getHeight());
    g2.setPaint(oldPaint);
  }
  super.paint(g);
  if (outlineColor != null && !outlineColor.equals(lastBackgroundColor)) {
    g.setColor(outlineColor);
    g.drawLine(0,0,getWidth(),0);
    g.drawLine(0,getHeight() - 1,getWidth(),getHeight() - 1);
  }
}
Program: 45208
Project: 45208
Buggy source:
/** 
 * Sets the background to a gradient between the two specified colors.
 * @param c1 first component of the gradient.
 * @param c2 second component of the gradient.
 */
public void setBackground(Color c1,Color c2){
  if (c1.equals(c2))   setBackground(c1);
 else {
    lastBackgroundColor=c1;
    gradient=new GradientPaint(0,0,c1,0,getHeight(),c2,false);
  }
}

Fixed version (ground truth):
/** 
 * Sets the background to a gradient between the two specified colors.
 * @param c1 first component of the gradient.
 * @param c2 second component of the gradient.
 */
public void setBackground(Color c1,Color c2){
  if (c1.equals(c2))   setBackground(c1);
 else {
    lastBackgroundColor=c1;
    gradientColor=c2;
  }
}
Program: 45209
Project: 45209
Buggy source:
/** 
 * Updates the divider component's location to keep the current proportional divider location. 
 */
public void updateDividerLocation(){
  if (!window.isVisible())   return;
  setDividerLocation((int)(splitRatio * (getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight())));
  lastDividerLocation=getDividerLocation();
}

Fixed version (ground truth):
/** 
 * Updates the divider component's location to keep the current proportional divider location. 
 */
public void updateDividerLocation(){
  if (!window.isVisible())   return;
  lastDividerLocation=-1;
  setDividerLocation((int)(splitRatio * (getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight())));
}
Program: 45210
Project: 45210
Buggy source:
/** 
 * Sets the constant, proportional divider's location. The given float but be comprised between 0 and 1, 0 meaning completely left (or top), 1 right completely (or bottom).   
 * @param splitRatio the proportional divider's location, comprised between 0 and 1.
 */
public void setSplitRatio(float splitRatio){
  this.splitRatio=splitRatio;
  lastDividerLocation=-1;
  updateDividerLocation();
}

Fixed version (ground truth):
/** 
 * Sets the constant, proportional divider's location. The given float but be comprised between 0 and 1, 0 meaning completely left (or top), 1 right completely (or bottom).   
 * @param splitRatio the proportional divider's location, comprised between 0 and 1.
 */
public void setSplitRatio(float splitRatio){
  this.splitRatio=splitRatio;
  updateDividerLocation();
}
Program: 45211
Project: 45211
Buggy source:
public void componentMoved(ComponentEvent e){
  Object source=e.getSource();
  if (source == getDividerComponent()) {
    if (lastDividerLocation == -1 || lastDividerLocation == getDividerLocation()) {
      return;
    }
    lastDividerLocation=getDividerLocation();
    splitRatio=lastDividerLocation / (float)(getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight());
  }
}

Fixed version (ground truth):
public void componentMoved(ComponentEvent e){
  if (e.getSource() == getDividerComponent()) {
    if (lastDividerLocation == -1) {
      lastDividerLocation=getDividerLocation();
      return;
    }
 else     if (lastDividerLocation == getDividerLocation())     return;
    lastDividerLocation=getDividerLocation();
    splitRatio=lastDividerLocation / (float)(getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight());
  }
}
Program: 45212
Project: 45212
Buggy source:
/** 
 * Creates a new LocationComboBox for use in the given FolderPanel.
 * @param folderPanel FolderPanel this combo box is displayed in
 */
public LocationComboBox(FolderPanel folderPanel){
  super(new ProgressTextField(0,ThemeManager.getCurrentColor(Theme.LOCATION_BAR_PROGRESS_COLOR)));
  this.folderPanel=folderPanel;
  this.locationField=(ProgressTextField)getTextField();
  locationField.setComboBox(this);
  setFont(ThemeManager.getCurrentFont(Theme.LOCATION_BAR_FONT));
  setForeground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_FOREGROUND_COLOR));
  setBackground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_BACKGROUND_COLOR));
  setSelectionForeground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_SELECTED_FOREGROUND_COLOR));
  setSelectionBackground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_SELECTED_BACKGROUND_COLOR));
  addEditableComboBoxListener(this);
  folderPanel.getLocationManager().addLocationListener(this);
  locationField.addFocusListener(this);
  addFocusListener(this);
  ThemeManager.addCurrentThemeListener(this);
}

Fixed version (ground truth):
/** 
 * Creates a new LocationComboBox for use in the given FolderPanel.
 * @param folderPanel FolderPanel this combo box is displayed in
 */
public LocationComboBox(FolderPanel folderPanel){
  super(new ProgressTextField(0,ThemeManager.getCurrentColor(Theme.LOCATION_BAR_PROGRESS_COLOR)));
  this.folderPanel=folderPanel;
  this.locationField=(ProgressTextField)getTextField();
  locationField.setComboBox(this);
  setFont(ThemeManager.getCurrentFont(Theme.LOCATION_BAR_FONT));
  locationField.setDisabledTextColor(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_FOREGROUND_COLOR));
  setForeground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_FOREGROUND_COLOR));
  setBackground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_BACKGROUND_COLOR));
  setSelectionForeground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_SELECTED_FOREGROUND_COLOR));
  setSelectionBackground(ThemeManager.getCurrentColor(Theme.LOCATION_BAR_SELECTED_BACKGROUND_COLOR));
  addEditableComboBoxListener(this);
  folderPanel.getLocationManager().addLocationListener(this);
  locationField.addFocusListener(this);
  addFocusListener(this);
  ThemeManager.addCurrentThemeListener(this);
}
Program: 45213
Project: 45213
Buggy source:
/** 
 * Receives theme color changes notifications.
 */
public void colorChanged(ColorChangedEvent event){
switch (event.getColorId()) {
case Theme.LOCATION_BAR_PROGRESS_COLOR:
    locationField.setProgressColor(event.getColor());
  break;
case Theme.LOCATION_BAR_FOREGROUND_COLOR:
setForeground(event.getColor());
break;
case Theme.LOCATION_BAR_BACKGROUND_COLOR:
setBackground(event.getColor());
break;
case Theme.LOCATION_BAR_SELECTED_FOREGROUND_COLOR:
setSelectionForeground(event.getColor());
break;
case Theme.LOCATION_BAR_SELECTED_BACKGROUND_COLOR:
setSelectionBackground(event.getColor());
break;
}
}

Fixed version (ground truth):
/** 
 * Receives theme color changes notifications.
 */
public void colorChanged(ColorChangedEvent event){
switch (event.getColorId()) {
case Theme.LOCATION_BAR_PROGRESS_COLOR:
    locationField.setProgressColor(event.getColor());
  break;
case Theme.LOCATION_BAR_FOREGROUND_COLOR:
locationField.setDisabledTextColor(event.getColor());
setForeground(event.getColor());
break;
case Theme.LOCATION_BAR_BACKGROUND_COLOR:
setBackground(event.getColor());
break;
case Theme.LOCATION_BAR_SELECTED_FOREGROUND_COLOR:
setSelectionForeground(event.getColor());
break;
case Theme.LOCATION_BAR_SELECTED_BACKGROUND_COLOR:
setSelectionBackground(event.getColor());
break;
}
}
Program: 45214
Project: 45214
Buggy source:
public void setFont(Font font){
  if (renderer == null)   super.setFont(font);
 else {
    renderer.setFont(font);
    textField.setFont(font);
  }
}

Fixed version (ground truth):
public void setFont(Font font){
  super.setFont(font);
  if (renderer != null) {
    renderer.setFont(font);
    textField.setFont(font);
  }
}
Program: 45215
Project: 45215
Buggy source:
/** 
 * Initialises the panel's UI.
 */
private void initUI(){
  YBoxPanel mainPanel;
  ProportionalGridPanel gridPanel;
  JPanel colorsPanel;
  FontChooser fontChooser;
  JPanel wrapper;
  JPanel previewPanel;
  fontChooser=createFontChooser("String_Node_Str",ThemeData.EDITOR_FONT);
  gridPanel=new ProportionalGridPanel(4);
  addLabelRow(gridPanel);
  createButtons(gridPanel,fontChooser,"String_Node_Str",ThemeData.EDITOR_FOREGROUND_COLOR,ThemeData.EDITOR_BACKGROUND_COLOR);
  createButtons(gridPanel,fontChooser,"String_Node_Str",ThemeData.EDITOR_SELECTED_FOREGROUND_COLOR,ThemeData.EDITOR_SELECTED_BACKGROUND_COLOR);
  colorsPanel=new JPanel(new FlowLayout(FlowLayout.LEFT));
  colorsPanel.add(gridPanel);
  colorsPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("String_Node_Str")));
  mainPanel=new YBoxPanel();
  mainPanel.add(fontChooser);
  mainPanel.addSpace(10);
  mainPanel.add(colorsPanel);
  previewPanel=new JPanel();
  previewPanel.add(createPreviewPanel(mainPanel.getPreferredSize().height));
  previewPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("String_Node_Str")));
  addFontChooserListener(fontChooser,preview);
  wrapper=new JPanel(new BorderLayout());
  wrapper.add(mainPanel,BorderLayout.CENTER);
  wrapper.add(previewPanel,BorderLayout.EAST);
  setLayout(new BorderLayout());
  add(wrapper,BorderLayout.NORTH);
}

Fixed version (ground truth):
/** 
 * Initialises the panel's UI.
 */
private void initUI(){
  YBoxPanel mainPanel;
  ProportionalGridPanel gridPanel;
  JPanel colorsPanel;
  FontChooser fontChooser;
  JPanel wrapper;
  JPanel previewPanel;
  JScrollPane scroll;
  fontChooser=createFontChooser("String_Node_Str",ThemeData.EDITOR_FONT);
  gridPanel=new ProportionalGridPanel(3);
  gridPanel.add(new JLabel());
  gridPanel.add(createCaptionLabel("String_Node_Str"));
  gridPanel.add(createCaptionLabel("String_Node_Str"));
  createTextButtons(gridPanel,fontChooser,"String_Node_Str",ThemeData.EDITOR_FOREGROUND_COLOR,ThemeData.EDITOR_BACKGROUND_COLOR);
  createTextButtons(gridPanel,fontChooser,"String_Node_Str",ThemeData.EDITOR_SELECTED_FOREGROUND_COLOR,ThemeData.EDITOR_SELECTED_BACKGROUND_COLOR);
  colorsPanel=new JPanel(new FlowLayout(FlowLayout.LEFT));
  colorsPanel.add(gridPanel);
  colorsPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("String_Node_Str")));
  mainPanel=new YBoxPanel();
  mainPanel.add(fontChooser);
  mainPanel.addSpace(10);
  mainPanel.add(colorsPanel);
  previewPanel=new JPanel();
  previewPanel.add(createPreviewPanel(mainPanel.getPreferredSize().height));
  previewPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("String_Node_Str")));
  addFontChooserListener(fontChooser,preview);
  wrapper=new JPanel(new BorderLayout());
  wrapper.add(mainPanel,BorderLayout.CENTER);
  wrapper.add(previewPanel,BorderLayout.EAST);
  setLayout(new BorderLayout());
  add(wrapper,BorderLayout.NORTH);
}
Program: 45216
Project: 45216
Buggy source:
public void commit(){
}

Fixed version (ground truth):
/** 
 * Ignored.
 */
public void commit(){
}
Program: 45217
Project: 45217
Buggy source:
public void propertyChange(PropertyChangeEvent event){
  if (event.getPropertyName().equals(PreviewLabel.BACKGROUND_COLOR_PROPERTY_NAME)) {
    preview.setBackground(template.getColor(ThemeData.EDITOR_BACKGROUND_COLOR));
    preview.setSelectionColor(template.getColor(ThemeData.EDITOR_SELECTED_BACKGROUND_COLOR));
  }
 else   if (!event.getPropertyName().equals(PreviewLabel.FOREGROUND_COLOR_PROPERTY_NAME)) {
    preview.setForeground(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
    preview.setSelectedTextColor(template.getColor(ThemeData.EDITOR_SELECTED_FOREGROUND_COLOR));
    preview.setCaretColor(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
  }
  preview.repaint();
}

Fixed version (ground truth):
/** 
 * Listens on changes on the foreground and background colors.
 */
public void propertyChange(PropertyChangeEvent event){
  if (event.getPropertyName().equals(PreviewLabel.BACKGROUND_COLOR_PROPERTY_NAME)) {
    preview.setBackground(template.getColor(ThemeData.EDITOR_BACKGROUND_COLOR));
    preview.setSelectionColor(template.getColor(ThemeData.EDITOR_SELECTED_BACKGROUND_COLOR));
  }
 else   if (!event.getPropertyName().equals(PreviewLabel.FOREGROUND_COLOR_PROPERTY_NAME)) {
    preview.setForeground(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
    preview.setSelectedTextColor(template.getColor(ThemeData.EDITOR_SELECTED_FOREGROUND_COLOR));
    preview.setCaretColor(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
  }
 else   return;
  preview.repaint();
}
Program: 45218
Project: 45218
Buggy source:
private JScrollPane createPreviewPanel(int preferredHeight){
  JScrollPane scroll;
  preview=new JTextArea(15,15);
  scroll=new JScrollPane(preview,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scroll.getViewport().setPreferredSize(new Dimension(preview.getPreferredSize().width,preferredHeight));
  preview.setText(Translator.get("String_Node_Str"));
  preview.setBackground(template.getColor(ThemeData.EDITOR_BACKGROUND_COLOR));
  preview.setSelectionColor(template.getColor(ThemeData.EDITOR_SELECTED_BACKGROUND_COLOR));
  preview.setForeground(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
  preview.setSelectedTextColor(template.getColor(ThemeData.EDITOR_SELECTED_FOREGROUND_COLOR));
  preview.setCaretColor(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
  preview.setFont(template.getFont(ThemeData.EDITOR_FONT));
  return scroll;
}

Fixed version (ground truth):
/** 
 * Creates the file editor preview panel.
 */
private JScrollPane createPreviewPanel(int preferredHeight){
  JScrollPane scroll;
  preview=new JTextArea(15,15);
  scroll=new JScrollPane(preview,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scroll.getViewport().setPreferredSize(new Dimension(preview.getPreferredSize().width,preferredHeight));
  preview.setText(Translator.get("String_Node_Str"));
  preview.setBackground(template.getColor(ThemeData.EDITOR_BACKGROUND_COLOR));
  preview.setSelectionColor(template.getColor(ThemeData.EDITOR_SELECTED_BACKGROUND_COLOR));
  preview.setForeground(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
  preview.setSelectedTextColor(template.getColor(ThemeData.EDITOR_SELECTED_FOREGROUND_COLOR));
  preview.setCaretColor(template.getColor(ThemeData.EDITOR_FOREGROUND_COLOR));
  preview.setFont(template.getFont(ThemeData.EDITOR_FONT));
  return scroll;
}
Program: 45219
Project: 45219
Buggy source:
/** 
 * Stops dimming the scrollpane's background (returns to a normal background color), called by  {@link com.mucommander.ui.main.table.FileTable.QuickSearch} when a quick search is over.
 */
public void undimBackground(){
  if (fileTable.hasFocus())   scrollPane.getViewport().setBackground(backgroundColor);
 else   scrollPane.getViewport().setBackground(unfocusedBackgroundColor);
}

Fixed version (ground truth):
/** 
 * Stops dimming the scrollpane's background (returns to a normal background color), called by  {@link com.mucommander.ui.main.table.FileTable.QuickSearch} when a quick search is over.
 */
public void undimBackground(){
  Color newColor;
  if (fileTable.hasFocus())   newColor=backgroundColor;
 else   newColor=unfocusedBackgroundColor;
  if (newColor.equals(scrollPane.getViewport().getBackground()))   fileTable.repaint();
 else   scrollPane.getViewport().setBackground(newColor);
}
Program: 45222
Project: 45222
Buggy source:
public Object clone(){
  PreviewLabel previewLabel=new PreviewLabel();
  previewLabel.setText(getText());
  previewLabel.setForeground(getForeground());
  previewLabel.setBackground(getBackground());
  previewLabel.setOverlayUnderText(overlayUnderText);
  previewLabel.putClientProperty(OVERLAY_COLOR_PROPERTY_NAME,getClientProperty(OVERLAY_COLOR_PROPERTY_NAME));
  previewLabel.putClientProperty(BORDER_COLOR_PROPERTY_NAME,getClientProperty(BORDER_COLOR_PROPERTY_NAME));
  return previewLabel;
}

Fixed version (ground truth):
public Object clone(){
  PreviewLabel previewLabel=new PreviewLabel();
  previewLabel.setText(getText());
  previewLabel.setForeground(getForeground());
  previewLabel.setBackground(getBackground());
  previewLabel.setOverlayUnderText(overlayUnderText);
  previewLabel.setFont(getFont());
  previewLabel.putClientProperty(OVERLAY_COLOR_PROPERTY_NAME,getClientProperty(OVERLAY_COLOR_PROPERTY_NAME));
  previewLabel.putClientProperty(BORDER_COLOR_PROPERTY_NAME,getClientProperty(BORDER_COLOR_PROPERTY_NAME));
  return previewLabel;
}
Program: 45223
Project: 45223
Buggy source:
public void execute() throws BuildException {
  if (with == null)   throw new BuildException("String_Node_Str");
  if (what == null)   throw new BuildException("String_Node_Str");
  if (from == null)   throw new BuildException("String_Node_Str");
  if (to == null)   throw new BuildException("String_Node_Str");
  getProject().setProperty(to,from.replaceAll(what,with));
}

Fixed version (ground truth):
public void execute() throws BuildException {
  if (with == null)   throw new BuildException("String_Node_Str");
  if (what == null)   throw new BuildException("String_Node_Str");
  if (from == null)   throw new BuildException("String_Node_Str");
  if (to == null)   throw new BuildException("String_Node_Str");
  getProject().setNewProperty(to,from.replaceAll(what,with));
}
Program: 45224
Project: 45224
Buggy source:
/** 
 * Changes current folder, keeping current selection if folder hasn't changed. Should only be called by FolderPanel!
 */
public synchronized void setCurrentFolder(AbstractFile folder,AbstractFile children[]){
  AbstractFile current;
  FileSet markedFiles;
  AbstractFile selectedFile;
  quickSearch.cancel();
  currentFolder=folder;
  current=getCurrentFolder();
  markedFiles=null;
  selectedFile=null;
  if (current != null && folder.equals(current)) {
    markedFiles=tableModel.getMarkedFiles();
    selectedFile=getSelectedFile();
  }
 else   if (tableModel.hasParentFolder() && folder.equals(tableModel.getParentFolder()))   selectedFile=current;
  SwingUtilities.invokeLater(new FolderChangeThread(folder,children,markedFiles,selectedFile));
}

Fixed version (ground truth):
/** 
 * Changes current folder, keeping current selection if folder hasn't changed. Should only be called by FolderPanel!
 */
public synchronized void setCurrentFolder(AbstractFile folder,AbstractFile children[]){
  AbstractFile current;
  FileSet markedFiles;
  AbstractFile selectedFile;
  quickSearch.cancel();
  current=getCurrentFolder();
  currentFolder=folder;
  markedFiles=null;
  selectedFile=null;
  if (current != null && folder.equals(current)) {
    markedFiles=tableModel.getMarkedFiles();
    selectedFile=getSelectedFile();
  }
 else   if (tableModel.hasParentFolder() && folder.equals(tableModel.getParentFolder()))   selectedFile=current;
  SwingUtilities.invokeLater(new FolderChangeThread(folder,children,markedFiles,selectedFile));
}
Program: 45226
Project: 45226
Buggy source:
/** 
 * Skips (up to) the specified number of bytes and returns the number of bytes effectively skipped. The exact given number of bytes will be skipped as long as the current offset as returned by   {@link #getOffset()}plus the number of bytes to skip doesn't exceed the length of this stream as returned by   {@link #getLength()}. If it does, all the remaining bytes will be skipped so that the offset of this stream will be positionned to  {@link #getLength()}.
 * @param n number of bytes to skip
 * @return the number of bytes that have effectively been skipped
 * @throws IOException if something went wrong
 */
public long skip(long n) throws IOException {
  long offset=getOffset();
  if (offset + n >= getLength()) {
    seek(getLength() - 1);
    return getLength() - offset - 1;
  }
  seek(n);
  return n;
}

Fixed version (ground truth):
/** 
 * Skips (up to) the specified number of bytes and returns the number of bytes effectively skipped. The exact given number of bytes will be skipped as long as the current offset as returned by   {@link #getOffset()}plus the number of bytes to skip doesn't exceed the length of this stream as returned by   {@link #getLength()}. If it does, all the remaining bytes will be skipped so that the offset of this stream will be positionned to  {@link #getLength()}.
 * @param n number of bytes to skip
 * @return the number of bytes that have effectively been skipped
 * @throws IOException if something went wrong
 */
public long skip(long n) throws IOException {
  long offset=getOffset();
  long length=getLength();
  if (offset + n >= length) {
    seek(length - 1);
    return length - offset - 1;
  }
  seek(offset + n);
  return n;
}
Program: 45228
Project: 45228
Buggy source:
private static Reader getStreamReader(InputStream in,String encoding){
  if (encoding != null) {
    try {
      return new InputStreamReader(in,encoding);
    }
 catch (    Exception e) {
    }
  }
  return new InputStreamReader(in);
}

Fixed version (ground truth):
private static Reader getStreamReader(InputStream in,String encoding){
  if (encoding != null) {
    try {
      return new InputStreamReader(in,encoding);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  return new InputStreamReader(in);
}
Program: 45229
Project: 45229
Buggy source:
/** 
 * Extracts the shell command from configuration.
 */
private static synchronized void setShellCommand(){
  String buffer;
  if (ConfigurationManager.getVariableBoolean(ConfigurationVariables.USE_CUSTOM_SHELL,ConfigurationVariables.DEFAULT_USE_CUSTOM_SHELL))   buffer=ConfigurationManager.getVariable(ConfigurationVariables.CUSTOM_SHELL,PlatformManager.DEFAULT_SHELL_COMMAND);
 else   buffer=PlatformManager.DEFAULT_SHELL_COMMAND;
  tokens=CommandParser.getTokensWithParams(buffer,1);
  encoding=ConfigurationManager.getVariable(ConfigurationVariables.SHELL_ENCODING,PlatformManager.DEFAULT_SHELL_ENCODING);
}

Fixed version (ground truth):
/** 
 * Extracts the shell command from configuration.
 */
private static synchronized void setShellCommand(){
  String buffer;
  if (ConfigurationManager.getVariableBoolean(ConfigurationVariables.USE_CUSTOM_SHELL,ConfigurationVariables.DEFAULT_USE_CUSTOM_SHELL))   buffer=ConfigurationManager.getVariable(ConfigurationVariables.CUSTOM_SHELL,PlatformManager.DEFAULT_SHELL_COMMAND);
 else   buffer=PlatformManager.DEFAULT_SHELL_COMMAND;
  tokens=CommandParser.getTokensWithParams(buffer,1);
  encoding=ConfigurationManager.getVariable(ConfigurationVariables.SHELL_ENCODING);
}