nus-yam/ex-repair huggingface dataset:
Program: 152248
Project: 152248
Buggy source:
public void testPort() throws Exception {
  assertEquals(port,((NioListener)server.getServerContext().getListener("String_Node_Str")).getPort());
  server.start();
  assertEquals(port,((NioListener)server.getServerContext().getListener("String_Node_Str")).getPort());
}

Fixed version (ground truth):
public void testPort() throws Exception {
  assertEquals(0,((NioListener)server.getListener("String_Node_Str")).getPort());
  server.start();
  assertTrue(((NioListener)server.getListener("String_Node_Str")).getPort() > 0);
}
Program: 152249
Project: 152249
Buggy source:
public void testConnect() throws Exception {
  try {
    client.connect("String_Node_Str",port);
    fail("String_Node_Str");
  }
 catch (  FTPConnectionClosedException e) {
  }
}

Fixed version (ground truth):
public void testConnect() throws Exception {
  try {
    client.connect("String_Node_Str",getListenerPort());
    fail("String_Node_Str");
  }
 catch (  FTPConnectionClosedException e) {
  }
}
Program: 152250
Project: 152250
Buggy source:
public void testLoginWithMaxConnections() throws Exception {
  FTPClient client1=new FTPClient();
  FTPClient client2=new FTPClient();
  FTPClient client3=new FTPClient();
  FTPClient client4=new FTPClient();
  try {
    client1.connect("String_Node_Str",port);
    client2.connect("String_Node_Str",port);
    client3.connect("String_Node_Str",port);
    client4.connect("String_Node_Str",port);
    assertTrue(client1.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
    assertTrue(client2.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
    assertTrue(client3.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
    try {
      assertTrue(client4.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
      assertEquals(421,client.getReplyCode());
      fail("String_Node_Str");
    }
 catch (    FTPConnectionClosedException e) {
    }
  }
  finally {
    closeQuitely(client1);
    closeQuitely(client2);
    closeQuitely(client3);
    closeQuitely(client4);
  }
}

Fixed version (ground truth):
public void testLoginWithMaxConnections() throws Exception {
  FTPClient client1=new FTPClient();
  FTPClient client2=new FTPClient();
  FTPClient client3=new FTPClient();
  FTPClient client4=new FTPClient();
  try {
    client1.connect("String_Node_Str",getListenerPort());
    client2.connect("String_Node_Str",getListenerPort());
    client3.connect("String_Node_Str",getListenerPort());
    client4.connect("String_Node_Str",getListenerPort());
    assertTrue(client1.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
    assertTrue(client2.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
    assertTrue(client3.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
    try {
      assertTrue(client4.login(TESTUSER1_USERNAME,TESTUSER_PASSWORD));
      assertEquals(421,client.getReplyCode());
      fail("String_Node_Str");
    }
 catch (    FTPConnectionClosedException e) {
    }
  }
  finally {
    closeQuitely(client1);
    closeQuitely(client2);
    closeQuitely(client3);
    closeQuitely(client4);
  }
}
Program: 152251
Project: 152251
Buggy source:
public void testMultiplePasv() throws Exception {
  for (int i=0; i < 5; i++) {
    client.connect("String_Node_Str",port);
    client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
    client.pasv();
    client.quit();
    client.disconnect();
  }
}

Fixed version (ground truth):
public void testMultiplePasv() throws Exception {
  for (int i=0; i < 5; i++) {
    client.connect("String_Node_Str",getListenerPort());
    client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
    client.pasv();
    client.quit();
    client.disconnect();
  }
}
Program: 152252
Project: 152252
Buggy source:
/** 
 * This tests that the correct IP is returned, that is the IP that the client has connected to. Note that this test will only work if you got more than one NIC and the server is allowed to listen an all NICs
 */
public void testPasvIp() throws Exception {
  String[] ips=TestUtil.getHostAddresses();
  for (int i=0; i < ips.length; i++) {
    String ip=ips[i];
    String ftpIp=ip.replace('.',',');
    if (!ip.startsWith("String_Node_Str")) {
      try {
        client.connect(ip,port);
      }
 catch (      FTPConnectionClosedException e) {
        Thread.sleep(200);
        client.connect(ip,port);
      }
      client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
      client.pasv();
      assertTrue(client.getReplyString().indexOf(ftpIp) > -1);
      client.quit();
      client.disconnect();
    }
  }
}

Fixed version (ground truth):
/** 
 * This tests that the correct IP is returned, that is the IP that the client has connected to. Note that this test will only work if you got more than one NIC and the server is allowed to listen an all NICs
 */
public void testPasvIp() throws Exception {
  String[] ips=TestUtil.getHostAddresses();
  for (int i=0; i < ips.length; i++) {
    String ip=ips[i];
    String ftpIp=ip.replace('.',',');
    if (!ip.startsWith("String_Node_Str")) {
      try {
        client.connect(ip,getListenerPort());
      }
 catch (      FTPConnectionClosedException e) {
        Thread.sleep(200);
        client.connect(ip,getListenerPort());
      }
      client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
      client.pasv();
      assertTrue(client.getReplyString().indexOf(ftpIp) > -1);
      client.quit();
      client.disconnect();
    }
  }
}
Program: 152254
Project: 152254
Buggy source:
public void testConnect() throws Exception {
  try {
    client.connect("String_Node_Str",port);
    fail("String_Node_Str");
  }
 catch (  FTPConnectionClosedException e) {
  }
}

Fixed version (ground truth):
public void testConnect() throws Exception {
  try {
    client.connect("String_Node_Str",getListenerPort());
    fail("String_Node_Str");
  }
 catch (  FTPConnectionClosedException e) {
  }
}
Program: 152255
Project: 152255
Buggy source:
public void testSuspendResumeListener() throws Exception {
  client.connect("String_Node_Str",port);
  client.disconnect();
  server.getListener("String_Node_Str").suspend();
  try {
    client.connect("String_Node_Str",port);
    fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
 finally {
    client.disconnect();
  }
  server.getListener("String_Node_Str").resume();
  client.connect("String_Node_Str",port);
  client.disconnect();
}

Fixed version (ground truth):
public void testSuspendResumeListener() throws Exception {
  client.connect("String_Node_Str",getListenerPort());
  client.disconnect();
  server.getListener("String_Node_Str").suspend();
  try {
    client.connect("String_Node_Str",getListenerPort());
    fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
 finally {
    client.disconnect();
  }
  server.getListener("String_Node_Str").resume();
  client.connect("String_Node_Str",getListenerPort());
  client.disconnect();
}
Program: 152256
Project: 152256
Buggy source:
public void testSuspendResumeServer() throws Exception {
  client.connect("String_Node_Str",port);
  client.disconnect();
  server.suspend();
  try {
    client.connect("String_Node_Str",port);
    fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
 finally {
    client.disconnect();
  }
  server.resume();
  client.connect("String_Node_Str",port);
  client.disconnect();
}

Fixed version (ground truth):
public void testSuspendResumeServer() throws Exception {
  client.connect("String_Node_Str",getListenerPort());
  client.disconnect();
  server.suspend();
  try {
    client.connect("String_Node_Str",getListenerPort());
    fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
 finally {
    client.disconnect();
  }
  server.resume();
  client.connect("String_Node_Str",getListenerPort());
  client.disconnect();
}
Program: 152257
Project: 152257
Buggy source:
public void testFailStartingSecondListener() throws Exception {
  FtpServerFactory serverFactory=new FtpServerFactory();
  ListenerFactory listenerFactory=new ListenerFactory();
  listenerFactory.setPort(TestUtil.findFreePort());
  Listener defaultListener=listenerFactory.createListener();
  Listener secondListener=listenerFactory.createListener();
  serverFactory.addListener("String_Node_Str",defaultListener);
  serverFactory.addListener("String_Node_Str",secondListener);
  FtpServer server=serverFactory.createServer();
  try {
    server.start();
  }
 catch (  FtpServerConfigurationException e) {
    if (e.getCause() instanceof BindException) {
      assertTrue(defaultListener.isStopped());
      assertTrue(secondListener.isStopped());
      assertTrue(server.isStopped());
    }
 else {
      throw e;
    }
  }
}

Fixed version (ground truth):
public void testFailStartingSecondListener() throws Exception {
  FtpServerFactory serverFactory=new FtpServerFactory();
  ListenerFactory listenerFactory=new ListenerFactory();
  listenerFactory.setPort(0);
  Listener defaultListener=listenerFactory.createListener();
  Listener secondListener=listenerFactory.createListener();
  serverFactory.addListener("String_Node_Str",defaultListener);
  serverFactory.addListener("String_Node_Str",secondListener);
  FtpServer server=serverFactory.createServer();
  try {
    server.start();
  }
 catch (  FtpServerConfigurationException e) {
    if (e.getCause() instanceof BindException) {
      assertTrue(defaultListener.isStopped());
      assertTrue(secondListener.isStopped());
      assertTrue(server.isStopped());
    }
 else {
      throw e;
    }
  }
}
Program: 152260
Project: 152260
Buggy source:
private ResultSet selectUserByName(String name) throws SQLException {
  HashMap<String,Object> map=new HashMap<String,Object>();
  map.put(ATTR_LOGIN,escapeString(name));
  String sql=StringUtils.replaceString(selectUserStmt,map);
  LOG.info(sql);
  Statement stmt=null;
  try {
    stmt=createConnection().createStatement();
    return stmt.executeQuery(sql);
  }
  finally {
    closeQuitely(stmt);
  }
}

Fixed version (ground truth):
private BaseUser selectUserByName(String name) throws SQLException {
  HashMap<String,Object> map=new HashMap<String,Object>();
  map.put(ATTR_LOGIN,escapeString(name));
  String sql=StringUtils.replaceString(selectUserStmt,map);
  LOG.info(sql);
  Statement stmt=null;
  ResultSet rs=null;
  try {
    stmt=createConnection().createStatement();
    rs=stmt.executeQuery(sql);
    BaseUser thisUser=null;
    if (rs.next()) {
      thisUser=new BaseUser();
      thisUser.setName(rs.getString(ATTR_LOGIN));
      thisUser.setPassword(rs.getString(ATTR_PASSWORD));
      thisUser.setHomeDirectory(rs.getString(ATTR_HOME));
      thisUser.setEnabled(rs.getBoolean(ATTR_ENABLE));
      thisUser.setMaxIdleTime(rs.getInt(ATTR_MAX_IDLE_TIME));
      List<Authority> authorities=new ArrayList<Authority>();
      if (rs.getBoolean(ATTR_WRITE_PERM)) {
        authorities.add(new WritePermission());
      }
      authorities.add(new ConcurrentLoginPermission(rs.getInt(ATTR_MAX_LOGIN_NUMBER),rs.getInt(ATTR_MAX_LOGIN_PER_IP)));
      authorities.add(new TransferRatePermission(rs.getInt(ATTR_MAX_DOWNLOAD_RATE),rs.getInt(ATTR_MAX_UPLOAD_RATE)));
      thisUser.setAuthorities(authorities);
    }
    return thisUser;
  }
  finally {
    closeQuitely(rs);
    closeQuitely(stmt);
  }
}
Program: 152261
Project: 152261
Buggy source:
/** 
 * Get the user object. Fetch the row from the table.
 */
public User getUserByName(String name) throws FtpException {
  Statement stmt=null;
  ResultSet rs=null;
  try {
    rs=selectUserByName(name);
    BaseUser thisUser=null;
    if (rs.next()) {
      thisUser=new BaseUser();
      thisUser.setName(rs.getString(ATTR_LOGIN));
      thisUser.setHomeDirectory(rs.getString(ATTR_HOME));
      thisUser.setEnabled(rs.getBoolean(ATTR_ENABLE));
      thisUser.setMaxIdleTime(rs.getInt(ATTR_MAX_IDLE_TIME));
      List<Authority> authorities=new ArrayList<Authority>();
      if (rs.getBoolean(ATTR_WRITE_PERM)) {
        authorities.add(new WritePermission());
      }
      authorities.add(new ConcurrentLoginPermission(rs.getInt(ATTR_MAX_LOGIN_NUMBER),rs.getInt(ATTR_MAX_LOGIN_PER_IP)));
      authorities.add(new TransferRatePermission(rs.getInt(ATTR_MAX_DOWNLOAD_RATE),rs.getInt(ATTR_MAX_UPLOAD_RATE)));
      thisUser.setAuthorities(authorities);
    }
    return thisUser;
  }
 catch (  SQLException ex) {
    LOG.error("String_Node_Str",ex);
    throw new FtpException("String_Node_Str",ex);
  }
 finally {
    closeQuitely(rs);
    closeQuitely(stmt);
  }
}

Fixed version (ground truth):
/** 
 * Get the user object. Fetch the row from the table.
 */
public User getUserByName(String name) throws FtpException {
  Statement stmt=null;
  ResultSet rs=null;
  try {
    BaseUser user=selectUserByName(name);
    if (user != null) {
      user.setPassword(null);
    }
    return user;
  }
 catch (  SQLException ex) {
    LOG.error("String_Node_Str",ex);
    throw new FtpException("String_Node_Str",ex);
  }
 finally {
    closeQuitely(rs);
    closeQuitely(stmt);
  }
}
Program: 152262
Project: 152262
Buggy source:
void init(FtpServerContext context,Listener listener) throws Exception ;

Fixed version (ground truth):
void init(FtpServerContext context,Listener listener);
Program: 152263
Project: 152263
Buggy source:
/** 
 * Start the listener, will initiate the listener waiting on the socket. The method should not return until the listener has started accepting socket requests.
 * @throws Exception On error during start up
 */
void start(FtpServerContext serverContext) throws Exception ;

Fixed version (ground truth):
/** 
 * Start the listener, will initiate the listener waiting on the socket. The method should not return until the listener has started accepting socket requests.
 * @throws Exception On error during start up
 */
void start(FtpServerContext serverContext);
Program: 152264
Project: 152264
Buggy source:
/** 
 * Start the server. Open a new listener thread.
 */
public void start() throws Exception {
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.start(serverContext);
  }
  serverContext.getFtpletContainer().init(serverContext);
  started=true;
  LOG.info("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Start the server. Open a new listener thread.
 * @throws FtpException 
 */
public void start() throws FtpException {
  List<Listener> startedListeners=new ArrayList<Listener>();
  try {
    Map<String,Listener> listeners=serverContext.getListeners();
    for (    Listener listener : listeners.values()) {
      listener.start(serverContext);
      startedListeners.add(listener);
    }
    serverContext.getFtpletContainer().init(serverContext);
    started=true;
    LOG.info("String_Node_Str");
  }
 catch (  Exception e) {
    for (    Listener listener : startedListeners) {
      listener.stop();
    }
    if (e instanceof FtpException) {
      throw (FtpException)e;
    }
 else {
      throw (RuntimeException)e;
    }
  }
}
Program: 152265
Project: 152265
Buggy source:
/** 
 * Stop the server. Stop the listener thread.
 */
public void stop(){
  if (!started || serverContext == null) {
    return;
  }
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.stop();
  }
  if (serverContext != null) {
    serverContext.dispose();
    serverContext=null;
  }
  started=false;
}

Fixed version (ground truth):
/** 
 * Stop the server. Stop the listener thread.
 */
public void stop(){
  if (serverContext == null) {
    return;
  }
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.stop();
  }
  if (serverContext != null) {
    serverContext.dispose();
    serverContext=null;
  }
  started=false;
}
Program: 152266
Project: 152266
Buggy source:
/** 
 * @see Listener#stop()
 */
public synchronized void stop(){
  if (acceptor != null) {
    acceptor.unbind();
    acceptor.dispose();
    acceptor=null;
  }
  if (filterExecutor != null) {
    filterExecutor.shutdown();
    try {
      filterExecutor.awaitTermination(5000,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
    }
 finally {
    }
  }
}

Fixed version (ground truth):
/** 
 * @see Listener#stop()
 */
public synchronized void stop(){
  if (acceptor != null) {
    acceptor.unbind();
    acceptor.dispose();
    acceptor=null;
  }
  if (filterExecutor != null) {
    filterExecutor.shutdown();
    try {
      filterExecutor.awaitTermination(5000,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
    }
 finally {
    }
  }
  context=null;
}
Program: 152268
Project: 152268
Buggy source:
/** 
 * Suspend further requests
 */
public void suspend(){
  if (!started) {
    return;
  }
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.suspend();
  }
  suspended=true;
}

Fixed version (ground truth):
/** 
 * Suspend further requests
 */
public void suspend(){
  if (!started) {
    return;
  }
  LOG.debug("String_Node_Str");
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.suspend();
  }
  suspended=true;
  LOG.debug("String_Node_Str");
}
Program: 152269
Project: 152269
Buggy source:
/** 
 * Resume the server handler
 */
public void resume(){
  if (!suspended) {
    return;
  }
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.resume();
  }
  suspended=false;
}

Fixed version (ground truth):
/** 
 * Resume the server handler
 */
public void resume(){
  if (!suspended) {
    return;
  }
  LOG.debug("String_Node_Str");
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.resume();
  }
  suspended=false;
  LOG.debug("String_Node_Str");
}
Program: 152270
Project: 152270
Buggy source:
/** 
 * @see Listener#resume()
 */
public synchronized void resume(){
  if (acceptor != null && suspended) {
    try {
      acceptor.bind(address);
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * @see Listener#resume()
 */
public synchronized void resume(){
  if (acceptor != null && suspended) {
    try {
      LOG.debug("String_Node_Str");
      acceptor.bind(address);
      LOG.debug("String_Node_Str");
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",e);
    }
  }
}
Program: 152271
Project: 152271
Buggy source:
/** 
 * @see Listener#suspend()
 */
public synchronized void suspend(){
  if (acceptor != null && !suspended) {
    acceptor.unbind(address);
  }
}

Fixed version (ground truth):
/** 
 * @see Listener#suspend()
 */
public synchronized void suspend(){
  if (acceptor != null && !suspended) {
    LOG.debug("String_Node_Str");
    acceptor.unbind();
    suspended=true;
    LOG.debug("String_Node_Str");
  }
}
Program: 152273
Project: 152273
Buggy source:
/** 
 * Start the server. Open a new listener thread.
 */
public void start() throws Exception {
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.start(serverContext);
  }
  started=true;
  LOG.info("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Start the server. Open a new listener thread.
 */
public void start() throws Exception {
  Map<String,Listener> listeners=serverContext.getListeners();
  for (  Listener listener : listeners.values()) {
    listener.start(serverContext);
  }
  serverContext.getFtpletContainer().init(serverContext);
  started=true;
  LOG.info("String_Node_Str");
}
Program: 152274
Project: 152274
Buggy source:
public void init(FtpletContext ftpletContext) throws FtpException {
}

Fixed version (ground truth):
public synchronized void init(FtpletContext ftpletContext) throws FtpException {
  this.ftpletContext=ftpletContext;
  for (  Entry<String,Ftplet> entry : ftplets.entrySet()) {
    entry.getValue().init(ftpletContext);
  }
}
Program: 152275
Project: 152275
Buggy source:
/** 
 * @see FtpletContainer#setFtplets(Map)
 */
public void setFtplets(Map<String,Ftplet> ftplets){
  this.ftplets=ftplets;
}

Fixed version (ground truth):
/** 
 * @see FtpletContainer#setFtplets(Map)
 */
public synchronized void setFtplets(Map<String,Ftplet> ftplets){
  this.ftplets=ftplets;
}
Program: 152276
Project: 152276
Buggy source:
/** 
 * Get Ftplet for the given name.
 */
public Ftplet getFtplet(String name){
  if (name == null) {
    return null;
  }
  return ftplets.get(name);
}

Fixed version (ground truth):
/** 
 * Get Ftplet for the given name.
 */
public synchronized Ftplet getFtplet(String name){
  if (name == null) {
    return null;
  }
  return ftplets.get(name);
}
Program: 152277
Project: 152277
Buggy source:
/** 
 * @see FtpletContainer#getFtplets()
 */
public Map<String,Ftplet> getFtplets(){
  return ftplets;
}

Fixed version (ground truth):
/** 
 * @see FtpletContainer#getFtplets()
 */
public synchronized Map<String,Ftplet> getFtplets(){
  return ftplets;
}
Program: 152278
Project: 152278
Buggy source:
public void addFtplet(String name,Ftplet ftplet){
  if (getFtplet(name) != null) {
    throw new IllegalArgumentException("String_Node_Str" + name + "String_Node_Str");
  }
  ftplets.put(name,ftplet);
}

Fixed version (ground truth):
public synchronized void addFtplet(String name,Ftplet ftplet) throws FtpException {
  if (getFtplet(name) != null) {
    throw new IllegalArgumentException("String_Node_Str" + name + "String_Node_Str");
  }
  ftplets.put(name,ftplet);
  if (ftpletContext != null) {
    ftplet.init(ftpletContext);
  }
}
Program: 152279
Project: 152279
Buggy source:
public void dispose(){
  for (  Entry<String,Ftplet> entry : ftplets.entrySet()) {
    try {
      entry.getValue().destroy();
    }
 catch (    Exception ex) {
      LOG.error(entry.getKey() + "String_Node_Str",ex);
    }
  }
  ftplets.clear();
}

Fixed version (ground truth):
public synchronized void dispose(){
  for (  Entry<String,Ftplet> entry : ftplets.entrySet()) {
    try {
      entry.getValue().destroy();
    }
 catch (    Exception ex) {
      LOG.error(entry.getKey() + "String_Node_Str",ex);
    }
  }
  ftplets.clear();
}
Program: 152280
Project: 152280
Buggy source:
public Ftplet removeFtplet(String name){
  Ftplet ftplet=ftplets.get(name);
  if (ftplet != null) {
    ftplets.remove(name);
    return ftplet;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public synchronized Ftplet removeFtplet(String name){
  Ftplet ftplet=ftplets.get(name);
  if (ftplet != null) {
    ftplets.remove(name);
    return ftplet;
  }
 else {
    return null;
  }
}
Program: 152281
Project: 152281
Buggy source:
/** 
 * Add an   {@link Ftplet} to the container.
 * @param name The name of the Ftplet to be added
 * @param ftplet The Ftplet
 * @throws IllegalArgumentException If an Ftplet with the same name already exist within the container
 */
void addFtplet(String name,Ftplet ftplet);

Fixed version (ground truth):
/** 
 * Add an   {@link Ftplet} to the container.
 * @param name The name of the Ftplet to be added
 * @param ftplet The Ftplet
 * @throws FtpException 
 * @throws IllegalArgumentException If an Ftplet with the same name already exist within the container
 */
void addFtplet(String name,Ftplet ftplet) throws FtpException ;
Program: 152282
Project: 152282
Buggy source:
public void testAddAndGetFtplet(){
  MockFtplet ftplet1=new MockFtplet();
  MockFtplet ftplet2=new MockFtplet();
  assertNull(container.getFtplet("String_Node_Str"));
  assertNull(container.getFtplet("String_Node_Str"));
  container.addFtplet("String_Node_Str",ftplet1);
  container.addFtplet("String_Node_Str",ftplet2);
  assertSame(ftplet1,container.getFtplet("String_Node_Str"));
  assertSame(ftplet2,container.getFtplet("String_Node_Str"));
}

Fixed version (ground truth):
public void testAddAndGetFtplet() throws FtpException {
  MockFtplet ftplet1=new MockFtplet();
  MockFtplet ftplet2=new MockFtplet();
  assertNull(container.getFtplet("String_Node_Str"));
  assertNull(container.getFtplet("String_Node_Str"));
  container.addFtplet("String_Node_Str",ftplet1);
  container.addFtplet("String_Node_Str",ftplet2);
  assertSame(ftplet1,container.getFtplet("String_Node_Str"));
  assertSame(ftplet2,container.getFtplet("String_Node_Str"));
}
Program: 152283
Project: 152283
Buggy source:
public void testRemoveFtplet(){
  MockFtplet ftplet1=new MockFtplet();
  MockFtplet ftplet2=new MockFtplet();
  container.addFtplet("String_Node_Str",ftplet1);
  container.addFtplet("String_Node_Str",ftplet2);
  assertSame(ftplet1,container.getFtplet("String_Node_Str"));
  assertSame(ftplet2,container.getFtplet("String_Node_Str"));
  assertSame(ftplet1,container.removeFtplet("String_Node_Str"));
  assertNull(container.getFtplet("String_Node_Str"));
  assertSame(ftplet2,container.getFtplet("String_Node_Str"));
  assertNull(container.removeFtplet("String_Node_Str"));
}

Fixed version (ground truth):
public void testRemoveFtplet() throws FtpException {
  MockFtplet ftplet1=new MockFtplet();
  MockFtplet ftplet2=new MockFtplet();
  container.addFtplet("String_Node_Str",ftplet1);
  container.addFtplet("String_Node_Str",ftplet2);
  assertSame(ftplet1,container.getFtplet("String_Node_Str"));
  assertSame(ftplet2,container.getFtplet("String_Node_Str"));
  assertSame(ftplet1,container.removeFtplet("String_Node_Str"));
  assertNull(container.getFtplet("String_Node_Str"));
  assertSame(ftplet2,container.getFtplet("String_Node_Str"));
  assertNull(container.removeFtplet("String_Node_Str"));
}
Program: 152284
Project: 152284
Buggy source:
public void testAddFtpletWithDuplicateName(){
  MockFtplet ftplet1=new MockFtplet();
  MockFtplet ftplet2=new MockFtplet();
  assertNull(container.getFtplet("String_Node_Str"));
  container.addFtplet("String_Node_Str",ftplet1);
  try {
    container.addFtplet("String_Node_Str",ftplet2);
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException e) {
  }
  assertSame(ftplet1,container.getFtplet("String_Node_Str"));
}

Fixed version (ground truth):
public void testAddFtpletWithDuplicateName() throws FtpException {
  MockFtplet ftplet1=new MockFtplet();
  MockFtplet ftplet2=new MockFtplet();
  assertNull(container.getFtplet("String_Node_Str"));
  container.addFtplet("String_Node_Str",ftplet1);
  try {
    container.addFtplet("String_Node_Str",ftplet2);
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException e) {
  }
  assertSame(ftplet1,container.getFtplet("String_Node_Str"));
}
Program: 152285
Project: 152285
Buggy source:
public void init(FtpletContext ftpletContext) throws FtpException {
  callback.init(ftpletContext);
}

Fixed version (ground truth):
public void init(FtpletContext ftpletContext) throws FtpException {
  this.context=ftpletContext;
  callback.init(ftpletContext);
}
Program: 152286
Project: 152286
Buggy source:
public void destroy(){
  callback.destroy();
}

Fixed version (ground truth):
public void destroy(){
  destroyed=true;
  callback.destroy();
}
Program: 152287
Project: 152287
Buggy source:
/** 
 * Execute command
 */
public void execute(final FtpIoSession session,final FtpServerContext context,final FtpRequest request) throws IOException {
  session.resetState();
  session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_221_CLOSING_CONTROL_CONNECTION,"String_Node_Str",null));
  session.closeOnFlush().awaitUninterruptibly(10000);
}

Fixed version (ground truth):
/** 
 * Execute command
 */
public void execute(final FtpIoSession session,final FtpServerContext context,final FtpRequest request) throws IOException {
  session.resetState();
  session.write(LocalizedFtpReply.translate(session,request,context,FtpReply.REPLY_221_CLOSING_CONTROL_CONNECTION,"String_Node_Str",null));
  session.closeOnFlush().awaitUninterruptibly(10000);
  session.getDataConnection().closeDataConnection();
}
Program: 152288
Project: 152288
Buggy source:
/** 
 * Attempts to find a free port or fallback to a default
 * @throws IOException
 * @throws IOException
 */
public static int findFreePort() throws IOException {
  int port=-1;
  ServerSocket tmpSocket=null;
  try {
    tmpSocket=new ServerSocket(DEFAULT_PORT);
    port=DEFAULT_PORT;
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str");
    try {
      int attempts=0;
      while (port < 1024 && attempts < 1000) {
        attempts++;
        tmpSocket=new ServerSocket(0);
        port=tmpSocket.getLocalPort();
      }
    }
 catch (    IOException e1) {
      throw new IOException("String_Node_Str" + e1.getMessage());
    }
  }
 finally {
    if (tmpSocket != null) {
      try {
        tmpSocket.close();
      }
 catch (      IOException e) {
      }
      tmpSocket=null;
    }
  }
  return port;
}

Fixed version (ground truth):
/** 
 * Attempts to find a free port
 * @param initPort The first port to try, before resolving to brute force searching
 * @throws IOException
 * @throws IOException
 */
public static int findFreePort(int initPort) throws IOException {
  int port=-1;
  ServerSocket tmpSocket=null;
  try {
    tmpSocket=new ServerSocket(initPort);
    port=initPort;
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str");
    try {
      int attempts=0;
      while (port < 1024 && attempts < 1000) {
        attempts++;
        tmpSocket=new ServerSocket(0);
        port=tmpSocket.getLocalPort();
      }
    }
 catch (    IOException e1) {
      throw new IOException("String_Node_Str" + e1.getMessage());
    }
  }
 finally {
    if (tmpSocket != null) {
      try {
        tmpSocket.close();
      }
 catch (      IOException e) {
      }
      tmpSocket=null;
    }
  }
  return port;
}
Program: 152289
Project: 152289
Buggy source:
/** 
 * Close data socket.
 */
void closeDataConnection();

Fixed version (ground truth):
/** 
 * Close data socket. If no open data connection exists, this will silently ignore the call.
 */
void closeDataConnection();
Program: 152290
Project: 152290
Buggy source:
/** 
 * Get the SQL SELECT statement used to find whether an user is admin or not.
 * @return The SQL statement
 */
public String getSqlUserAdmin(){
  return selectAllStmt;
}

Fixed version (ground truth):
/** 
 * Get the SQL SELECT statement used to find whether an user is admin or not.
 * @return The SQL statement
 */
public String getSqlUserAdmin(){
  return isAdminStmt;
}
Program: 152291
Project: 152291
Buggy source:
/** 
 * Get the SQL DELETE statement used to delete an existing user.
 * @return The SQL statement
 */
public String getSqlUserDelete(){
  return insertUserStmt;
}

Fixed version (ground truth):
/** 
 * Get the SQL DELETE statement used to delete an existing user.
 * @return The SQL statement
 */
public String getSqlUserDelete(){
  return deleteUserStmt;
}
Program: 152292
Project: 152292
Buggy source:
/** 
 * Get the SQL SELECT statement used to authenticate user.
 * @return The SQL statement
 */
public String getSqlUserAuthenticate(){
  return selectAllStmt;
}

Fixed version (ground truth):
/** 
 * Get the SQL SELECT statement used to authenticate user.
 * @return The SQL statement
 */
public String getSqlUserAuthenticate(){
  return authenticateStmt;
}
Program: 152293
Project: 152293
Buggy source:
/** 
 * Initiate a data connection in passive mode (server listening).  It returns the success flag.
 */
public synchronized InetSocketAddress initPassiveDataConnection() throws DataConnectionException {
  closeDataConnection();
  int passivePort=session.getListener().getDataConnectionConfiguration().requestPassivePort();
  if (passivePort == -1) {
    servSoc=null;
    throw new DataConnectionException("String_Node_Str");
  }
  try {
    DataConnectionConfiguration dataCfg=session.getListener().getDataConnectionConfiguration();
    address=dataCfg.getPassiveAddress();
    if (address == null) {
      address=serverControlAddress;
    }
    if (secure) {
      SslConfiguration ssl=dataCfg.getSSLConfiguration();
      if (ssl == null) {
        throw new DataConnectionException("String_Node_Str");
      }
      servSoc=createServerSocket(ssl,address,passivePort);
      port=servSoc.getLocalPort();
      LOG.debug("String_Node_Str" + address + "String_Node_Str"+ port);
    }
 else {
      servSoc=new ServerSocket(passivePort,1,address);
      port=servSoc.getLocalPort();
      LOG.debug("String_Node_Str" + address + "String_Node_Str"+ port);
    }
    servSoc.setSoTimeout(dataCfg.getMaxIdleTimeMillis());
    passive=true;
    requestTime=System.currentTimeMillis();
    return new InetSocketAddress(address,port);
  }
 catch (  Exception ex) {
    servSoc=null;
    closeDataConnection();
    throw new DataConnectionException("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
/** 
 * Initiate a data connection in passive mode (server listening).  It returns the success flag.
 */
public synchronized InetSocketAddress initPassiveDataConnection() throws DataConnectionException {
  LOG.debug("String_Node_Str");
  closeDataConnection();
  int passivePort=session.getListener().getDataConnectionConfiguration().requestPassivePort();
  if (passivePort == -1) {
    servSoc=null;
    throw new DataConnectionException("String_Node_Str");
  }
  try {
    DataConnectionConfiguration dataCfg=session.getListener().getDataConnectionConfiguration();
    address=dataCfg.getPassiveAddress();
    if (address == null) {
      address=serverControlAddress;
    }
    if (secure) {
      LOG.debug("String_Node_Str",address,passivePort);
      SslConfiguration ssl=dataCfg.getSSLConfiguration();
      if (ssl == null) {
        throw new DataConnectionException("String_Node_Str");
      }
      servSoc=createServerSocket(ssl,address,passivePort);
      port=servSoc.getLocalPort();
      LOG.debug("String_Node_Str",address,passivePort);
    }
 else {
      LOG.debug("String_Node_Str",address,passivePort);
      servSoc=new ServerSocket(passivePort,0,address);
      port=servSoc.getLocalPort();
      LOG.debug("String_Node_Str",address,passivePort);
    }
    servSoc.setSoTimeout(dataCfg.getMaxIdleTimeMillis());
    passive=true;
    requestTime=System.currentTimeMillis();
    return new InetSocketAddress(address,port);
  }
 catch (  Exception ex) {
    servSoc=null;
    closeDataConnection();
    throw new DataConnectionException("String_Node_Str" + ex.getMessage(),ex);
  }
}
Program: 152294
Project: 152294
Buggy source:
public void sessionOpened(FtpIoSession session) throws Exception {
  session.write(FtpReplyUtil.translate(session,null,context,FtpReply.REPLY_220_SERVICE_READY,null,null));
}

Fixed version (ground truth):
public void sessionOpened(FtpIoSession session) throws Exception {
  context.getFtpletContainer().onConnect(session.getFtpletSession());
  session.write(FtpReplyUtil.translate(session,null,context,FtpReply.REPLY_220_SERVICE_READY,null,null));
}
Program: 152295
Project: 152295
Buggy source:
public void sessionClosed(FtpIoSession session) throws Exception {
  ServerFtpStatistics stats=((ServerFtpStatistics)context.getFtpStatistics());
  if (stats != null) {
    stats.setLogout(session);
  }
}

Fixed version (ground truth):
public void sessionClosed(FtpIoSession session) throws Exception {
  context.getFtpletContainer().onDisconnect(session.getFtpletSession());
  ServerFtpStatistics stats=((ServerFtpStatistics)context.getFtpStatistics());
  if (stats != null) {
    stats.setLogout(session);
  }
}
Program: 152296
Project: 152296
Buggy source:
public void sessionClosed(FtpIoSession session) throws Exception {
  context.getFtpletContainer().onDisconnect(session.getFtpletSession());
  ServerFtpStatistics stats=((ServerFtpStatistics)context.getFtpStatistics());
  if (stats != null) {
    stats.setLogout(session);
  }
}

Fixed version (ground truth):
public void sessionClosed(FtpIoSession session) throws Exception {
  try {
    context.getFtpletContainer().onDisconnect(session.getFtpletSession());
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str",e);
  }
  ServerFtpStatistics stats=((ServerFtpStatistics)context.getFtpStatistics());
  if (stats != null) {
    stats.setLogout(session);
  }
}
Program: 152297
Project: 152297
Buggy source:
Authority[] getAuthorities(Class<Authority> clazz);

Fixed version (ground truth):
Authority[] getAuthorities(Class<? extends Authority> clazz);
Program: 152298
Project: 152298
Buggy source:
public Authority[] getAuthorities(Class<Authority> clazz){
  List<Authority> selected=new ArrayList<Authority>();
  for (int i=0; i < authorities.length; i++) {
    if (authorities[i].getClass().equals(clazz)) {
      selected.add(authorities[i]);
    }
  }
  return selected.toArray(new Authority[0]);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public Authority[] getAuthorities(Class<? extends Authority> clazz){
  List<Authority> selected=new ArrayList<Authority>();
  for (int i=0; i < authorities.length; i++) {
    if (authorities[i].getClass().equals(clazz)) {
      selected.add(authorities[i]);
    }
  }
  return selected.toArray(new Authority[0]);
}
Program: 152299
Project: 152299
Buggy source:
/** 
 * @see User#authorize(AuthorizationRequest)
 */
public AuthorizationRequest authorize(AuthorizationRequest request){
  Authority[] authorities=getAuthorities();
  boolean someoneCouldAuthorize=false;
  for (int i=0; i < authorities.length; i++) {
    Authority authority=authorities[i];
    if (authority.canAuthorize(request)) {
      someoneCouldAuthorize=true;
      request=authority.authorize(request);
      if (request == null) {
        return null;
      }
    }
  }
  if (someoneCouldAuthorize) {
    return request;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public AuthorizationRequest authorize(AuthorizationRequest request){
  Authority[] authorities=getAuthorities();
  boolean someoneCouldAuthorize=false;
  for (int i=0; i < authorities.length; i++) {
    Authority authority=authorities[i];
    if (authority.canAuthorize(request)) {
      someoneCouldAuthorize=true;
      request=authority.authorize(request);
      if (request == null) {
        return null;
      }
    }
  }
  if (someoneCouldAuthorize) {
    return request;
  }
 else {
    return null;
  }
}
Program: 152301
Project: 152301
Buggy source:
/** 
 * Constructor.
 */
protected NativeFileObject(String fileName,File file,User user){
  if (fileName == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (file == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  fileName=fileName.trim();
  if (fileName.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (fileName.charAt(0) != '/') {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.fileName=fileName;
  this.file=file;
  this.user=user;
}

Fixed version (ground truth):
/** 
 * Constructor.
 */
protected NativeFileObject(String fileName,File file,User user){
  if (fileName == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (file == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (fileName.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (fileName.charAt(0) != '/') {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.fileName=fileName;
  this.file=file;
  this.user=user;
}
Program: 152302
Project: 152302
Buggy source:
public void testCWD() throws Exception {
  assertTrue(client.changeWorkingDirectory(TEST_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory(TEST_DIR_IN_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory('/' + TEST_DIR2.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory("String_Node_Str"));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory(TEST_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory("String_Node_Str"));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory("String_Node_Str"));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory(TEST_DIR1.getName() + '/' + TEST_DIR_IN_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
}

Fixed version (ground truth):
public void testCWD() throws Exception {
  assertTrue(client.changeWorkingDirectory(TEST_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory(TEST_DIR_IN_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory('/' + TEST_DIR2.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory("String_Node_Str"));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory("String_Node_Str"));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory(TEST_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory("String_Node_Str"));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory("String_Node_Str"));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
  assertTrue(client.changeWorkingDirectory(TEST_DIR1.getName() + '/' + TEST_DIR_IN_DIR1.getName()));
  assertEquals("String_Node_Str",client.printWorkingDirectory());
}
Program: 152303
Project: 152303
Buggy source:
protected void setUp() throws Exception {
  super.setUp();
  TEST_DIR1.mkdirs();
  TEST_DIR2.mkdirs();
  TEST_DIR_IN_DIR1.mkdirs();
  assertTrue(TEST_DIR1.exists());
  assertTrue(TEST_DIR2.exists());
  assertTrue(TEST_DIR_IN_DIR1.exists());
  client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  super.setUp();
  TEST_DIR1.mkdirs();
  TEST_DIR2.mkdirs();
  TEST_DIR_WITH_LEADING_SPACE.mkdirs();
  TEST_DIR_IN_DIR1.mkdirs();
  assertTrue(TEST_DIR1.exists());
  assertTrue(TEST_DIR2.exists());
  assertTrue(TEST_DIR_WITH_LEADING_SPACE.exists());
  assertTrue(TEST_DIR_IN_DIR1.exists());
  client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
}
Program: 152305
Project: 152305
Buggy source:
/** 
 * @throws Exception
 */
private void doAssertOfUniqueFile(FTPClient client,File dir) throws Exception {
  assertTrue(client.completePendingCommand());
  String reply=client.getReplyString();
  String generatedFileName=reply.substring(5,reply.indexOf(':'));
  File testFile=new File(dir,generatedFileName);
  assertTrue(testFile.exists());
  TestUtil.assertFileEqual(testData,testFile);
}

Fixed version (ground truth):
/** 
 * @throws Exception
 */
private void doAssertOfUniqueFile(FTPClient client,File dir) throws Exception {
  String reply=client.getReplyString();
  String generatedFileName=reply.substring(5,reply.indexOf(':'));
  File testFile=new File(dir,generatedFileName);
  assertTrue(testFile.exists());
  TestUtil.assertFileEqual(testData,testFile);
}
Program: 152306
Project: 152306
Buggy source:
public void testUploadUnique() throws Exception {
  client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
  client.storeUniqueFile(new ByteArrayInputStream(TESTDATA));
  client.completePendingCommand();
  TestUtil.assertFileEqual(TESTDATA,ROOT_DIR.listFiles()[0]);
}

Fixed version (ground truth):
public void testUploadUnique() throws Exception {
  client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
  client.storeUniqueFile(new ByteArrayInputStream(TESTDATA));
  TestUtil.assertFileEqual(TESTDATA,ROOT_DIR.listFiles()[0]);
}
Program: 152307
Project: 152307
Buggy source:
public void testExceptionDuringUploadUniqueEnd() throws Exception {
  MockFtplet.callback=new MockFtpletCallback(){
    public FtpletEnum onUploadUniqueEnd(    FtpSession session,    FtpRequest request,    FtpReplyOutput response) throws FtpException, IOException {
      throwException();
      return mockReturnValue;
    }
  }
;
  client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
  assertTrue(client.storeUniqueFile(new ByteArrayInputStream(TESTDATA)));
  assertTrue(client.completePendingCommand());
  try {
    client.noop();
    fail("String_Node_Str");
  }
 catch (  FTPConnectionClosedException e) {
  }
  TestUtil.assertFileEqual(TESTDATA,ROOT_DIR.listFiles()[0]);
}

Fixed version (ground truth):
public void testExceptionDuringUploadUniqueEnd() throws Exception {
  MockFtplet.callback=new MockFtpletCallback(){
    public FtpletEnum onUploadUniqueEnd(    FtpSession session,    FtpRequest request,    FtpReplyOutput response) throws FtpException, IOException {
      throwException();
      return mockReturnValue;
    }
  }
;
  client.login(ADMIN_USERNAME,ADMIN_PASSWORD);
  assertTrue(client.storeUniqueFile(new ByteArrayInputStream(TESTDATA)));
  try {
    client.noop();
    fail("String_Node_Str");
  }
 catch (  FTPConnectionClosedException e) {
  }
  TestUtil.assertFileEqual(TESTDATA,ROOT_DIR.listFiles()[0]);
}
Program: 152308
Project: 152308
Buggy source:
public void testImplementsInterface(){
  X509KeyManager km=new AliasKeyManager(null,null);
  assertTrue(ClassUtils.implementsInterface(km.getClass(),"String_Node_Str"));
  assertFalse(ClassUtils.implementsInterface(km.getClass(),"String_Node_Str"));
}

Fixed version (ground truth):
public void testImplementsInterface(){
  assertTrue(ClassUtils.extendsClass(MySubBean.class,MyBean.class.getName()));
  assertFalse(ClassUtils.extendsClass(MySubBean.class,"String_Node_Str"));
}
Program: 152317
Project: 152317
Buggy source:
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);
}

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);
  FtpSessionImpl ftpSession=(FtpSessionImpl)connection.getSession();
  ftpSession.updateLastAccessTime();
  protocolHandler.onRequestReceived(connection,ftpSession,output,request);
}
Program: 152318
Project: 152318
Buggy source:
public void encode(IoSession session,Object message,ProtocolEncoderOutput out) throws Exception {
  FtpReply ftpResponse=(FtpReply)message;
  ByteBuffer buf=ByteBuffer.allocate(256);
  buf.putString(ftpResponse.toString(),ENCODER);
  buf.flip();
  out.write(buf);
}

Fixed version (ground truth):
public void encode(IoSession session,Object message,ProtocolEncoderOutput out) throws Exception {
  String value=message.toString();
  ByteBuffer buf=ByteBuffer.allocate(value.length()).setAutoExpand(true);
  buf.putString(value,ENCODER);
  buf.flip();
  out.write(buf);
}