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 int NOOP_INTERVAL = 30000 ; 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 lastNoop ; 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 { } protected String fetchDelimiter ( ) throws IOException , CommandCancelledException , IMAPException { } public ListInfo [ ] list ( String reference , String pattern ) throws Exception { } public Integer append ( InputStream messageSource , IMAPFolder folder ) throws Exception { } public Integer append ( InputStream messageSource , IMAPFlags flags , 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 { try { StatusObservable observable = getObservable ( ) ; ensureSelectedState ( folder ) ; if ( ( ( selectedStatus . getMessages ( ) ) - startIdx ) >= 0 ) { SequenceSet set = new SequenceSet ( ) ; <START_BUG> set . addRightOpen ( startIdx ) ; <END_BUG> SequenceSet [ ] packs = divide ( set ) ; if ( observable != null ) { observable . setCurrent ( 0 ) ; observable . setMax ( set . getLength ( selectedStatus . getMessages ( ) ) ) ; } List allResults = new ArrayList ( packs . length ) ; int pos = 0 ; for ( int i = 0 ; i < ( packs . length ) ; i ++ ) { IMAPFlags [ ] r = protocol . fetchFlags ( packs [ i ] ) ; pos += r . length ; allResults . add ( r ) ; if ( observable != null ) { observable . setCurrent ( pos ) ; } } IMAPFlags [ ] result = new IMAPFlags [ pos ] ; Iterator it = allResults . iterator ( ) ; pos = 0 ; while ( it . hasNext ( ) ) { IMAPFlags [ ] r = ( ( IMAPFlags [ ] ) ( it . next ( ) ) ) ; System . arraycopy ( r , 0 , result , pos , r . length ) ; pos += r . length ; } return result ; } else { return new IMAPFlags [ 0 ] ; } } catch ( IMAPDisconnectedException e ) { return fetchFlagsListStartFrom ( startIdx , folder ) ; } } 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 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 { }

Fix:
set . addOpenRange ( startIdx ) ;