title: Java Apache FTPClient API: Why isn't logout() in finally clause?
body: <p><a href="http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html" rel="nofollow">http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html</a></p>
  
  <p>I noticed the example disconnects() in the finally clause, but doesn't do the same for logout()</p>
  
  <pre><code>FTPClient ftp = new FTPClient();
  FTPClientConfig config = new FTPClientConfig();
  config.setXXX(YYY); // change required options
  ftp.configure(config );
  boolean error = false;
  try {
    int reply;
    ftp.connect("ftp.foobar.com");
    System.out.println("Connected to " + server + ".");
    System.out.print(ftp.getReplyString());
  
    // After connection attempt, you should check the reply code to verify
    // success.
    reply = ftp.getReplyCode();
  
    if(!FTPReply.isPositiveCompletion(reply)) {
      ftp.disconnect();
      System.err.println("FTP server refused connection.");
      System.exit(1);
    }
    ... // transfer files
    ftp.logout();
  } catch(IOException e) {
    error = true;
    e.printStackTrace();
  } finally {
    if(ftp.isConnected()) {
      try {
        ftp.disconnect();
      } catch(IOException ioe) {
        // do nothing
      }
    }
    System.exit(error ? 1 : 0);
  }
  </code></pre>
  
  <p>Anyone know why we don't need to logout() when we catch an exception?</p>