Buggy code:
public class IMAPFolder extends RemoteFolder { private ImapItem item ; private Object aktMessageUid ; private ColumbaMessage aktMessage ; private boolean mailcheck = false ; private IMAPStore store ; protected HeaderList headerList ; protected RemoteHeaderCache cache ; protected boolean existsOnServer ; public IMAPFolder ( FolderItem folderItem ) { } public Object [ ] searchMessages ( Filter filter , Object [ ] uids ) throws Exception { } public Object [ ] searchMessages ( Filter filter ) throws Exception { } public void removeFolder ( ) throws Exception { } public boolean renameFolder ( String name ) throws Exception { } public FolderTreeNode getRootFolder ( ) { } public IMAPStore getStore ( ) { } public HeaderList getHeaderList ( ) throws Exception { } protected void updateFlags ( Flags [ ] flagsList ) { MessageFolderInfo info = getMessageFolderInfo ( ) ; info . setExists ( 0 ) ; info . setRecent ( 0 ) ; info . setUnseen ( 0 ) ; for ( int i = 0 ; i < ( flagsList . length ) ; i ++ ) { IMAPFlags flags = ( ( IMAPFlags ) ( flagsList [ i ] ) ) ; Integer uid = ( ( Integer ) ( flags . getUid ( ) ) ) ; <START_BUG> ColumbaHeader header = ( ( ColumbaHeader ) ( headerList . get ( uid . toString ( ) ) ) ) ; <END_BUG> if ( header == null ) continue ; Flags localFlags = header . getFlags ( ) ; localFlags . setFlags ( flags . getFlags ( ) ) ; if ( ! ( flags . get ( SEEN ) ) ) { info . incUnseen ( ) ; } if ( flags . get ( RECENT ) ) { info . incRecent ( ) ; } info . incExists ( ) ; } } public void save ( ) throws Exception { } public List synchronize ( HeaderList headerList , List newList ) throws Exception { } protected boolean existsRemotely ( String uid , int startIndex , List uidList ) throws Exception { } protected boolean existsLocally ( String uid , HeaderList list ) throws Exception { } public MimeTree getMimePartTree ( Object uid ) throws Exception { } public MimePart getMimePart ( Object uid , Integer [ ] address ) throws Exception { } public void innerCopy ( Folder destFolder , Object [ ] uids ) throws Exception { } public Object addMessage ( ColumbaMessage message ) throws Exception { } public Object addMessage ( String source ) throws Exception { } public boolean exists ( Object uid ) throws Exception { } protected void markMessage ( Object uid , int variant ) throws Exception { } public void markMessage ( Object [ ] uids , int variant ) throws Exception { } public void removeMessage ( Object uid ) throws Exception { } public Object [ ] getUids ( ) throws Exception { } public void expungeFolder ( ) throws Exception { } public String getMessageSource ( Object uid ) throws Exception { } public ColumbaHeader getMessageHeader ( Object uid ) throws Exception { } public ColumbaMessage getMessage ( Object uid ) throws Exception { } public String getImapPath ( ) { } public static XmlElement getDefaultProperties ( ) { } public boolean tryToGetLock ( Object locker ) { } public void releaseLock ( ) { } public IMAPFolder ( String name , String type ) throws Exception { } public void addSubfolder ( FolderTreeNode child ) throws Exception { } public StatusObservable getObservable ( ) { } public Object addMessage ( InputStream in ) throws Exception { } public Object getAttribute ( Object uid , String key ) throws Exception { } public Flags getFlags ( Object uid ) throws Exception { } public Header getHeaderFields ( Object uid , String [ ] keys ) throws Exception { } public InputStream getMessageSourceStream ( Object uid ) throws Exception { } public InputStream getMimePartSourceStream ( Object uid , Integer [ ] address ) throws Exception { } public InputStream getMimePartBodyStream ( Object uid , Integer [ ] address ) throws Exception { } }

Fix:
ColumbaHeader header = ( ( ColumbaHeader ) ( headerList . get ( uid ) ) ) ;