nus-yam/ex-repair huggingface dataset:
Program: 45230
Project: 45230
Buggy source:
/** 
 * Executes the specified command in the specified folder. <p> The <code>currentFolder</code> folder parameter will only be used if it's neither a remote directory nor an archive. Otherwise, the command will run from the user's home directory. </p> <p> Information about the resulting process will be sent to the specified <code>listener</code>. </p>
 * @param command       command to run.
 * @param currentFolder where to run the command from.
 * @param listener      where to send information about the resulting process.
 * @return                  the resulting process.
 * @exception IOException   thrown if any error occurs while trying to run the command.
 */
public static synchronized AbstractProcess execute(String command,AbstractFile currentFolder,ProcessListener listener) throws IOException {
  String[] commandTokens;
  if (Debug.ON)   Debug.trace("String_Node_Str" + command);
  ShellHistoryManager.add(command);
  if (currentFolder instanceof LocalFile || !currentFolder.canRunProcess()) {
    tokens[tokens.length - 1]=command;
    commandTokens=tokens;
  }
 else {
    remoteTokens[0]=command;
    commandTokens=remoteTokens;
  }
  return ProcessRunner.execute(commandTokens,currentFolder,listener,encoding);
}

Fixed version (ground truth):
/** 
 * Executes the specified command in the specified folder. <p> The <code>currentFolder</code> folder parameter will only be used if it's neither a remote directory nor an archive. Otherwise, the command will run from the user's home directory. </p> <p> Information about the resulting process will be sent to the specified <code>listener</code>. </p>
 * @param command       command to run.
 * @param currentFolder where to run the command from.
 * @param listener      where to send information about the resulting process.
 * @return                  the resulting process.
 * @exception IOException   thrown if any error occurs while trying to run the command.
 */
public static synchronized AbstractProcess execute(String command,AbstractFile currentFolder,ProcessListener listener) throws IOException {
  String[] commandTokens;
  if (Debug.ON)   Debug.trace("String_Node_Str" + command);
  ShellHistoryManager.add(command);
  if (currentFolder instanceof LocalFile || !currentFolder.canRunProcess()) {
    tokens[tokens.length - 1]=command;
    commandTokens=tokens;
  }
 else {
    remoteTokens[0]=command;
    commandTokens=remoteTokens;
  }
  return (encoding == null) ? ProcessRunner.execute(commandTokens,currentFolder,listener) : ProcessRunner.execute(commandTokens,currentFolder,listener,encoding);
}
Program: 45232
Project: 45232
Buggy source:
public void performAction(){
  FileTable fileTable=mainFrame.getActiveTable();
  FileTableModel tableModel=fileTable.getFileTableModel();
  int nbRows=tableModel.getRowCount();
  for (int i=fileTable.getParent() == null ? 0 : 1; i < nbRows; i++)   tableModel.setRowMarked(i,true);
  fileTable.repaint();
  fileTable.fireMarkedFilesChangedEvent();
}

Fixed version (ground truth):
public void performAction(){
  FileTable fileTable=mainFrame.getActiveTable();
  FileTableModel tableModel=fileTable.getFileTableModel();
  int nbRows=tableModel.getRowCount();
  for (int i=fileTable.getCurrentFolder().getParent() == null ? 0 : 1; i < nbRows; i++)   tableModel.setRowMarked(i,true);
  fileTable.repaint();
  fileTable.fireMarkedFilesChangedEvent();
}
Program: 45233
Project: 45233
Buggy source:
public void performAction(){
  FileTable fileTable=mainFrame.getActiveTable();
  FileTableModel tableModel=fileTable.getFileTableModel();
  int nbRows=tableModel.getRowCount();
  for (int i=fileTable.getParent() == null ? 0 : 1; i < nbRows; i++)   tableModel.setRowMarked(i,false);
  fileTable.repaint();
  fileTable.fireMarkedFilesChangedEvent();
}

Fixed version (ground truth):
public void performAction(){
  FileTable fileTable=mainFrame.getActiveTable();
  FileTableModel tableModel=fileTable.getFileTableModel();
  int nbRows=tableModel.getRowCount();
  for (int i=fileTable.getCurrentFolder().getParent() == null ? 0 : 1; i < nbRows; i++)   tableModel.setRowMarked(i,false);
  fileTable.repaint();
  fileTable.fireMarkedFilesChangedEvent();
}
Program: 45234
Project: 45234
Buggy source:
public boolean canRunProcess(){
  return true;
}

Fixed version (ground truth):
public boolean canRunProcess(){
  return false;
}
Program: 45235
Project: 45235
Buggy source:
private SFTPProcess(String tokens[]) throws IOException {
  try {
    connHandler=(SFTPConnectionHandler)ConnectionPool.getConnectionHandler(SFTPFile.this,fileURL,true);
    connHandler.checkConnection();
    sessionClient=connHandler.sshClient.openSessionChannel();
    String command="String_Node_Str";
    int nbTokens=tokens.length;
    for (int i=0; i < nbTokens; i++) {
      command+=tokens[i];
      if (i != nbTokens - 1)       command+="String_Node_Str";
    }
    success=sessionClient.executeCommand(command);
    if (Debug.ON)     Debug.trace("String_Node_Str" + command + "String_Node_Str"+ success);
  }
 catch (  IOException e) {
    connHandler.releaseLock();
    sessionClient.close();
  }
}

Fixed version (ground truth):
private SFTPProcess(String tokens[]) throws IOException {
  try {
    connHandler=(SFTPConnectionHandler)ConnectionPool.getConnectionHandler(SFTPFile.this,fileURL,true);
    connHandler.checkConnection();
    sessionClient=connHandler.sshClient.openSessionChannel();
    String command="String_Node_Str";
    int nbTokens=tokens.length;
    for (int i=0; i < nbTokens; i++) {
      command+=tokens[i];
      if (i != nbTokens - 1)       command+="String_Node_Str";
    }
    success=sessionClient.executeCommand(command);
    if (Debug.ON)     Debug.trace("String_Node_Str" + command + "String_Node_Str"+ success);
  }
 catch (  IOException e) {
    connHandler.releaseLock();
    sessionClient.close();
    throw e;
  }
}
Program: 45236
Project: 45236
Buggy source:
/** 
 * Overrident method to close connection to the mail server.
 */
protected void jobStopped(){
  super.jobStopped();
  closeConnection();
}

Fixed version (ground truth):
/** 
 * Method overridden to close connection to the mail server.
 */
protected void jobStopped(){
  super.jobStopped();
  closeConnection();
}
Program: 45237
Project: 45237
Buggy source:
protected boolean processFile(AbstractFile file,Object recurseParams){
  if (getState() == INTERRUPTED)   return false;
  try {
    return sendAttachment(file);
  }
 catch (  IOException e) {
    showErrorDialog(Translator.get("String_Node_Str",file.getName()));
    return false;
  }
}

Fixed version (ground truth):
protected boolean processFile(AbstractFile file,Object recurseParams){
  if (getState() == INTERRUPTED)   return false;
  try {
    sendAttachment(file);
  }
 catch (  IOException e) {
    showErrorDialog(Translator.get("String_Node_Str",file.getName()));
    return false;
  }
  if (getCurrentFileIndex() == getNbFiles() - 1) {
    try {
      sayGoodBye();
    }
 catch (    IOException e) {
      showErrorDialog(Translator.get("String_Node_Str"));
      return false;
    }
  }
  return true;
}
Program: 45238
Project: 45238
Buggy source:
/** 
 * Send file as attachment encoded in Base64, and returns true if file was successfully and completely transferred.
 */
private boolean sendAttachment(AbstractFile file) throws IOException {
  InputStream fileIn=null;
  try {
    String mimeType=MimeTypes.getMimeType(file);
    if (mimeType == null)     mimeType="String_Node_Str";
    writeLine("String_Node_Str" + mimeType + "String_Node_Str"+ file.getName());
    writeLine("String_Node_Str" + file.getName() + "String_Node_Str");
    writeLine("String_Node_Str");
    fileIn=setCurrentInputStream(file.getInputStream());
    AbstractFile.copyStream(fileIn,out64);
    out64.writePadding();
    writeLine("String_Node_Str" + boundary);
    return true;
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    if (fileIn != null)     fileIn.close();
  }
}

Fixed version (ground truth):
/** 
 * Send file as attachment encoded in Base64, and returns true if file was successfully and completely transferred.
 */
private void sendAttachment(AbstractFile file) throws IOException {
  InputStream fileIn=null;
  try {
    String mimeType=MimeTypes.getMimeType(file);
    if (mimeType == null)     mimeType="String_Node_Str";
    writeLine("String_Node_Str" + mimeType + "String_Node_Str"+ file.getName());
    writeLine("String_Node_Str" + file.getName() + "String_Node_Str");
    writeLine("String_Node_Str");
    fileIn=setCurrentInputStream(file.getInputStream());
    AbstractFile.copyStream(fileIn,out64);
    out64.writePadding();
    writeLine("String_Node_Str" + boundary);
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    if (fileIn != null)     fileIn.close();
  }
}
Program: 45239
Project: 45239
Buggy source:
/** 
 * TransferFileJob methods implementation 
 */
public String getStatusString(){
  if (connectedToMailServer)   return Translator.get("String_Node_Str",getCurrentFileInfo());
 else   return Translator.get("String_Node_Str",mailServer);
}

Fixed version (ground truth):
public String getStatusString(){
  if (connectedToMailServer)   return Translator.get("String_Node_Str",getCurrentFileInfo());
 else   return Translator.get("String_Node_Str",mailServer);
}
Program: 45240
Project: 45240
Buggy source:
/** 
 * Creates a new local process running the specified command.
 * @param tokens      command to run and its parameters.
 * @param dir         directory in which to start the command.
 * @return             the newly created process.
 * @throws IOException if the process could not be created.
 */
public LocalProcess(String[] tokens,File dir) throws IOException {
  if (PlatformManager.JAVA_VERSION >= PlatformManager.JAVA_1_5) {
    ProcessBuilder pb=new ProcessBuilder(tokens);
    pb.directory(dir);
    pb.redirectErrorStream(true);
    process=pb.start();
  }
 else   process=Runtime.getRuntime().exec(tokens,null,dir);
  if (process == null)   throw new IOException();
}

Fixed version (ground truth):
/** 
 * Creates a new local process running the specified command.
 * @param tokens      command to run and its parameters.
 * @param dir         directory in which to start the command.
 * @throws IOException if the process could not be created.
 */
public LocalProcess(String[] tokens,File dir) throws IOException {
  if (PlatformManager.JAVA_VERSION >= PlatformManager.JAVA_1_5) {
    ProcessBuilder pb=new ProcessBuilder(tokens);
    pb.directory(dir);
    pb.redirectErrorStream(true);
    process=pb.start();
  }
 else   process=Runtime.getRuntime().exec(tokens,null,dir);
  if (process == null)   throw new IOException();
}
Program: 45241
Project: 45241
Buggy source:
/** 
 * Creates a new ViewerFrame to start viewing the given file. <p>This constructor has package access only, ViewerFrame need to be created can  {@link ViewerRegistrar#getViewerFrame(AbstractFile) ViewerRegistrar.getViewerFrame(AbstractFile)}. 
 */
ViewerFrame(MainFrame mainFrame,AbstractFile file,Image icon){
  super();
  setIconImage(icon);
  this.mainFrame=mainFrame;
  this.file=file;
  this.menuMnemonicHelper=new MnemonicHelper();
  MnemonicHelper menuItemMnemonicHelper=new MnemonicHelper();
  this.menuBar=new JMenuBar();
  JMenu menu=addMenu(Translator.get("String_Node_Str"));
  closeItem=MenuToolkit.addMenuItem(menu,Translator.get("String_Node_Str"),menuItemMnemonicHelper,KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),this);
  menu.add(closeItem);
  setJMenuBar(menuBar);
  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  setResizable(true);
  new Thread(ViewerFrame.this,"String_Node_Str").start();
}

Fixed version (ground truth):
/** 
 * Creates a new ViewerFrame to start viewing the given file. <p>This constructor has package access only, ViewerFrame need to be created can  {@link ViewerRegistrar#createViewerFrame(MainFrame,AbstractFile,Image)}.
 */
ViewerFrame(MainFrame mainFrame,AbstractFile file,Image icon){
  super();
  setIconImage(icon);
  this.mainFrame=mainFrame;
  this.file=file;
  this.menuMnemonicHelper=new MnemonicHelper();
  MnemonicHelper menuItemMnemonicHelper=new MnemonicHelper();
  this.menuBar=new JMenuBar();
  JMenu menu=addMenu(Translator.get("String_Node_Str"));
  closeItem=MenuToolkit.addMenuItem(menu,Translator.get("String_Node_Str"),menuItemMnemonicHelper,KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),this);
  menu.add(closeItem);
  setJMenuBar(menuBar);
  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  setResizable(true);
  new Thread(ViewerFrame.this,"String_Node_Str").start();
}
Program: 45242
Project: 45242
Buggy source:
/** 
 * Changes the current theme. <p> This method will change the current theme and trigger all the proper events. </p>
 * @param theme theme to use as the current theme.
 */
public synchronized static void setCurrentTheme(Theme theme){
  ThemeData oldData;
  if (isCurrentTheme(theme)) {
    setConfigurationTheme(theme);
    return;
  }
  oldData=currentData;
  if ((currentData=theme.getThemeData()) == null)   throw new IllegalStateException("String_Node_Str" + theme.getName());
  setConfigurationTheme(theme);
  for (int i=0; i < Theme.FONT_COUNT; i++) {
    if (oldData.getFont(i) == null) {
      if (currentData.getFont(i) == null)       continue;
    }
 else     if (currentData.getFont(i) != null) {
      if (oldData.getFont(i).equals(currentData.getFont(i)))       continue;
    }
    triggerFontEvent(i,getCurrentFont(i));
  }
  for (int i=0; i < Theme.COLOR_COUNT; i++) {
    if (oldData.getColor(i) == null) {
      if (currentData.getColor(i) == null)       continue;
    }
 else     if (currentData.getColor(i) != null) {
      if (oldData.getColor(i).equals(currentData.getColor(i)))       continue;
    }
    triggerColorEvent(i,getCurrentColor(i));
  }
}

Fixed version (ground truth):
/** 
 * Changes the current theme. <p> This method will change the current theme and trigger all the proper events. </p>
 * @param theme theme to use as the current theme.
 */
public synchronized static void setCurrentTheme(Theme theme){
  ThemeData oldData;
  if (isCurrentTheme(theme)) {
    setConfigurationTheme(theme);
    return;
  }
  oldData=currentData;
  if ((currentData=theme.getThemeData()) == null)   throw new IllegalStateException("String_Node_Str" + theme.getName());
  if (currentType == USER_THEME)   saveUserTheme();
  setConfigurationTheme(theme);
  for (int i=0; i < Theme.FONT_COUNT; i++) {
    if (oldData.getFont(i) == null) {
      if (currentData.getFont(i) == null)       continue;
    }
 else     if (currentData.getFont(i) != null) {
      if (oldData.getFont(i).equals(currentData.getFont(i)))       continue;
    }
    triggerFontEvent(i,getCurrentFont(i));
  }
  for (int i=0; i < Theme.COLOR_COUNT; i++) {
    if (oldData.getColor(i) == null) {
      if (currentData.getColor(i) == null)       continue;
    }
 else     if (currentData.getColor(i) != null) {
      if (oldData.getColor(i).equals(currentData.getColor(i)))       continue;
    }
    triggerColorEvent(i,getCurrentColor(i));
  }
}
Program: 45243
Project: 45243
Buggy source:
public void mousePressed(MouseEvent e){
  int modifiers=e.getModifiers();
  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)) {
    AbstractFile currentFolder=getCurrentFolder();
    new TablePopupMenu(FolderPanel.this.mainFrame,currentFolder,null,false,fileTable.getFileTableModel().getMarkedFiles()).show(scrollPane,e.getX(),e.getY());
  }
}
Program: 45245
Project: 45245
Buggy source:
/** 
 * Creates and returns an AbstractFile using the provided entry and parent file. This method takes care of creating the proper AbstractArchiveFile instance if the entry is itself an archive.
 */
private AbstractFile createArchiveEntryFile(ArchiveEntry entry,AbstractFile parentFile) throws java.net.MalformedURLException {
  String separator=getSeparator();
  FileURL archiveURL=getURL();
  String entryURLString=archiveURL.getStringRep(false);
  if (!entryURLString.endsWith(separator))   entryURLString+=separator;
  entryURLString+=entry.getPath();
  AbstractFile entryFile=FileFactory.wrapArchive(new ArchiveEntryFile(this,entry,URLFactory.getFileURL(entryURLString,archiveURL,true)));
  entryFile.setParent(parentFile);
  return entryFile;
}

Fixed version (ground truth):
/** 
 * Creates and returns an AbstractFile using the provided entry and parent file. This method takes care of creating the proper AbstractArchiveFile instance if the entry is itself an archive.
 */
private AbstractFile createArchiveEntryFile(ArchiveEntry entry,AbstractFile parentFile) throws java.net.MalformedURLException {
  String separator=getSeparator();
  FileURL archiveURL=getURL();
  String entryURLString=archiveURL.getStringRep(false);
  if (!entryURLString.endsWith(separator))   entryURLString+=separator;
  String entryPath=entry.getPath();
  String parentSeparator=parentFile.getSeparator();
  if (!parentSeparator.equals("String_Node_Str"))   entryPath=entryPath.replace("String_Node_Str",parentSeparator);
  entryURLString+=entryPath;
  AbstractFile entryFile=FileFactory.wrapArchive(new ArchiveEntryFile(this,entry,URLFactory.getFileURL(entryURLString,archiveURL,true)));
  entryFile.setParent(parentFile);
  return entryFile;
}
Program: 45246
Project: 45246
Buggy source:
/** 
 * Returns true if the login of the provided credentials (as returned by   {@link #getLogin()} equals to one inthis Credentials instance, false otherwise. Two Credentials instances with the same login but a different password will thus be equal. If null is passed, true will be returned if these Credentials are empty, as returned by  {@link #isEmpty()}.
 */
public boolean equals(Object o){
  if (o == null)   return isEmpty();
  if (!(o instanceof Credentials))   return false;
  Credentials credentials=(Credentials)o;
  return credentials.login.equals(this.login) && credentials.password.equals(this.password);
}

Fixed version (ground truth):
/** 
 * Returns true if the login of the provided credentials (as returned by   {@link #getLogin()} equals to one inthis Credentials instance, false otherwise. Two Credentials instances with the same login but a different password will thus be equal. If null is passed, true will be returned if these Credentials are empty, as returned by  {@link #isEmpty()}.
 */
public boolean equals(Object o){
  if (o == null)   return isEmpty();
  if (!(o instanceof Credentials))   return false;
  Credentials credentials=(Credentials)o;
  return credentials.login.equals(this.login);
}
Program: 45247
Project: 45247
Buggy source:
/** 
 * Pops up the menu and requests focus on the popup menu.
 */
public void popup(){
  rootFolders=RootFolders.getRootFolders();
  popupMenu=new JPopupMenu();
  popupMenu.addPopupMenuListener(this);
  menuItems=new Vector();
  int nbRoots=rootFolders.length;
  if (PlatformManager.isWindowsFamily()) {
    FileSystemView fileSystemView=FileSystemView.getFileSystemView();
    for (int i=0; i < nbRoots; i++) {
      Icon driveIcon=null;
      if (PlatformManager.JAVA_VERSION >= PlatformManager.JAVA_1_4)       driveIcon=fileSystemView.getSystemIcon(new java.io.File(rootFolders[i].getAbsolutePath()));
      addMenuItem(rootFolders[i].getName(),driveIcon);
    }
  }
 else {
    for (int i=0; i < nbRoots; i++)     addMenuItem(rootFolders[i].getName());
  }
  popupMenu.add(new JSeparator());
  this.bookmarksOffset=menuItems.size();
  this.bookmarks=BookmarkManager.getBookmarks();
  int nbBookmarks=bookmarks.size();
  if (nbBookmarks > 0) {
    for (int i=0; i < nbBookmarks; i++)     addMenuItem(((Bookmark)bookmarks.elementAt(i)).getName());
  }
 else {
    addMenuItem(Translator.get("String_Node_Str")).setEnabled(false);
  }
  popupMenu.add(new JSeparator());
  this.serverShortcutsOffset=menuItems.size();
  addMenuItem("String_Node_Str");
  addMenuItem("String_Node_Str");
  addMenuItem("String_Node_Str");
  addMenuItem("String_Node_Str");
  popupMenu.show(this,0,getHeight());
}

Fixed version (ground truth):
/** 
 * Pops up the menu and requests focus on the popup menu.
 */
public void popup(){
  rootFolders=RootFolders.getRootFolders();
  popupMenu=new JPopupMenu();
  popupMenu.addPopupMenuListener(this);
  menuItems=new Vector();
  int nbRoots=rootFolders.length;
  if (PlatformManager.isWindowsFamily()) {
    FileSystemView fileSystemView=FileSystemView.getFileSystemView();
    for (int i=0; i < nbRoots; i++) {
      Icon driveIcon=null;
      if (PlatformManager.JAVA_VERSION >= PlatformManager.JAVA_1_5)       driveIcon=fileSystemView.getSystemIcon(new java.io.File(rootFolders[i].getAbsolutePath()));
      addMenuItem(rootFolders[i].getName(),driveIcon);
    }
  }
 else {
    for (int i=0; i < nbRoots; i++)     addMenuItem(rootFolders[i].getName());
  }
  popupMenu.add(new JSeparator());
  this.bookmarksOffset=menuItems.size();
  this.bookmarks=BookmarkManager.getBookmarks();
  int nbBookmarks=bookmarks.size();
  if (nbBookmarks > 0) {
    for (int i=0; i < nbBookmarks; i++)     addMenuItem(((Bookmark)bookmarks.elementAt(i)).getName());
  }
 else {
    addMenuItem(Translator.get("String_Node_Str")).setEnabled(false);
  }
  popupMenu.add(new JSeparator());
  this.serverShortcutsOffset=menuItems.size();
  addMenuItem("String_Node_Str");
  addMenuItem("String_Node_Str");
  addMenuItem("String_Node_Str");
  addMenuItem("String_Node_Str");
  popupMenu.show(this,0,getHeight());
}
Program: 45248
Project: 45248
Buggy source:
public PsiFile resolve(){
  JavaPsiFacade javaFacade=JavaPsiFacade.getInstance(xav.getProject());
  if (page.startsWith("String_Node_Str")) {
    String pkg=page.substring(1,page.lastIndexOf('/')).replace('/','.');
    PsiPackage jpkg=javaFacade.findPackage(pkg);
    if (jpkg == null)     return null;
    for (    PsiDirectory dir : jpkg.getDirectories()) {
      PsiFile f=dir.findFile(page.substring(page.lastIndexOf('/') + 1));
      if (f != null)       return f;
    }
    return null;
  }
 else {
    PsiFile f=xav.getContainingFile();
    PsiDirectory p=f.getParent();
    if (p == null)     return null;
    PsiFile target=p.findFile(page);
    if (target != null)     return target;
    JavaDirectoryService jds=JavaDirectoryService.getInstance();
    PsiPackage pkg=jds.getPackage(p);
    if (pkg == null)     return null;
    Module m=ModuleUtil.findModuleForFile(f.getVirtualFile(),f.getProject());
    PsiClass c=javaFacade.findClass(pkg.getName(),GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(m));
    if (c == null)     return null;
    c=c.getSuperClass();
    for (; c != null; c=c.getSuperClass()) {
      pkg=javaFacade.findPackage(c.getQualifiedName());
      if (pkg != null) {
        for (        PsiDirectory dir : pkg.getDirectories()) {
          target=dir.findFile(page);
          if (target != null)           return f;
        }
      }
    }
    return null;
  }
}

Fixed version (ground truth):
public PsiFile resolve(){
  JavaPsiFacade javaFacade=JavaPsiFacade.getInstance(xav.getProject());
  if (page.startsWith("String_Node_Str")) {
    String pkg=page.substring(1,page.lastIndexOf('/')).replace('/','.');
    PsiPackage jpkg=javaFacade.findPackage(pkg);
    if (jpkg == null)     return null;
    for (    PsiDirectory dir : jpkg.getDirectories()) {
      PsiFile f=dir.findFile(page.substring(page.lastIndexOf('/') + 1));
      if (f != null)       return f;
    }
    return null;
  }
 else {
    PsiFile f=xav.getContainingFile();
    PsiDirectory p=f.getParent();
    if (p == null)     return null;
    PsiFile target=p.findFile(page);
    if (target != null)     return target;
    JavaDirectoryService jds=JavaDirectoryService.getInstance();
    PsiPackage pkg=jds.getPackage(p);
    if (pkg == null)     return null;
    Module m=ModuleUtil.findModuleForFile(f.getVirtualFile(),f.getProject());
    PsiClass c=javaFacade.findClass(pkg.getQualifiedName(),GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(m));
    if (c == null)     return null;
    c=c.getSuperClass();
    for (; c != null; c=c.getSuperClass()) {
      pkg=javaFacade.findPackage(c.getQualifiedName());
      if (pkg != null) {
        for (        PsiDirectory dir : pkg.getDirectories()) {
          target=dir.findFile(page);
          if (target != null)           return target;
        }
      }
    }
    return null;
  }
}
Program: 45250
Project: 45250
Buggy source:
@Override public void visitXmlText(XmlText text){
  if (!started[0]) {
    started[0]=true;
    registrar.startInjecting(language);
  }
  int len=text.getTextLength();
  if (len == 0)   return;
  registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
}

Fixed version (ground truth):
@Override public void visitXmlText(XmlText text){
  int len=text.getTextLength();
  if (len == 0)   return;
  if (!started[0]) {
    started[0]=true;
    registrar.startInjecting(language);
  }
  registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
}
Program: 45251
Project: 45251
Buggy source:
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar,@NotNull PsiElement context){
  if (!context.getContainingFile().getName().endsWith("String_Node_Str"))   return;
  if (context instanceof XmlAttributeValue) {
    final XmlAttributeValue value=(XmlAttributeValue)context;
    XmlAttribute a=(XmlAttribute)value.getParent();
    if (!a.getName().equals("String_Node_Str"))     return;
    Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    registrar.startInjecting(language);
    registrar.addPlace("String_Node_Str","String_Node_Str",(PsiLanguageInjectionHost)value,TextRange.from(1,value.getTextLength() - 2));
    registrar.doneInjecting();
  }
  if (context instanceof XmlTag) {
    final boolean[] started=new boolean[1];
    XmlTag t=(XmlTag)context;
    if (!t.getName().equals("String_Node_Str"))     return;
    final Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    t.acceptChildren(new XmlElementVisitor(){
      @Override public void visitXmlText(      XmlText text){
        if (!started[0]) {
          started[0]=true;
          registrar.startInjecting(language);
        }
        int len=text.getTextLength();
        if (len == 0)         return;
        registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
      }
    }
);
    if (started[0])     registrar.doneInjecting();
  }
}

Fixed version (ground truth):
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar,@NotNull PsiElement context){
  if (!context.getContainingFile().getName().endsWith("String_Node_Str"))   return;
  if (context instanceof XmlAttributeValue) {
    final XmlAttributeValue value=(XmlAttributeValue)context;
    XmlAttribute a=(XmlAttribute)value.getParent();
    if (!a.getName().equals("String_Node_Str"))     return;
    Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    registrar.startInjecting(language);
    registrar.addPlace("String_Node_Str","String_Node_Str",(PsiLanguageInjectionHost)value,TextRange.from(1,value.getTextLength() - 2));
    registrar.doneInjecting();
  }
  if (context instanceof XmlTag) {
    final boolean[] started=new boolean[1];
    XmlTag t=(XmlTag)context;
    if (!t.getName().equals("String_Node_Str"))     return;
    final Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    t.acceptChildren(new XmlElementVisitor(){
      @Override public void visitXmlText(      XmlText text){
        int len=text.getTextLength();
        if (len == 0)         return;
        if (!started[0]) {
          started[0]=true;
          registrar.startInjecting(language);
        }
        registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
      }
    }
);
    if (started[0])     registrar.doneInjecting();
  }
}
Program: 45252
Project: 45252
Buggy source:
public JellyCompletionContributer(){
  extend(CompletionType.BASIC,XML_ELEMENT_NAME_PATTERN,new CompletionProvider<CompletionParameters>(false,true){
    protected void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet result){
      XmlElement name=(XmlElement)parameters.getPosition();
      if (!name.getContainingFile().getName().endsWith("String_Node_Str"))       return;
      XmlTag tag=(XmlTag)name.getParent();
      Module module=ModuleUtil.findModuleForPsiElement(tag);
      String[] uris=tag.knownNamespaces();
      for (      String uri : uris) {
        String prefix=tag.getPrefixByNamespace(uri);
        if (prefix != null && prefix.length() > 0)         prefix+=':';
        XmlNSDescriptorImpl d=XmlNSDescriptorImpl.get(uri,module);
        if (d != null) {
          for (          XmlElementDescriptor e : d.getRootElementsDescriptors(null)) {
            result.addElement(LookupItem.fromString(prefix + e.getName()));
          }
        }
      }
    }
  }
);
}

Fixed version (ground truth):
public JellyCompletionContributer(){
  extend(CompletionType.BASIC,XML_ELEMENT_NAME_PATTERN,new CompletionProvider<CompletionParameters>(true,true){
    protected void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet result){
      XmlElement name=(XmlElement)parameters.getPosition();
      if (!name.getContainingFile().getName().endsWith("String_Node_Str"))       return;
      XmlTag tag=(XmlTag)name.getParent();
      Module module=ModuleUtil.findModuleForPsiElement(tag);
      String[] uris=tag.knownNamespaces();
      for (      String uri : uris) {
        String prefix=tag.getPrefixByNamespace(uri);
        if (prefix != null && prefix.length() > 0)         prefix+=':';
        XmlNSDescriptorImpl d=XmlNSDescriptorImpl.get(uri,module);
        if (d != null) {
          for (          XmlElementDescriptor e : d.getRootElementsDescriptors(null)) {
            result.addElement(LookupItem.fromString(prefix + e.getName()));
          }
        }
      }
    }
  }
);
}
Program: 45253
Project: 45253
Buggy source:
@NotNull public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,final boolean isOnTheFly){
  return new PsiElementVisitor(){
    public void visitXmlText(    XmlText text){
      addDescriptors(checkXmlText(text,holder.getManager(),isOnTheFly));
    }
    public void visitXmlAttributeValue(    XmlAttributeValue value){
      addDescriptors(checkXmlAttributeValue(value,holder.getManager(),isOnTheFly));
    }
    public void visitReferenceExpression(    PsiReferenceExpression expression){
    }
    private void addDescriptors(    final ProblemDescriptor[] descriptors){
      for (      ProblemDescriptor descriptor : descriptors) {
        holder.registerProblem(descriptor);
      }
    }
  }
;
}

Fixed version (ground truth):
@NotNull public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,final boolean isOnTheFly){
  return new XmlElementVisitor(){
    @Override public void visitXmlText(    XmlText text){
      addDescriptors(checkXmlText(text,holder.getManager(),isOnTheFly));
    }
    @Override public void visitXmlAttributeValue(    XmlAttributeValue value){
      addDescriptors(checkXmlAttributeValue(value,holder.getManager(),isOnTheFly));
    }
    private void addDescriptors(    final ProblemDescriptor[] descriptors){
      for (      ProblemDescriptor descriptor : descriptors) {
        holder.registerProblem(descriptor);
      }
    }
  }
;
}
Program: 45254
Project: 45254
Buggy source:
public void visitXmlAttributeValue(XmlAttributeValue value){
  addDescriptors(checkXmlAttributeValue(value,holder.getManager(),isOnTheFly));
}

Fixed version (ground truth):
@Override public void visitXmlAttributeValue(XmlAttributeValue value){
  addDescriptors(checkXmlAttributeValue(value,holder.getManager(),isOnTheFly));
}
Program: 45255
Project: 45255
Buggy source:
public void visitXmlText(XmlText text){
  addDescriptors(checkXmlText(text,holder.getManager(),isOnTheFly));
}

Fixed version (ground truth):
@Override public void visitXmlText(XmlText text){
  addDescriptors(checkXmlText(text,holder.getManager(),isOnTheFly));
}
Program: 45256
Project: 45256
Buggy source:
@Override public void visitXmlText(XmlText text){
  int len=text.getTextLength();
  if (len == 0)   return;
  registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
}

Fixed version (ground truth):
@Override public void visitXmlText(XmlText text){
  if (!started[0]) {
    started[0]=true;
    registrar.startInjecting(language);
  }
  int len=text.getTextLength();
  if (len == 0)   return;
  registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
}
Program: 45257
Project: 45257
Buggy source:
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar,@NotNull PsiElement context){
  if (!context.getContainingFile().getName().endsWith("String_Node_Str"))   return;
  if (context instanceof XmlAttributeValue) {
    final XmlAttributeValue value=(XmlAttributeValue)context;
    XmlAttribute a=(XmlAttribute)value.getParent();
    if (!a.getName().equals("String_Node_Str"))     return;
    Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    registrar.startInjecting(language);
    registrar.addPlace("String_Node_Str","String_Node_Str",(PsiLanguageInjectionHost)value,TextRange.from(1,value.getTextLength() - 2));
    registrar.doneInjecting();
  }
  if (context instanceof XmlTag) {
    XmlTag t=(XmlTag)context;
    if (!t.getName().equals("String_Node_Str"))     return;
    Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    registrar.startInjecting(language);
    t.acceptChildren(new XmlElementVisitor(){
      @Override public void visitXmlText(      XmlText text){
        int len=text.getTextLength();
        if (len == 0)         return;
        registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
      }
    }
);
    registrar.doneInjecting();
  }
}

Fixed version (ground truth):
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar,@NotNull PsiElement context){
  if (!context.getContainingFile().getName().endsWith("String_Node_Str"))   return;
  if (context instanceof XmlAttributeValue) {
    final XmlAttributeValue value=(XmlAttributeValue)context;
    XmlAttribute a=(XmlAttribute)value.getParent();
    if (!a.getName().equals("String_Node_Str"))     return;
    Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    registrar.startInjecting(language);
    registrar.addPlace("String_Node_Str","String_Node_Str",(PsiLanguageInjectionHost)value,TextRange.from(1,value.getTextLength() - 2));
    registrar.doneInjecting();
  }
  if (context instanceof XmlTag) {
    final boolean[] started=new boolean[1];
    XmlTag t=(XmlTag)context;
    if (!t.getName().equals("String_Node_Str"))     return;
    final Language language=findLanguage("String_Node_Str");
    if (language == null)     return;
    t.acceptChildren(new XmlElementVisitor(){
      @Override public void visitXmlText(      XmlText text){
        if (!started[0]) {
          started[0]=true;
          registrar.startInjecting(language);
        }
        int len=text.getTextLength();
        if (len == 0)         return;
        registrar.addPlace(null,null,(PsiLanguageInjectionHost)text,TextRange.from(0,len));
      }
    }
);
    if (started[0])     registrar.doneInjecting();
  }
}
Program: 45258
Project: 45258
Buggy source:
public boolean isRequired(){
  return def.isRequired();
}

Fixed version (ground truth):
/** 
 * This only seems to be used when a new tag is inserted, to automatically complete all required attributes. But not having a required attribute missing in XML doesn't automatically flag an error annotation.
 */
public boolean isRequired(){
  return def.isRequired();
}
Program: 45259
Project: 45259
Buggy source:
public int getContentType(){
  return CONTENT_TYPE_MIXED;
}

Fixed version (ground truth):
public int getContentType(){
  return CONTENT_TYPE_ANY;
}
Program: 45260
Project: 45260
Buggy source:
public XmlElementDescriptor getDescriptor(XmlTag xmlTag){
  if (!xmlTag.getContainingFile().getName().endsWith("String_Node_Str"))   return null;
  String nsUri=xmlTag.getNamespace();
  if (nsUri.length() == 0)   return null;
  Module m=ModuleUtil.findModuleForPsiElement(xmlTag);
  if (m == null)   return null;
  JavaPsiFacade javaPsi=JavaPsiFacade.getInstance(xmlTag.getProject());
  String pkgName=nsUri.substring(1).replace('/','.');
  PsiPackage pkg=javaPsi.findPackage(pkgName);
  if (pkg == null)   return null;
  PsiDirectory[] dirs=pkg.getDirectories(GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(m,false));
  for (  PsiDirectory dir : dirs) {
    if (dir.findFile("String_Node_Str") != null) {
      return new XmlNSDescriptorImpl(nsUri,dir).getElementDescriptor(xmlTag);
    }
  }
  return null;
}

Fixed version (ground truth):
public XmlElementDescriptor getDescriptor(XmlTag tag){
  XmlNSDescriptorImpl ns=XmlNSDescriptorImpl.get(tag);
  if (ns != null)   return ns.getElementDescriptor(tag);
  return null;
}
Program: 45261
Project: 45261
Buggy source:
/** 
 * Calculate the text range withtin   {@link XmlTag} that representsthe tag name.
 */
private static TextRange calcTagNameRange(XmlTag t){
  TextRange tr=t.getFirstChild().getNextSibling().getTextRange();
  return tr.shiftRight(t.getTextRange().getStartOffset());
}

Fixed version (ground truth):
/** 
 * Calculate the text range withtin   {@link XmlTag} that representsthe tag name.
 */
private static TextRange calcTagNameRange(XmlTag t){
  TextRange tr=t.getFirstChild().getNextSibling().getTextRange();
  return tr.shiftRight(-t.getTextRange().getStartOffset());
}
Program: 45263
Project: 45263
Buggy source:
/** 
 * Finds the smallest   {@link PsiElement} that encompasses the current selection.
 */
@Nullable private PsiElement findSelectedPsiElement(SelectionModel selectionModel,PsiJavaFile javaFile){
  PsiElement e=javaFile.findElementAt(selectionModel.getSelectionStart());
  if (e == null)   return null;
  while (true) {
    PsiElement p=e.getParent();
    TextRange tr=p.getTextRange();
    if (selectionModel.getSelectionEnd() <= tr.getEndOffset())     return e;
    e=p;
  }
}

Fixed version (ground truth):
/** 
 * Finds the smallest   {@link PsiElement} that encompasses the current selection.
 */
@Nullable private PsiElement findSelectedPsiElement(SelectionModel selectionModel,PsiJavaFile javaFile){
  PsiElement e=javaFile.findElementAt(selectionModel.getSelectionStart());
  if (e == null)   return null;
  while (true) {
    TextRange tr=e.getTextRange();
    if (selectionModel.getSelectionEnd() <= tr.getEndOffset())     return e;
    e=e.getParent();
  }
}
Program: 45264
Project: 45264
Buggy source:
public PsiElement resolve(){
  String localName=myElement.getLocalName();
  String nsUri=myElement.getNamespace();
  Module m=ModuleUtil.findModuleForPsiElement(myElement);
  if (m != null) {
    PsiManager psiManager=PsiManager.getInstance(myElement.getProject());
    String pkgName=nsUri.substring(1).replace('/','.');
    PsiPackage pkg=psiManager.findPackage(pkgName);
    PsiDirectory[] dirs=pkg.getDirectories(GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(m,false));
    for (    PsiDirectory dir : dirs) {
      PsiFile tagFile=dir.findFile(localName + "String_Node_Str");
      if (tagFile != null)       return tagFile;
    }
    VirtualFile module=m.getModuleFile().getParent();
    VirtualFile child=module.findChild(localName + "String_Node_Str");
    if (child != null)     return psiManager.findFile(child);
  }
  return null;
}

Fixed version (ground truth):
public PsiElement resolve(){
  String localName=myElement.getLocalName();
  String nsUri=myElement.getNamespace();
  if (nsUri.length() == 0)   return null;
  Module m=ModuleUtil.findModuleForPsiElement(myElement);
  if (m == null)   return null;
  PsiManager psiManager=PsiManager.getInstance(myElement.getProject());
  String pkgName=nsUri.substring(1).replace('/','.');
  PsiPackage pkg=psiManager.findPackage(pkgName);
  if (pkg == null)   return null;
  PsiDirectory[] dirs=pkg.getDirectories(GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(m,false));
  for (  PsiDirectory dir : dirs) {
    PsiFile tagFile=dir.findFile(localName + "String_Node_Str");
    if (tagFile != null)     return tagFile;
  }
  VirtualFile module=m.getModuleFile().getParent();
  VirtualFile child=module.findChild(localName + "String_Node_Str");
  if (child != null)   return psiManager.findFile(child);
  return null;
}
Program: 45266
Project: 45266
Buggy source:
/** 
 * Finds the smallest   {@link PsiElement} that encompasses the current selection.
 */
@Nullable private PsiElement findSelectedPsiElement(SelectionModel selectionModel,PsiJavaFile javaFile){
  PsiElement e=javaFile.findElementAt(selectionModel.getSelectionStart());
  if (e == null)   return null;
  while (true) {
    PsiElement p=e.getParent();
    TextRange tr=p.getTextRange();
    if (selectionModel.getSelectionEnd() < tr.getEndOffset())     return e;
    e=p;
  }
}

Fixed version (ground truth):
/** 
 * Finds the smallest   {@link PsiElement} that encompasses the current selection.
 */
@Nullable private PsiElement findSelectedPsiElement(SelectionModel selectionModel,PsiJavaFile javaFile){
  PsiElement e=javaFile.findElementAt(selectionModel.getSelectionStart());
  if (e == null)   return null;
  while (true) {
    PsiElement p=e.getParent();
    TextRange tr=p.getTextRange();
    if (selectionModel.getSelectionEnd() <= tr.getEndOffset())     return e;
    e=p;
  }
}
Program: 45269
Project: 45269
Buggy source:
/** 
 * Takes the literal string value and appends that to <tt>propertyValue</tt> with proper escaping.
 */
private void escapeAndAppend(String value){
  for (  char ch : value.toCharArray()) {
switch (ch) {
case '\'':
      propertyValue.append("String_Node_Str");
    break;
case '{':
case '}':
  propertyValue.append('\'').append(ch).append('\'');
break;
default :
propertyValue.append(ch);
}
}
}

Fixed version (ground truth):
/** 
 * Takes the literal string value and appends that to <tt>propertyValue</tt> with proper escaping.
 */
private void escapeAndAppend(String value){
  for (  char ch : value.toCharArray()) {
switch (ch) {
case '\'':
      propertyValue.append("String_Node_Str");
    break;
case '{':
case '}':
  propertyValue.append('\'').append(ch).append('\'');
break;
case ' ':
if (propertyValue.length() == 0) propertyValue.append('\\');
default :
propertyValue.append(ch);
}
}
}
Program: 45270
Project: 45270
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  ApplicationContextMock appctx=new ApplicationContextMock();
  application.addComponentInstantiationListener(new SpringComponentInjector(application,appctx));
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  ApplicationContextMock appctx=new ApplicationContextMock();
  application.addComponentInstantiationListener(new SpringComponentInjector(application,appctx,true));
}
Program: 45271
Project: 45271
Buggy source:
public void testStartFirstSecure(){
  ApplicationContextMock appctx=new ApplicationContextMock();
  application.addComponentInstantiationListener(new SpringComponentInjector(application,appctx));
  loginToApp("String_Node_Str");
  mock.assertRenderedPage(HomePage.class);
  logoutOfApp();
}

Fixed version (ground truth):
public void testStartFirstSecure(){
  ApplicationContextMock appctx=new ApplicationContextMock();
  application.addComponentInstantiationListener(new SpringComponentInjector(application,appctx,true));
  loginToApp("String_Node_Str");
  mock.assertRenderedPage(HomePage.class);
  logoutOfApp();
}
Program: 45272
Project: 45272
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  ApplicationContextMock appctx=new ApplicationContextMock();
  application.addComponentInstantiationListener(new SpringComponentInjector(application,appctx));
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  ApplicationContextMock appctx=new ApplicationContextMock();
  application.addComponentInstantiationListener(new SpringComponentInjector(application,appctx,true));
}
Program: 45273
Project: 45273
Buggy source:
@Override public void init(){
  ApplicationContextMock appctx=new ApplicationContextMock();
  addComponentInstantiationListener(new SpringComponentInjector(this,appctx));
  ProviderManager authMan=new ProviderManager();
  List<TestingAuthenticationProvider> providerList=new ArrayList<TestingAuthenticationProvider>();
  providerList.add(new TestingAuthenticationProvider());
  authMan.setProviders(providerList);
  this.authenticationManager=authMan;
  this.setupStrategyFactory();
  this.setupActionFactory();
  this.setUpHive();
  getMarkupSettings().setStripComments(false);
  getMarkupSettings().setStripWicketTags(false);
  getMarkupSettings().setDefaultBeforeDisabledLink("String_Node_Str");
  getMarkupSettings().setDefaultAfterDisabledLink("String_Node_Str");
}

Fixed version (ground truth):
@Override public void init(){
  ApplicationContextMock appctx=new ApplicationContextMock();
  addComponentInstantiationListener(new SpringComponentInjector(this,appctx,true));
  ProviderManager authMan=new ProviderManager();
  List<TestingAuthenticationProvider> providerList=new ArrayList<TestingAuthenticationProvider>();
  providerList.add(new TestingAuthenticationProvider());
  authMan.setProviders(providerList);
  this.authenticationManager=authMan;
  this.setupStrategyFactory();
  this.setupActionFactory();
  this.setUpHive();
  getMarkupSettings().setStripComments(false);
  getMarkupSettings().setStripWicketTags(false);
  getMarkupSettings().setDefaultBeforeDisabledLink("String_Node_Str");
  getMarkupSettings().setDefaultAfterDisabledLink("String_Node_Str");
}
Program: 45274
Project: 45274
Buggy source:
/** 
 * Checks raw input for aliases and then replaces those with the registered values. Note that if the encountered alias is not allowed it is left unresolved and will probably later in the creation of the factory be skipped or cause a failure.
 * @param raw the raw input
 * @return the input with as much aliases resolved
 */
private String resolveAliases(String raw){
  Matcher m=aliasPattern.matcher(raw);
  StringBuffer buff=new StringBuffer(raw.length() + 30);
  int index=0;
  while (m.find()) {
    if (m.start() > index)     buff.append(raw.substring(index,m.start()));
 else     if (m.start() == index) {
      String key=raw.substring(m.start() + 2,m.end() - 1);
      String alias=getAlias(key);
      if (alias == null) {
        alias=key;
        if (log.isDebugEnabled())         log.debug("String_Node_Str" + key);
      }
 else       if (log.isDebugEnabled())       log.debug("String_Node_Str" + key + "String_Node_Str"+ alias);
      buff.ensureCapacity(buff.length() + alias.length());
      buff.append(alias);
    }
 else     throw new IllegalStateException("String_Node_Str" + raw);
    index=m.end();
  }
  if (index < raw.length())   buff.append(raw.substring(index,raw.length()));
  String temp=buff.toString();
  if (temp.indexOf("String_Node_Str") >= 0)   throw new IllegalStateException("String_Node_Str" + raw);
  return temp;
}

Fixed version (ground truth):
/** 
 * Checks raw input for aliases and then replaces those with the registered values. Note that if the encountered alias is not allowed it is left unresolved and will probably later in the creation of the factory be skipped or cause a failure.
 * @param raw the raw input
 * @return the input with as much aliases resolved
 */
private String resolveAliases(String raw){
  Matcher m=aliasPattern.matcher(raw);
  StringBuffer buff=new StringBuffer(raw.length() + 30);
  int index=0;
  while (m.find()) {
    if (m.start() > index) {
      buff.append(raw.substring(index,m.start()));
      replaceAlias(raw,m,buff);
    }
 else     if (m.start() == index) {
      replaceAlias(raw,m,buff);
    }
 else     throw new IllegalStateException("String_Node_Str" + raw);
    index=m.end();
  }
  if (index < raw.length())   buff.append(raw.substring(index,raw.length()));
  String temp=buff.toString();
  if (temp.indexOf("String_Node_Str") >= 0)   throw new IllegalStateException("String_Node_Str" + raw);
  return temp;
}