Buggy code:
public class VirtualFolder extends AbstractMessageFolder { protected int nextUid ; protected HeaderList headerList ; public VirtualFolder ( FolderItem item , String path ) { } public VirtualFolder ( String name , String type , String path ) { } protected Object generateNextUid ( ) { } public void setNextUid ( int next ) { } public JDialog showFilterDialog ( AbstractMailFrameController frameController ) { } public boolean exists ( Object uid ) throws Exception { } public IHeaderList getHeaderList ( ) throws Exception { } public void addSearchToHistory ( ) throws Exception { } protected void applySearch ( ) throws Exception { } protected void applySearch ( AbstractMessageFolder parent , Filter filter ) throws Exception { AbstractMessageFolder folder = parent ; Object [ ] resultUids = folder . searchMessages ( filter ) ; <START_BUG> String [ ] headerfields = CachedHeaderfields . getCachedHeaderfields ( ) ; <END_BUG> if ( resultUids != null ) { for ( int i = 0 ; i < ( resultUids . length ) ; i ++ ) { ColumbaHeader header = null ; if ( folder instanceof VirtualFolder ) { VirtualHeader virtualHeader = ( ( VirtualFolder ) ( folder ) ) . getVirtualHeader ( resultUids [ i ] ) ; AbstractMessageFolder sourceFolder = virtualHeader . getSrcFolder ( ) ; Object sourceUid = virtualHeader . getSrcUid ( ) ; Header h = sourceFolder . getHeaderFields ( sourceUid , headerfields ) ; header = new ColumbaHeader ( h ) ; header . setAttributes ( sourceFolder . getAttributes ( sourceUid ) ) ; header . setFlags ( sourceFolder . getFlags ( sourceUid ) ) ; add ( ( ( ColumbaHeader ) ( header ) ) , sourceFolder , sourceUid ) ; } else { Header h = folder . getHeaderFields ( resultUids [ i ] , headerfields ) ; header = new ColumbaHeader ( h ) ; header . setAttributes ( folder . getAttributes ( resultUids [ i ] ) ) ; header . setFlags ( folder . getFlags ( resultUids [ i ] ) ) ; add ( ( ( ColumbaHeader ) ( header ) ) , folder , resultUids [ i ] ) ; } } } boolean isInclude = Boolean . valueOf ( getConfiguration ( ) . get ( "property" , "include_subfolders" ) ) . booleanValue ( ) ; if ( isInclude ) { for ( Enumeration e = parent . children ( ) ; e . hasMoreElements ( ) ; ) { folder = ( ( AbstractMessageFolder ) ( e . nextElement ( ) ) ) ; if ( folder instanceof VirtualFolder ) { continue ; } applySearch ( folder , filter ) ; } } } public DefaultSearchEngine getSearchEngine ( ) { } public Filter getFilter ( ) { } public void add ( ColumbaHeader header , AbstractMessageFolder f , Object uid ) throws Exception { } public void markMessage ( Object [ ] uids , int variant ) throws Exception { } public void removeMessage ( Object uid ) throws Exception { } public MimeTree getMimePartTree ( Object uid ) throws Exception { } public VirtualHeader getVirtualHeader ( Object virtualUid ) { } public Object [ ] searchMessages ( Filter filter , Object [ ] uids ) throws Exception { } public Object [ ] searchMessages ( Filter filter ) throws Exception { } public String getDefaultChild ( ) { } public static XmlElement getDefaultProperties ( ) { } public boolean tryToGetLock ( Object locker ) { } public void releaseLock ( Object locker ) { } public Object [ ] getUids ( ) throws Exception { } 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 getMimePartBodyStream ( Object uid , Integer [ ] address ) throws Exception { } public InputStream getMimePartSourceStream ( Object uid , Integer [ ] address ) throws Exception { } public boolean supportsAddMessage ( ) { } public boolean supportsAddFolder ( IMailFolder newFolder ) { } public void innerCopy ( IMailbox destFolder , Object [ ] uids ) { } public void setAttribute ( Object uid , String key , Object value ) throws Exception { } public Attributes getAttributes ( Object uid ) throws Exception { } public Object addMessage ( InputStream in , Attributes attributes , Flags flags ) throws Exception { } public IHeaderListStorage getHeaderListStorage ( ) { } public boolean supportsMove ( ) { } public Header getAllHeaderFields ( Object uid ) throws Exception { } }

Fix:
String [ ] headerfields = CachedHeaderfields . getDefaultHeaderfields ( ) ;