Buggy code:
public class IMAPServer implements IMAPListener { private static final int STEP_SIZE = 50 ; private static final int UID_FETCH_STEPS = 500 ; private static final Logger LOG = Logger . getLogger ( "org.columba.mail.imap" ) ; private static final Charset UTF8 = Charset . forName ( "UTF-8" ) ; private static final Charset DEFAULT = Charset . forName ( System . getProperty ( "file.encoding" ) ) ; private IMAPFolder selectedFolder ; private MailboxStatus selectedStatus ; private String delimiter ; private IMAPProtocol protocol ; private ImapItem item ; private IMAPRootFolder imapRoot ; private MimeTree aktMimeTree ; private Object aktMessageUid ; private MailboxInfo messageFolderInfo ; private boolean firstLogin ; boolean usingSSL ; String [ ] capabilities ; private long lastCommunication ; private int MIN_IDLE = ( 1000 * 60 ) * 1 ; private boolean updatesEnabled ; public IMAPServer ( ImapItem item , IMAPRootFolder root ) { } protected StatusObservable getObservable ( ) { } protected void printStatusMessage ( String message ) { } public String getDelimiter ( ) throws IOException , CommandCancelledException , IMAPException { } public void logout ( ) throws Exception { } private void openConnection ( ) throws IOException , CommandCancelledException , IMAPException { } public List checkSupportedAuthenticationMethods ( ) throws IOException { } private String [ ] getCapas ( String command ) throws IOException { } public boolean isSupported ( String command ) throws IOException { } private void fetchCapas ( ) throws IOException { } private int getLoginMethod ( ) throws IOException , CommandCancelledException { } private void login ( ) throws IOException , CommandCancelledException , IMAPException { } protected void ensureSelectedState ( IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public MailboxStatus getStatus ( IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { ensureLoginState ( ) ; if ( ( ( selectedFolder ) != null ) && ( selectedFolder . equals ( folder ) ) ) { try { protocol . noop ( ) ; return selectedStatus ; } catch ( IMAPDisconnectedException e1 ) { } catch ( ConnectionDroppedException e1 ) { } } <START_BUG> if ( ( selectedFolder ) == null ) { <END_BUG> ensureSelectedState ( folder ) ; return selectedStatus ; } printStatusMessage ( MessageFormat . format ( MailResourceLoader . getString ( "statusbar" , "message" , "status" ) , new Object [ ] { folder . getName ( ) } ) ) ; return protocol . status ( folder . getImapPath ( ) , new String [ ] { "MESSAGES" , "UIDNEXT" , "RECENT" , "UNSEEN" , "UIDVALIDITY" } ) ; } protected String fetchDelimiter ( ) throws IOException , CommandCancelledException , IMAPException { } public ListInfo [ ] list ( String reference , String pattern ) throws Exception { } public Integer append ( InputStream messageSource , IMAPFlags flags , IMAPFolder folder ) throws Exception { } public Integer append ( InputStream messageSource , IMAPFolder folder ) throws Exception { } public void createMailbox ( String mailboxName , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public void deleteFolder ( String path ) throws Exception { } public void renameFolder ( String oldMailboxName , String newMailboxName ) throws IOException , CommandCancelledException , IMAPException { } public void subscribeFolder ( String mailboxName ) throws IOException , CommandCancelledException , IMAPException { } public void unsubscribeFolder ( String mailboxName ) throws IOException , CommandCancelledException , IMAPException { } public void expunge ( IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public Integer [ ] copy ( IMAPFolder destFolder , Object [ ] uids , IMAPFolder folder ) throws Exception { } public Integer [ ] fetchUids ( SequenceSet set , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } private SequenceSet [ ] divide ( SequenceSet in ) { } public IMAPFlags [ ] fetchFlagsListStartFrom ( int startIdx , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public NamespaceCollection fetchNamespaces ( ) throws IOException , CommandCancelledException , IMAPException { } private ColumbaHeader parseMessage ( String headerString ) { } public void fetchHeaderList ( IHeaderList headerList , List list , IMAPFolder folder ) throws Exception { } private void doFetchHeaderList ( IHeaderList headerList , List list ) throws IOException , IMAPException { } protected Integer getAccountUid ( ) { } protected synchronized void ensureConnectedState ( ) throws IOException , CommandCancelledException , IMAPException { } protected void ensureLoginState ( ) throws IOException , CommandCancelledException , IMAPException { } public MimeTree getMimeTree ( Object uid , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public InputStream getMimePartBodyStream ( Object uid , Integer [ ] address , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public Header getHeaders ( Object uid , String [ ] keys , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public Header getAllHeaders ( Object uid , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public InputStream getMimePartSourceStream ( Object uid , Integer [ ] address , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public InputStream getMessageSourceStream ( Object uid , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public void markMessage ( Object [ ] uids , int variant , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public void setFlags ( Object [ ] uids , IMAPFlags flags , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public List search ( Object [ ] uids , FilterRule filterRule , IMAPFolder folder ) throws Exception { } public int getIndex ( Integer uid , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public Integer [ ] search ( SearchKey key , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public List search ( FilterRule filterRule , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } private SearchKey [ ] createSearchKey ( FilterRule filterRule ) { } private SearchKey getSearchKey ( FilterCriteria criteria ) { }

Fix:
if ( ( ( selectedFolder ) == null ) || ( ( protocol . getState ( ) ) < ( IMAPProtocol . SELECTED ) ) ) {