Buggy code:
public class IMAPServer implements Observer , IImapServer , 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 IMailbox selectedFolder ; private MailboxStatus selectedStatus ; private String delimiter ; private IMAPProtocol protocol ; private ImapItem item ; private MimeTree aktMimeTree ; private Object aktMessageUid ; private MailboxInfo messageFolderInfo ; private boolean firstLogin ; boolean usingSSL ; String [ ] capabilities ; private long lastCommunication ; private IStatusObservable observable ; private int MIN_IDLE = 30 * 1000 ; private boolean updatesEnabled = true ; private IFirstLoginAction firstLoginAction ; private IUpdateFlagAction updateFlagAction ; private IExistsChangedAction existsChangedAction ; private boolean statusDirty ; public IMAPServer ( ImapItem item ) { } protected IStatusObservable 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 { } public void setFirstLoginAction ( IFirstLoginAction action ) { } public void ensureSelectedState ( IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public int getLargestRemoteUid ( IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { MailboxStatus status = getStatus ( folder ) ; <START_BUG> if ( ( status . getUidNext ( ) ) < 0 ) { <END_BUG> return fetchUid ( new SequenceSet ( status . getMessages ( ) ) , folder ) ; } else { return ( ( int ) ( ( status . getUidNext ( ) ) - 1 ) ) ; } } public MailboxStatus getStatus ( IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } 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 int fetchUid ( SequenceSet set , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } 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 IMAPFlags [ ] fetchFlagsListStartFrom2 ( int startIdx , IMAPFolder folder ) throws IOException , CommandCancelledException , IMAPException { } public NamespaceCollection fetchNamespaces ( ) throws IOException , CommandCancelledException , IMAPException { } 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 ( ( ( status . getUidNext ( ) ) < 0 ) && ( ( status . getMessages ( ) ) > 0 ) ) {