nus-yam/ex-repair huggingface dataset:
Program: 152319
Project: 152319
Buggy source:
public void messageReceived(IoSession session,Object message) throws IOException, FtpException {
  FtpRequest request=(FtpRequest)message;
  ConnectionObserver observer=(ConnectionObserver)session.getAttribute("String_Node_Str");
  if (observer != null) {
    observer.request(request.toString());
  }
  MinaConnection connection=(MinaConnection)session.getAttribute(CONNECTION_KEY);
  MinaFtpResponseOutput output=(MinaFtpResponseOutput)session.getAttribute(OUTPUT_KEY);
  protocolHandler.onRequestReceived(connection,(FtpSessionImpl)connection.getSession(),output,request);
}

Fixed version (ground truth):
public void messageReceived(IoSession session,Object message) throws IOException, FtpException {
  FtpRequest request=new FtpRequestImpl(message.toString());
  ConnectionObserver observer=(ConnectionObserver)session.getAttribute("String_Node_Str");
  if (observer != null) {
    observer.request(request.toString());
  }
  MinaConnection connection=(MinaConnection)session.getAttribute(CONNECTION_KEY);
  MinaFtpResponseOutput output=(MinaFtpResponseOutput)session.getAttribute(OUTPUT_KEY);
  protocolHandler.onRequestReceived(connection,(FtpSessionImpl)connection.getSession(),output,request);
}
Program: 152320
Project: 152320
Buggy source:
public void sessionCreated(IoSession session) throws Exception {
  MinaConnection connection=new MinaConnection(serverContext,session,listener);
  session.setAttribute(CONNECTION_KEY,connection);
  MinaFtpResponseOutput output=new MinaFtpResponseOutput(session);
  session.setAttribute(OUTPUT_KEY,output);
}

Fixed version (ground truth):
public void sessionCreated(IoSession session) throws Exception {
  MinaConnection connection=new MinaConnection(serverContext,session,listener);
  ConnectionManager conManager=serverContext.getConnectionManager();
  conManager.newConnection(connection);
  session.setAttribute(CONNECTION_KEY,connection);
  MinaFtpResponseOutput output=new MinaFtpResponseOutput(session);
  session.setAttribute(OUTPUT_KEY,output);
}
Program: 152321
Project: 152321
Buggy source:
public void onConnectionClosed(Connection connection,FtpSessionImpl session,FtpWriter writer){
  try {
    Ftplet ftpletContainer=serverContext.getFtpletContainer();
    ftpletContainer.onDisconnect(session,writer);
  }
 catch (  Exception ex) {
    LOG.warn("String_Node_Str",ex);
  }
  ServerFtpStatistics ftpStat=(ServerFtpStatistics)serverContext.getFtpStatistics();
  if (session != null) {
    User user=session.getUser();
    String userName=user != null ? user.getName() : "String_Node_Str";
    InetAddress clientAddr=session.getClientAddress();
    LOG.info("String_Node_Str" + clientAddr.getHostAddress() + "String_Node_Str"+ userName);
    if (session.isLoggedIn()) {
      session.setLogout();
      ftpStat.setLogout(connection);
    }
    ftpStat.setCloseConnection(connection);
    session.clear();
    session.getFtpDataConnection().dispose();
    FileSystemView fview=session.getFileSystemView();
    if (fview != null) {
      fview.dispose();
    }
    session=null;
  }
  if (writer != null) {
    writer.setObserver(null);
    writer.close();
    writer=null;
  }
}

Fixed version (ground truth):
public void onConnectionClosed(Connection connection,FtpSessionImpl session,FtpWriter writer){
  try {
    Ftplet ftpletContainer=serverContext.getFtpletContainer();
    if (ftpletContainer != null) {
      ftpletContainer.onDisconnect(session,writer);
    }
  }
 catch (  Exception ex) {
    LOG.warn("String_Node_Str",ex);
  }
  ServerFtpStatistics ftpStat=(ServerFtpStatistics)serverContext.getFtpStatistics();
  if (session != null) {
    User user=session.getUser();
    String userName=user != null ? user.getName() : "String_Node_Str";
    InetAddress clientAddr=session.getClientAddress();
    LOG.info("String_Node_Str" + clientAddr.getHostAddress() + "String_Node_Str"+ userName);
    if (session.isLoggedIn()) {
      session.setLogout();
      if (ftpStat != null) {
        ftpStat.setLogout(connection);
      }
    }
    if (ftpStat != null) {
      ftpStat.setCloseConnection(connection);
    }
    session.clear();
    session.getFtpDataConnection().dispose();
    FileSystemView fview=session.getFileSystemView();
    if (fview != null) {
      fview.dispose();
    }
    session=null;
  }
  if (writer != null) {
    writer.setObserver(null);
    writer.close();
    writer=null;
  }
}
Program: 152322
Project: 152322
Buggy source:
public String toString(){
  int code=getCode();
  String notNullMessage=getMessage();
  if (notNullMessage == null) {
    notNullMessage="String_Node_Str";
  }
  StringBuffer sb=new StringBuffer();
  if (notNullMessage.indexOf('\n') == -1) {
    sb.append(code);
    sb.append("String_Node_Str");
    sb.append(notNullMessage);
    sb.append(CRLF);
  }
 else {
    String[] lines=notNullMessage.split("String_Node_Str");
    sb.append(code);
    sb.append("String_Node_Str");
    for (int i=0; i < lines.length; i++) {
      String line=lines[i].trim();
      if (i + 1 == lines.length) {
        sb.append(code);
        sb.append("String_Node_Str");
      }
      sb.append(line);
      sb.append(CRLF);
    }
  }
  return sb.toString();
}

Fixed version (ground truth):
public String toString(){
  int code=getCode();
  String notNullMessage=getMessage();
  if (notNullMessage == null) {
    notNullMessage="String_Node_Str";
  }
  StringBuffer sb=new StringBuffer();
  if (notNullMessage.indexOf('\n') == -1) {
    sb.append(code);
    sb.append("String_Node_Str");
    sb.append(notNullMessage);
    sb.append(CRLF);
  }
 else {
    String[] lines=notNullMessage.split("String_Node_Str");
    sb.append(code);
    sb.append("String_Node_Str");
    for (int i=0; i < lines.length; i++) {
      String line=lines[i];
      if (i + 1 == lines.length) {
        sb.append(code);
        sb.append("String_Node_Str");
      }
      sb.append(line);
      sb.append(CRLF);
    }
  }
  return sb.toString();
}
Program: 152323
Project: 152323
Buggy source:
/** 
 * User logout
 */
public void setLogout(Connection connection){
  --currLogins;
  User user=connection.getSession().getUser();
  if ("String_Node_Str".equals(user.getName())) {
    --currAnonLogins;
  }
synchronized (user) {
    Hashtable statisticsTable=(Hashtable)userLoginTable.get(user.getName());
    Integer loginNumber=(Integer)statisticsTable.get(LOGIN_NUMBER);
    statisticsTable.put(LOGIN_NUMBER,new Integer(loginNumber.intValue() - 1));
    Integer loginNumberPerIP=(Integer)statisticsTable.get(connection.getSession().getClientAddress().getHostAddress());
    if (loginNumberPerIP != null) {
      if (loginNumberPerIP.intValue() <= 1) {
        statisticsTable.remove(connection.getSession().getClientAddress().getHostAddress());
      }
    }
 else {
      statisticsTable.put(connection.getSession().getClientAddress().getHostAddress(),new Integer(loginNumberPerIP.intValue() - 1));
    }
  }
  notifyLogout(connection);
}

Fixed version (ground truth):
/** 
 * User logout
 */
public void setLogout(Connection connection){
  --currLogins;
  User user=connection.getSession().getUser();
  if ("String_Node_Str".equals(user.getName())) {
    --currAnonLogins;
  }
synchronized (user) {
    Hashtable statisticsTable=(Hashtable)userLoginTable.get(user.getName());
    Integer loginNumber=(Integer)statisticsTable.get(LOGIN_NUMBER);
    statisticsTable.put(LOGIN_NUMBER,new Integer(loginNumber.intValue() - 1));
    Integer loginNumberPerIP=(Integer)statisticsTable.get(connection.getSession().getClientAddress().getHostAddress());
    if (loginNumberPerIP != null) {
      if (loginNumberPerIP.intValue() <= 1) {
        statisticsTable.remove(connection.getSession().getClientAddress().getHostAddress());
      }
 else {
        statisticsTable.put(connection.getSession().getClientAddress().getHostAddress(),new Integer(loginNumberPerIP.intValue() - 1));
      }
    }
  }
  notifyLogout(connection);
}
Program: 152324
Project: 152324
Buggy source:
private final long transfer(InputStream in,OutputStream out,int maxRate) throws IOException {
  long transferredSize=0L;
  boolean isAscii=session.getDataType() == DataType.ASCII;
  long startTime=System.currentTimeMillis();
  byte[] buff=new byte[4096];
  BufferedInputStream bis=null;
  BufferedOutputStream bos=null;
  try {
    bis=IoUtils.getBufferedInputStream(in);
    bos=IoUtils.getBufferedOutputStream(out);
    while (true) {
      if (maxRate > 0) {
        long interval=System.currentTimeMillis() - startTime;
        if (interval == 0) {
          interval=1;
        }
        long currRate=(transferredSize * 1000L) / interval;
        if (currRate > maxRate) {
          try {
            Thread.sleep(50);
          }
 catch (          InterruptedException ex) {
            break;
          }
          continue;
        }
      }
      int count=bis.read(buff);
      if (count == -1) {
        break;
      }
      if (isAscii) {
        for (int i=0; i < count; ++i) {
          byte b=buff[i];
          if (b == '\n') {
            bos.write('\r');
          }
          bos.write(b);
        }
      }
 else {
        bos.write(buff,0,count);
      }
      transferredSize+=count;
      notifyObserver();
    }
  }
  finally {
    if (bos != null) {
      bos.flush();
    }
  }
  return transferredSize;
}

Fixed version (ground truth):
private final long transfer(InputStream in,OutputStream out,int maxRate) throws IOException {
  long transferredSize=0L;
  boolean isAscii=session.getDataType() == DataType.ASCII;
  long startTime=System.currentTimeMillis();
  byte[] buff=new byte[4096];
  BufferedInputStream bis=null;
  BufferedOutputStream bos=null;
  try {
    bis=IoUtils.getBufferedInputStream(in);
    bos=IoUtils.getBufferedOutputStream(out);
    boolean lastWasCR=false;
    while (true) {
      if (maxRate > 0) {
        long interval=System.currentTimeMillis() - startTime;
        if (interval == 0) {
          interval=1;
        }
        long currRate=(transferredSize * 1000L) / interval;
        if (currRate > maxRate) {
          try {
            Thread.sleep(50);
          }
 catch (          InterruptedException ex) {
            break;
          }
          continue;
        }
      }
      int count=bis.read(buff);
      if (count == -1) {
        break;
      }
      if (isAscii) {
        for (int i=0; i < count; ++i) {
          byte b=buff[i];
          if (b == '\n' && !lastWasCR) {
            bos.write('\r');
          }
          if (b == '\r') {
            lastWasCR=true;
          }
 else {
            lastWasCR=false;
          }
          bos.write(b);
        }
      }
 else {
        bos.write(buff,0,count);
      }
      transferredSize+=count;
      notifyObserver();
    }
  }
  finally {
    if (bos != null) {
      bos.flush();
    }
  }
  return transferredSize;
}
Program: 152325
Project: 152325
Buggy source:
public void write(FtpReply response) throws IOException {
  session.write(response).join();
}

Fixed version (ground truth):
public void write(FtpReply response) throws IOException {
  session.write(response);
}
Program: 152326
Project: 152326
Buggy source:
protected Properties createConfig(){
  assertTrue(FTPSERVER_KEYSTORE.exists());
  Properties configProps=new Properties();
  configProps.setProperty("String_Node_Str",IOListener.class.getName());
  configProps.setProperty("String_Node_Str",Integer.toString(port));
  configProps.setProperty("String_Node_Str",DefaultSsl.class.getName());
  configProps.setProperty("String_Node_Str",FTPSERVER_KEYSTORE.getAbsolutePath());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",getAuthValue());
  configProps.setProperty("String_Node_Str",getClientAuth());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",DefaultDataConnectionConfig.class.getName());
  configProps.setProperty("String_Node_Str",DefaultSsl.class.getName());
  configProps.setProperty("String_Node_Str",FTPSERVER_KEYSTORE.getAbsolutePath());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",getAuthValue());
  configProps.setProperty("String_Node_Str",getClientAuth());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",USERS_FILE.getAbsolutePath());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  return configProps;
}

Fixed version (ground truth):
protected Properties createConfig(){
  assertTrue(FTPSERVER_KEYSTORE.exists());
  Properties configProps=new Properties();
  configProps.setProperty("String_Node_Str",MinaListener.class.getName());
  configProps.setProperty("String_Node_Str",Integer.toString(port));
  configProps.setProperty("String_Node_Str",DefaultSsl.class.getName());
  configProps.setProperty("String_Node_Str",FTPSERVER_KEYSTORE.getAbsolutePath());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",getAuthValue());
  configProps.setProperty("String_Node_Str",getClientAuth());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",DefaultDataConnectionConfig.class.getName());
  configProps.setProperty("String_Node_Str",DefaultSsl.class.getName());
  configProps.setProperty("String_Node_Str",FTPSERVER_KEYSTORE.getAbsolutePath());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",getAuthValue());
  configProps.setProperty("String_Node_Str",getClientAuth());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str","String_Node_Str");
  configProps.setProperty("String_Node_Str",USERS_FILE.getAbsolutePath());
  configProps.setProperty("String_Node_Str","String_Node_Str");
  return configProps;
}
Program: 152327
Project: 152327
Buggy source:
/** 
 * Get the data socket. In case of error returns null.
 */
private synchronized Socket getDataSocket() throws Exception {
  dataSoc=null;
  DataConnectionConfig dataConfig=serverContext.getDataConnectionConfig();
  try {
    if (isPort) {
      int localPort=dataConfig.getActiveLocalPort();
      if (secure) {
        Ssl ssl=dataConfig.getSSL();
        if (ssl == null) {
          throw new FtpException("String_Node_Str");
        }
        if (localPort == 0) {
          dataSoc=ssl.createSocket(null,address,port,false);
        }
 else {
          InetAddress localAddr=dataConfig.getActiveLocalAddress();
          dataSoc=ssl.createSocket(null,address,port,localAddr,localPort,false);
        }
      }
 else {
        if (localPort == 0) {
          dataSoc=new Socket(address,port);
        }
 else {
          InetAddress localAddr=dataConfig.getActiveLocalAddress();
          dataSoc=new Socket(address,port,localAddr,localPort);
        }
      }
    }
 else     if (isPasv) {
      dataSoc=servSoc.accept();
    }
  }
 catch (  Exception ex) {
    closeDataSocket();
    log.warn("String_Node_Str",ex);
    throw ex;
  }
  return dataSoc;
}

Fixed version (ground truth):
/** 
 * Get the data socket. In case of error returns null.
 */
private synchronized Socket getDataSocket() throws Exception {
  dataSoc=null;
  DataConnectionConfig dataConfig=serverContext.getDataConnectionConfig();
  try {
    if (isPort) {
      int localPort=dataConfig.getActiveLocalPort();
      if (secure) {
        Ssl ssl=dataConfig.getSSL();
        if (ssl == null) {
          throw new FtpException("String_Node_Str");
        }
        if (localPort == 0) {
          dataSoc=ssl.createSocket(null,address,port,false);
        }
 else {
          InetAddress localAddr=dataConfig.getActiveLocalAddress();
          dataSoc=ssl.createSocket(null,address,port,localAddr,localPort,false);
        }
      }
 else {
        if (localPort == 0) {
          dataSoc=new Socket(address,port);
        }
 else {
          InetAddress localAddr=dataConfig.getActiveLocalAddress();
          dataSoc=new Socket(address,port,localAddr,localPort);
        }
      }
    }
 else     if (isPasv) {
      dataSoc=servSoc.accept();
    }
  }
 catch (  Exception ex) {
    closeDataSocket();
    log.warn("String_Node_Str",ex);
    throw ex;
  }
  if (dataSoc instanceof SSLSocket) {
    ((SSLSocket)dataSoc).startHandshake();
  }
  return dataSoc;
}
Program: 152328
Project: 152328
Buggy source:
/** 
 * @throws Exception
 */
protected void connectClient() throws Exception {
  client=createFTPClient();
  client.addProtocolCommandListener(new ProtocolCommandListener(){
    public void protocolCommandSent(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
    public void protocolReplyReceived(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
  }
);
  int attempts=0;
  while (attempts < 5) {
    try {
      client.connect("String_Node_Str",port);
      break;
    }
 catch (    SSLException e) {
    }
catch (    FTPConnectionClosedException e) {
    }
    Thread.sleep(500);
    attempts++;
  }
}

Fixed version (ground truth):
/** 
 * @throws Exception
 */
protected void connectClient() throws Exception {
  client=createFTPClient();
  client.addProtocolCommandListener(new ProtocolCommandListener(){
    public void protocolCommandSent(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
    public void protocolReplyReceived(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
  }
);
  int attempts=0;
  while (attempts < 5) {
    try {
      client.connect("String_Node_Str",port);
      break;
    }
 catch (    SSLException e) {
    }
catch (    FTPConnectionClosedException e) {
    }
    System.out.println("String_Node_Str");
    Thread.sleep(500);
    attempts++;
  }
}
Program: 152330
Project: 152330
Buggy source:
protected void setUp() throws Exception {
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  MockFtplet.callback=new MockFtpletCallback();
  MockFtplet.callback.returnValue=FtpletEnum.RET_DEFAULT;
}
Program: 152332
Project: 152332
Buggy source:
/** 
 * Save entered properties 
 */
private void save(){
  int selIdx=comboBox.getSelectedIndex();
  if (selIdx == -1) {
    return;
  }
  String language=null;
  if (selIdx >= 1) {
    language=languages[selIdx - 1];
  }
  String key=(String)comboBox.getSelectedItem();
  String val=txtArea.getText();
  messageProps.setProperty(key,val);
  try {
    fconfig.getMessageResource().save(messageProps,language);
  }
 catch (  FtpException ex) {
    GuiUtils.showErrorMessage(this,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Save entered properties 
 */
private void save(){
  int selIdx=comboBox.getSelectedIndex();
  if (selIdx == -1) {
    return;
  }
  String language=null;
  if (selIdx >= 1) {
    language=languages[selIdx - 1];
  }
  String key=list.getSelectedValue().toString();
  String val=txtArea.getText();
  messageProps.setProperty(key,val);
  try {
    fconfig.getMessageResource().save(messageProps,language);
  }
 catch (  FtpException ex) {
    GuiUtils.showErrorMessage(this,"String_Node_Str");
  }
}
Program: 152333
Project: 152333
Buggy source:
/** 
 * Print file list. Detail listing. <pre> -a : display all (including hidden files) </pre>
 * @return true if success
 */
public boolean doLIST(String argument,Writer out) throws IOException {
  if (!parse(argument)) {
    return false;
  }
  FileObject[] files=null;
  try {
    files=fileSystemView.listFiles(file);
  }
 catch (  FtpException ex) {
  }
  if (files == null) {
    return false;
  }
  RegularExpr regexp=null;
  if (pattern != null) {
    regexp=new RegularExpr(pattern);
  }
  for (int i=0; i < files.length; i++) {
    if (files[i] == null) {
      continue;
    }
    if ((!isAllOption) && files[i].isHidden()) {
      continue;
    }
    if ((regexp != null) && (!regexp.isMatch(files[i].getShortName()))) {
      continue;
    }
    printLine(files[i],out);
    out.write(NEWLINE);
  }
  out.flush();
  return true;
}

Fixed version (ground truth):
/** 
 * Print file list. Detail listing. <pre> -a : display all (including hidden files) </pre>
 * @return true if success
 */
public boolean doLIST(String argument,Writer out) throws IOException {
  if (!parse(argument)) {
    return false;
  }
  FileObject[] files=listFiles();
  if (files == null) {
    return false;
  }
  RegularExpr regexp=null;
  if (pattern != null) {
    regexp=new RegularExpr(pattern);
  }
  for (int i=0; i < files.length; i++) {
    if (files[i] == null) {
      continue;
    }
    if ((!isAllOption) && files[i].isHidden()) {
      continue;
    }
    if ((regexp != null) && (!regexp.isMatch(files[i].getShortName()))) {
      continue;
    }
    printLine(files[i],out);
    out.write(NEWLINE);
  }
  out.flush();
  return true;
}
Program: 152334
Project: 152334
Buggy source:
/** 
 * Print file list. The server will return a stream of names of  files and no other information if detail listing flag is false. <pre> -l : detail listing -a : display all (including hidden files) </pre>
 */
public boolean doNLST(String argument,Writer out) throws IOException {
  if (!parse(argument)) {
    return false;
  }
  FileObject[] files=null;
  try {
    files=fileSystemView.listFiles(file);
  }
 catch (  FtpException ex) {
  }
  if (files == null) {
    return false;
  }
  RegularExpr regexp=null;
  if (pattern != null) {
    regexp=new RegularExpr(pattern);
  }
  for (int i=0; i < files.length; i++) {
    if (files[i] == null) {
      continue;
    }
    if ((!isAllOption) && files[i].isHidden()) {
      continue;
    }
    if ((regexp != null) && (!regexp.isMatch(files[i].getShortName()))) {
      continue;
    }
    if (isDetailOption) {
      printLine(files[i],out);
    }
 else {
      out.write(files[i].getShortName());
    }
    out.write(NEWLINE);
  }
  out.flush();
  return true;
}

Fixed version (ground truth):
/** 
 * Print file list. The server will return a stream of names of  files and no other information if detail listing flag is false. <pre> -l : detail listing -a : display all (including hidden files) </pre>
 */
public boolean doNLST(String argument,Writer out) throws IOException {
  if (!parse(argument)) {
    return false;
  }
  FileObject[] files=listFiles();
  if (files == null) {
    return false;
  }
  RegularExpr regexp=null;
  if (pattern != null) {
    regexp=new RegularExpr(pattern);
  }
  for (int i=0; i < files.length; i++) {
    if (files[i] == null) {
      continue;
    }
    if ((!isAllOption) && files[i].isHidden()) {
      continue;
    }
    if ((regexp != null) && (!regexp.isMatch(files[i].getShortName()))) {
      continue;
    }
    if (isDetailOption) {
      printLine(files[i],out);
    }
 else {
      out.write(files[i].getShortName());
    }
    out.write(NEWLINE);
  }
  out.flush();
  return true;
}
Program: 152335
Project: 152335
Buggy source:
/** 
 * Print directory contents. Machine listing. <pre> -a : display all (including hidden files) </pre>
 * @return true if success
 */
public boolean doMLSD(String argument,Writer out) throws IOException {
  if (!parse(argument)) {
    return false;
  }
  FileObject[] files=null;
  try {
    files=fileSystemView.listFiles(file);
  }
 catch (  FtpException ex) {
  }
  if (files == null) {
    return false;
  }
  RegularExpr regexp=null;
  if (pattern != null) {
    regexp=new RegularExpr(pattern);
  }
  for (int i=0; i < files.length; i++) {
    if (files[i] == null) {
      continue;
    }
    if ((!isAllOption) && files[i].isHidden()) {
      continue;
    }
    if ((regexp != null) && (!regexp.isMatch(files[i].getShortName()))) {
      continue;
    }
    printMLine(files[i],out);
    out.write(NEWLINE);
  }
  out.flush();
  return true;
}

Fixed version (ground truth):
/** 
 * Print directory contents. Machine listing. <pre> -a : display all (including hidden files) </pre>
 * @return true if success
 */
public boolean doMLSD(String argument,Writer out) throws IOException {
  if (!parse(argument)) {
    return false;
  }
  FileObject[] files=listFiles();
  if (files == null) {
    return false;
  }
  RegularExpr regexp=null;
  if (pattern != null) {
    regexp=new RegularExpr(pattern);
  }
  for (int i=0; i < files.length; i++) {
    if (files[i] == null) {
      continue;
    }
    if ((!isAllOption) && files[i].isHidden()) {
      continue;
    }
    if ((regexp != null) && (!regexp.isMatch(files[i].getShortName()))) {
      continue;
    }
    printMLine(files[i],out);
    out.write(NEWLINE);
  }
  out.flush();
  return true;
}
Program: 152336
Project: 152336
Buggy source:
/** 
 * Port command.
 */
public synchronized void setPortCommand(InetAddress addr,int port){
  closeDataSocket();
  isPort=true;
  isPasv=false;
  address=addr;
  this.port=port;
  requestTime=System.currentTimeMillis();
}

Fixed version (ground truth):
/** 
 * Port command.
 */
public synchronized void setPortCommand(InetAddress addr,int activePort){
  closeDataSocket();
  isPort=true;
  isPasv=false;
  address=addr;
  port=activePort;
  requestTime=System.currentTimeMillis();
}
Program: 152337
Project: 152337
Buggy source:
/** 
 * Passive command. It returns the success flag.
 */
public synchronized boolean setPasvCommand(){
  closeDataSocket();
  int port=fconfig.getDataConnectionConfig().getPassivePort();
  if (port == -1) {
    log.warn("String_Node_Str");
    servSoc=null;
    return false;
  }
  boolean bRet=false;
  try {
    IDataConnectionConfig dataCfg=fconfig.getDataConnectionConfig();
    address=dataCfg.getPassiveAddress();
    if (secure) {
      ISsl ssl=dataCfg.getSSL();
      if (ssl == null) {
        throw new FtpException("String_Node_Str");
      }
      servSoc=ssl.createServerSocket(null,address,this.port);
    }
 else {
      servSoc=new ServerSocket(port,1,address);
    }
    servSoc.setSoTimeout(dataCfg.getMaxIdleTimeMillis());
    this.port=servSoc.getLocalPort();
    isPort=false;
    isPasv=true;
    bRet=true;
    requestTime=System.currentTimeMillis();
  }
 catch (  Exception ex) {
    servSoc=null;
    closeDataSocket();
    log.warn("String_Node_Str",ex);
  }
  return bRet;
}

Fixed version (ground truth):
/** 
 * Passive command. It returns the success flag.
 */
public synchronized boolean setPasvCommand(){
  closeDataSocket();
  int passivePort=fconfig.getDataConnectionConfig().getPassivePort();
  if (passivePort == -1) {
    log.warn("String_Node_Str");
    servSoc=null;
    return false;
  }
  boolean bRet=false;
  try {
    IDataConnectionConfig dataCfg=fconfig.getDataConnectionConfig();
    address=dataCfg.getPassiveAddress();
    if (secure) {
      ISsl ssl=dataCfg.getSSL();
      if (ssl == null) {
        throw new FtpException("String_Node_Str");
      }
      servSoc=ssl.createServerSocket(null,address,passivePort);
    }
 else {
      servSoc=new ServerSocket(passivePort,1,address);
    }
    servSoc.setSoTimeout(dataCfg.getMaxIdleTimeMillis());
    port=servSoc.getLocalPort();
    isPort=false;
    isPasv=true;
    bRet=true;
    requestTime=System.currentTimeMillis();
  }
 catch (  Exception ex) {
    servSoc=null;
    closeDataSocket();
    log.warn("String_Node_Str",ex);
  }
  return bRet;
}
Program: 152338
Project: 152338
Buggy source:
/** 
 * Check user permission to execute ftp command. 
 */
protected boolean hasPermission(){
  String cmd=request.getCommand();
  if (cmd == null) {
    return false;
  }
  return request.isLoggedIn() || cmd.equals("String_Node_Str") || cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Check user permission to execute ftp command. 
 */
protected boolean hasPermission(){
  String cmd=request.getCommand();
  if (cmd == null) {
    return false;
  }
  return request.isLoggedIn() || cmd.equals("String_Node_Str") || cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str")|| cmd.equals("String_Node_Str");
}
Program: 152341
Project: 152341
Buggy source:
/** 
 * Generate and send ftp server response.
 */
public void send(int code,String subId,String basicMsg) throws IOException {
  IMessageResource resource=fconfig.getMessageResource();
  String lang=request.getLanguage();
  String msg=resource.getMessage(code,subId,lang);
  if (msg == null) {
    log.error("String_Node_Str" + code + ','+ subId+ ','+ lang);
    msg="String_Node_Str";
  }
  msg=replaceVariables(code,basicMsg,msg);
  write(code,msg);
}

Fixed version (ground truth):
/** 
 * Generate and send ftp server response.
 */
public void send(int code,String subId,String basicMsg) throws IOException {
  IMessageResource resource=fconfig.getMessageResource();
  String lang=request.getLanguage();
  String msg=null;
  if (resource != null) {
    msg=resource.getMessage(code,subId,lang);
  }
  if (msg == null) {
    log.error("String_Node_Str" + code + ','+ subId+ ','+ lang);
    msg="String_Node_Str";
  }
  msg=replaceVariables(code,basicMsg,msg);
  write(code,msg);
}
Program: 152343
Project: 152343
Buggy source:
public final static void delete(File file) throws IOException {
  if (file.isDirectory()) {
    deleteDir(file);
  }
 else {
    deleteFile(file);
  }
}

Fixed version (ground truth):
public final static void delete(File file) throws IOException {
  if (!file.exists()) {
    return;
  }
 else   if (file.isDirectory()) {
    deleteDir(file);
  }
 else {
    deleteFile(file);
  }
}
Program: 152344
Project: 152344
Buggy source:
protected void setUp() throws Exception {
  testTmpDir.mkdirs();
  initPort();
  config=new FtpConfigImpl(new PropertiesConfiguration(createConfig()));
  server=new FtpServer(config);
  server.start();
  client=new FTPClient();
  client.addProtocolCommandListener(new ProtocolCommandListener(){
    public void protocolCommandSent(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
    public void protocolReplyReceived(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
  }
);
  try {
    client.connect("String_Node_Str",port);
  }
 catch (  FTPConnectionClosedException e) {
    client.connect("String_Node_Str",port);
  }
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  cleanTmpDirs();
  testTmpDir.mkdirs();
  rootDir.mkdirs();
  initPort();
  config=new FtpConfigImpl(new PropertiesConfiguration(createConfig()));
  server=new FtpServer(config);
  server.start();
  client=new FTPClient();
  client.addProtocolCommandListener(new ProtocolCommandListener(){
    public void protocolCommandSent(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
    public void protocolReplyReceived(    ProtocolCommandEvent event){
      log.debug("String_Node_Str" + event.getMessage().trim());
    }
  }
);
  try {
    client.connect("String_Node_Str",port);
  }
 catch (  FTPConnectionClosedException e) {
    client.connect("String_Node_Str",port);
  }
}
Program: 152345
Project: 152345
Buggy source:
protected void tearDown() throws Exception {
  server.stop();
  IoUtils.delete(testTmpDir);
}

Fixed version (ground truth):
protected void tearDown() throws Exception {
  server.stop();
  cleanTmpDirs();
}
Program: 152348
Project: 152348
Buggy source:
/** 
 * Transfer data.
 */
public final long transfer(BufferedInputStream in,BufferedOutputStream out,int maxRate) throws IOException {
  boolean isAscii=dataType == DataType.ASCII;
  long startTime=System.currentTimeMillis();
  long transferredSize=0L;
  byte[] buff=new byte[4096];
  while (true) {
    if (maxRate > 0) {
      long interval=System.currentTimeMillis() - startTime;
      if (interval == 0) {
        interval=1;
      }
      long currRate=(transferredSize * 1000L) / interval;
      if (currRate > maxRate) {
        try {
          Thread.sleep(50);
        }
 catch (        InterruptedException ex) {
          break;
        }
      }
    }
    int count=in.read(buff);
    if (count == -1) {
      break;
    }
    if (isAscii) {
      for (int i=0; i < count; ++i) {
        byte b=buff[i];
        if (b == '\n') {
          out.write('\r');
        }
        out.write(b);
      }
    }
 else {
      out.write(buff,0,count);
    }
    transferredSize+=count;
    notifyObserver();
  }
  return transferredSize;
}

Fixed version (ground truth):
/** 
 * Transfer data.
 */
public final long transfer(BufferedInputStream in,BufferedOutputStream out,int maxRate) throws IOException {
  boolean isAscii=dataType == DataType.ASCII;
  long startTime=System.currentTimeMillis();
  long transferredSize=0L;
  byte[] buff=new byte[4096];
  while (true) {
    if (maxRate > 0) {
      long interval=System.currentTimeMillis() - startTime;
      if (interval == 0) {
        interval=1;
      }
      long currRate=(transferredSize * 1000L) / interval;
      if (currRate > maxRate) {
        try {
          Thread.sleep(50);
        }
 catch (        InterruptedException ex) {
          break;
        }
        continue;
      }
    }
    int count=in.read(buff);
    if (count == -1) {
      break;
    }
    if (isAscii) {
      for (int i=0; i < count; ++i) {
        byte b=buff[i];
        if (b == '\n') {
          out.write('\r');
        }
        out.write(b);
      }
    }
 else {
      out.write(buff,0,count);
    }
    transferredSize+=count;
    notifyObserver();
  }
  return transferredSize;
}
Program: 152351
Project: 152351
Buggy source:
/** 
 * Get unique file object.
 */
protected FileObject getUniqueFile(RequestHandler handler,FileObject oldFile) throws FtpException {
  FileObject newFile=oldFile;
  FileSystemView fsView=handler.getRequest().getFileSystemView();
  String fileName=newFile.getFullName();
  while (newFile.doesExist()) {
    newFile=fsView.getFileObject(fileName + '.' + System.currentTimeMillis());
  }
  return newFile;
}

Fixed version (ground truth):
/** 
 * Get unique file object.
 */
protected FileObject getUniqueFile(RequestHandler handler,FileObject oldFile) throws FtpException {
  FileObject newFile=oldFile;
  FileSystemView fsView=handler.getRequest().getFileSystemView();
  String fileName=newFile.getFullName();
  while (newFile.doesExist()) {
    newFile=fsView.getFileObject(fileName + '.' + System.currentTimeMillis());
    if (newFile == null) {
      break;
    }
  }
  return newFile;
}
Program: 152353
Project: 152353
Buggy source:
/** 
 * Equality check
 */
public boolean equals(Object obj){
  if (obj instanceof Ftplet) {
    return m_type == ((FtpletEnum)obj).m_type;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Equality check
 */
public boolean equals(Object obj){
  if (obj instanceof FtpletEnum) {
    return m_type == ((FtpletEnum)obj).m_type;
  }
  return false;
}
Program: 152354
Project: 152354
Buggy source:
/** 
 * Save user.
 */
private void save(){
  String userName=nameTxt.getText().trim();
  if (userName.equals("String_Node_Str")) {
    GuiUtils.showErrorMessage(this,"String_Node_Str");
    return;
  }
  try {
    BaseUser user=new BaseUser();
    user.setName(userName);
    if (setPassword(user)) {
      user.setHomeDirectory(new File(directoryTxt.getText()).getCanonicalPath());
      user.setEnabled(enabledChkBox.isSelected());
      user.setWritePermission(writeChkBox.isSelected());
      user.setMaxIdleTime(getMaxIdleTime(uploadLst));
      user.setMaxUploadRate(getBytesTransferRate(uploadLst));
      user.setMaxDownloadRate(getBytesTransferRate(downloadLst));
      fconfig.getUserManager().save(user);
      refresh(fconfig);
      GuiUtils.showInformationMessage(this,"String_Node_Str" + user.getName());
    }
  }
 catch (  Exception ex) {
    GuiUtils.showErrorMessage(this,ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Save user.
 */
private void save(){
  String userName=nameTxt.getText().trim();
  if (userName.equals("String_Node_Str")) {
    GuiUtils.showErrorMessage(this,"String_Node_Str");
    return;
  }
  try {
    BaseUser user=new BaseUser();
    user.setName(userName);
    if (setPassword(user)) {
      user.setHomeDirectory(directoryTxt.getText());
      user.setEnabled(enabledChkBox.isSelected());
      user.setWritePermission(writeChkBox.isSelected());
      user.setMaxIdleTime(getMaxIdleTime(idleLst));
      user.setMaxUploadRate(getBytesTransferRate(uploadLst));
      user.setMaxDownloadRate(getBytesTransferRate(downloadLst));
      fconfig.getUserManager().save(user);
      refresh(fconfig);
      GuiUtils.showInformationMessage(this,"String_Node_Str" + user.getName());
    }
  }
 catch (  Exception ex) {
    GuiUtils.showErrorMessage(this,ex.getMessage());
  }
}
Program: 152355
Project: 152355
Buggy source:
/** 
 * Refresh the ftp configuration
 */
public void refresh(IFtpConfig ftpConfig){
  fconfig=ftpConfig;
  int tabCount=tabbedPane.getTabCount();
  for (int i=0; i < tabCount; i++) {
    Component tabComp=tabbedPane.getComponentAt(i);
    if ((tabComp != null) && (tabComp != defaultComp)) {
      ((SpyPanel)tabComp).closePane();
      tabbedPane.remove(tabComp);
    }
  }
  tabbedPane.addTab("String_Node_Str",defaultComp);
}

Fixed version (ground truth):
/** 
 * Refresh the ftp configuration
 */
public void refresh(IFtpConfig ftpConfig){
  fconfig=ftpConfig;
  int tabCount=tabbedPane.getTabCount();
  for (int i=tabCount; --i >= 0; ) {
    Component tabComp=tabbedPane.getComponentAt(i);
    if ((tabComp != null) && (tabComp != defaultComp)) {
      ((SpyPanel)tabComp).closePane();
    }
  }
}
Program: 152356
Project: 152356
Buggy source:
/** 
 * <code>ABOR &lt;CRLF&gt;</code><br> This command tells the server to abort the previous FTP service command and any associated transfer of data. No action is to be taken if the previous command has been completed (including data transfer).  The control connection is not to be closed by the server, but the data connection must be closed. Current implementation does not do anything. As here data transfers are not multi-threaded.
 */
public void doABOR(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  mDataConnection.closeDataSocket();
  out.write(mFtpStatus.getResponse(226,request,mUser,null));
}

Fixed version (ground truth):
/** 
 * <code>ABOR &lt;CRLF&gt;</code><br> This command tells the server to abort the previous FTP service command and any associated transfer of data. No action is to be taken if the previous command has been completed (including data transfer).  The control connection is not to be closed by the server, but the data connection must be closed. Current implementation does not do anything. As here data transfers are not multi-threaded.
 */
public void doABOR(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  mDataConnection.closeDataSocket();
  out.write(mFtpStatus.getResponse(225,request,mUser,null));
}
Program: 152357
Project: 152357
Buggy source:
/** 
 * <code>CWD  &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br> This command allows the user to work with a different directory for file storage or retrieval without altering his login or accounting information.  Transfer parameters are similarly unchanged.  The argument is a pathname specifying a directory.
 */
public void doCWD(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  String dirName="String_Node_Str";
  if (request.hasArgument()) {
    dirName=request.getArgument();
  }
  if (mUser.getVirtualDirectory().changeDirectory(dirName)) {
    String args[]={mUser.getVirtualDirectory().getCurrentDirectory()};
    out.write(mFtpStatus.getResponse(200,request,mUser,args));
  }
 else {
    out.write(mFtpStatus.getResponse(431,request,mUser,null));
  }
}

Fixed version (ground truth):
/** 
 * <code>CWD  &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br> This command allows the user to work with a different directory for file storage or retrieval without altering his login or accounting information.  Transfer parameters are similarly unchanged.  The argument is a pathname specifying a directory.
 */
public void doCWD(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  String dirName="String_Node_Str";
  if (request.hasArgument()) {
    dirName=request.getArgument();
  }
  if (mUser.getVirtualDirectory().changeDirectory(dirName)) {
    String args[]={mUser.getVirtualDirectory().getCurrentDirectory()};
    out.write(mFtpStatus.getResponse(250,request,mUser,args));
  }
 else {
    out.write(mFtpStatus.getResponse(550,request,mUser,null));
  }
}
Program: 152358
Project: 152358
Buggy source:
/** 
 * <code>DELE &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br> This command causes the file specified in the pathname to be deleted at the server site.
 */
public void doDELE(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  if (!request.hasArgument()) {
    out.write(mFtpStatus.getResponse(501,request,mUser,null));
    return;
  }
  String fileName=request.getArgument();
  fileName=mUser.getVirtualDirectory().getAbsoluteName(fileName);
  String physicalName=mUser.getVirtualDirectory().getPhysicalName(fileName);
  File requestedFile=new File(physicalName);
  String[] args={fileName};
  if (!mUser.getVirtualDirectory().hasWritePermission(physicalName,true)) {
    out.write(mFtpStatus.getResponse(450,request,mUser,args));
    return;
  }
  if (requestedFile.delete()) {
    out.write(mFtpStatus.getResponse(250,request,mUser,args));
    mConfig.getStatistics().setDelete(requestedFile,mUser);
  }
 else {
    out.write(mFtpStatus.getResponse(450,request,mUser,args));
  }
}

Fixed version (ground truth):
/** 
 * <code>DELE &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br> This command causes the file specified in the pathname to be deleted at the server site.
 */
public void doDELE(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  if (!request.hasArgument()) {
    out.write(mFtpStatus.getResponse(501,request,mUser,null));
    return;
  }
  String fileName=request.getArgument();
  fileName=mUser.getVirtualDirectory().getAbsoluteName(fileName);
  String physicalName=mUser.getVirtualDirectory().getPhysicalName(fileName);
  File requestedFile=new File(physicalName);
  String[] args={fileName};
  if (!(requestedFile.exists() && requestedFile.isFile())) {
    out.write(mFtpStatus.getResponse(550,request,mUser,args));
    return;
  }
  if (!mUser.getVirtualDirectory().hasWritePermission(physicalName,true)) {
    out.write(mFtpStatus.getResponse(450,request,mUser,args));
    return;
  }
  if (requestedFile.delete()) {
    out.write(mFtpStatus.getResponse(250,request,mUser,args));
    mConfig.getStatistics().setDelete(requestedFile,mUser);
  }
 else {
    out.write(mFtpStatus.getResponse(450,request,mUser,args));
  }
}
Program: 152359
Project: 152359
Buggy source:
/** 
 * <code>CDUP &lt;CRLF&gt;</code><br> This command is a special case of CWD, and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory.  The reply codes shall be identical to the reply codes of CWD.
 */
public void doCDUP(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  if (mUser.getVirtualDirectory().changeDirectory("String_Node_Str")) {
    String args[]={mUser.getVirtualDirectory().getCurrentDirectory()};
    out.write(mFtpStatus.getResponse(200,request,mUser,args));
  }
 else {
    out.write(mFtpStatus.getResponse(431,request,mUser,null));
  }
}

Fixed version (ground truth):
/** 
 * <code>CDUP &lt;CRLF&gt;</code><br> This command is a special case of CWD, and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory.  The reply codes shall be identical to the reply codes of CWD.
 */
public void doCDUP(FtpRequest request,FtpWriter out) throws IOException {
  resetState();
  if (mUser.getVirtualDirectory().changeDirectory("String_Node_Str")) {
    String args[]={mUser.getVirtualDirectory().getCurrentDirectory()};
    out.write(mFtpStatus.getResponse(250,request,mUser,args));
  }
 else {
    out.write(mFtpStatus.getResponse(550,request,mUser,null));
  }
}
Program: 152360
Project: 152360
Buggy source:
/** 
 * Get <code>BufferedReader</code>.
 */
public static BufferedReader getBufferedReader(Reader rd){
  BufferedReader br=null;
  if (br instanceof java.io.BufferedReader) {
    br=(BufferedReader)rd;
  }
 else {
    br=new BufferedReader(rd);
  }
  return br;
}

Fixed version (ground truth):
/** 
 * Get <code>BufferedReader</code>.
 */
public static BufferedReader getBufferedReader(Reader rd){
  BufferedReader br=null;
  if (rd instanceof java.io.BufferedReader) {
    br=(BufferedReader)rd;
  }
 else {
    br=new BufferedReader(rd);
  }
  return br;
}
Program: 152361
Project: 152361
Buggy source:
@Override public void afterCompletion(HttpServletRequest request,HttpServletResponse response,Object handler,Exception ex) throws Exception {
  getSpringFacesContext().release();
}

Fixed version (ground truth):
@Override public void afterCompletion(HttpServletRequest request,HttpServletResponse response,Object handler,Exception ex) throws Exception {
  SpringFacesContextImpl context=getSpringFacesContext(false);
  if (context != null) {
    context.release();
  }
}
Program: 152362
Project: 152362
Buggy source:
/** 
 * Returns the   {@link SpringFacesContextImpl}.
 * @return the {@link SpringFacesContextImpl}
 */
private SpringFacesContextImpl getSpringFacesContext(){
  SpringFacesContext springFacesContext=SpringFacesContext.getCurrentInstance(true);
  Assert.isInstanceOf(SpringFacesContextImpl.class,springFacesContext,"String_Node_Str");
  return (SpringFacesContextImpl)springFacesContext;
}

Fixed version (ground truth):
/** 
 * Returns the   {@link SpringFacesContextImpl}.
 * @return the {@link SpringFacesContextImpl}
 */
private SpringFacesContextImpl getSpringFacesContext(boolean required){
  SpringFacesContext springFacesContext=SpringFacesContext.getCurrentInstance(required);
  if (springFacesContext == null) {
    return null;
  }
  Assert.isInstanceOf(SpringFacesContextImpl.class,springFacesContext,"String_Node_Str");
  return (SpringFacesContextImpl)springFacesContext;
}
Program: 152363
Project: 152363
Buggy source:
public ContactLocaleUtilsBase(LocaleSet locales){
  mUsePinyinTransliterator=locales.shouldPreferSimplifiedChinese();
  final ArraySet<Locale> addedLocales=new ArraySet<>();
  AlphabeticIndex ai=new AlphabeticIndex(locales.getPrimaryLocale()).setMaxLabelCount(300);
  addedLocales.add(locales.getPrimaryLocale());
  final LocaleList localeList=locales.getAllLocales();
  for (int i=0; i < localeList.size(); i++) {
    addLabels(ai,localeList.get(i),addedLocales);
  }
  for (int i=0; i < sDefaultLabelLocales.length; i++) {
    addLabels(ai,sDefaultLabelLocales[i],addedLocales);
  }
  mAlphabeticIndex=ai.buildImmutableIndex();
  mAlphabeticIndexBucketCount=mAlphabeticIndex.getBucketCount();
  mNumberBucketIndex=mAlphabeticIndexBucketCount - 1;
}

Fixed version (ground truth):
public ContactLocaleUtilsBase(LocaleSet systemLocales){
  mUsePinyinTransliterator=systemLocales.shouldPreferSimplifiedChinese();
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str");
  }
  final List<Locale> locales=getLocalesForBuckets(systemLocales);
  AlphabeticIndex ai=new AlphabeticIndex(locales.get(0)).setMaxLabelCount(300);
  for (int i=1; i < locales.size(); i++) {
    ai.addLabels(locales.get(i));
  }
  mAlphabeticIndex=ai.buildImmutableIndex();
  mAlphabeticIndexBucketCount=mAlphabeticIndex.getBucketCount();
  mNumberBucketIndex=mAlphabeticIndexBucketCount - 1;
  if (DEBUG) {
    final StringBuilder labels=new StringBuilder();
    String sep="String_Node_Str";
    for (int i=0; i < mAlphabeticIndexBucketCount; i++) {
      labels.append(sep);
      labels.append(mAlphabeticIndex.getBucket(i).getLabel());
      sep="String_Node_Str";
    }
    Log.d(TAG,"String_Node_Str" + labels + "String_Node_Str");
  }
}