Buggy code:
private Set scannedDirs = new HashSet ( ) ; private Set includeNonPatterns = new HashSet ( ) ; private Set excludeNonPatterns = new HashSet ( ) ; private String [ ] includePatterns ; private String [ ] excludePatterns ; private boolean areNonPatternSetsReady = false ; private boolean scanning = false ; private Object scanLock = new Object ( ) ; private boolean slowScanning = false ; private Object slowScanLock = new Object ( ) ; private IllegalStateException illegal = null ; public DirectoryScanner ( ) { } protected static boolean matchPatternStart ( String pattern , String str ) { } protected static boolean matchPatternStart ( String pattern , String str , boolean isCaseSensitive ) { } protected static boolean matchPath ( String pattern , String str ) { } protected static boolean matchPath ( String pattern , String str , boolean isCaseSensitive ) { } public static boolean match ( String pattern , String str ) { } protected static boolean match ( String pattern , String str , boolean isCaseSensitive ) { } public static String [ ] getDefaultExcludes ( ) { } public static boolean addDefaultExclude ( String s ) { } public static boolean removeDefaultExclude ( String s ) { } public static void resetDefaultExcludes ( ) { } public void setBasedir ( String basedir ) { } public synchronized void setBasedir ( File basedir ) { } public synchronized File getBasedir ( ) { } public synchronized boolean isCaseSensitive ( ) { } public synchronized void setCaseSensitive ( boolean isCaseSensitive ) { } public synchronized boolean isFollowSymlinks ( ) { } public synchronized void setFollowSymlinks ( boolean followSymlinks ) { } public synchronized void setIncludes ( String [ ] includes ) { } public synchronized void setExcludes ( String [ ] excludes ) { } public synchronized void addExcludes ( String [ ] excludes ) { } private static String normalizePattern ( String p ) { } public synchronized void setSelectors ( FileSelector [ ] selectors ) { } public synchronized boolean isEverythingIncluded ( ) { } public void scan ( ) throws IllegalStateException { } private void checkIncludePatterns ( ) { Hashtable newroots = new Hashtable ( ) ; for ( int icounter = 0 ; icounter < ( includes . length ) ; icounter ++ ) { newroots . put ( SelectorUtils . rtrimWildcardTokens ( includes [ icounter ] ) , includes [ icounter ] ) ; } if ( newroots . containsKey ( "" ) ) { scandir ( basedir , "" , true ) ; } else { Enumeration enum2 = newroots . keys ( ) ; File canonBase = null ; try { canonBase = basedir . getCanonicalFile ( ) ; } catch ( IOException ex ) { throw new BuildException ( ex ) ; } while ( enum2 . hasMoreElements ( ) ) { String currentelement = ( ( String ) ( enum2 . nextElement ( ) ) ) ; String originalpattern = ( ( String ) ( newroots . get ( currentelement ) ) ) ; File myfile = new File ( basedir , currentelement ) ; if ( myfile . exists ( ) ) { try { File canonFile = myfile . getCanonicalFile ( ) ; String path = DirectoryScanner . FILE_UTILS . removeLeadingPath ( canonBase , canonFile ) ; if ( ( ! ( path . equals ( currentelement ) ) ) || ( DirectoryScanner . ON_VMS ) ) { myfile = findFile ( basedir , currentelement , true ) ; if ( myfile != null ) { currentelement = DirectoryScanner . FILE_UTILS . removeLeadingPath ( basedir , myfile ) ; } } } catch ( IOException ex ) { throw new BuildException ( ex ) ; } } if ( ( ( myfile == null ) || ( ! ( myfile . exists ( ) ) ) ) && ( ! ( isCaseSensitive ( ) ) ) ) { File f = findFile ( basedir , currentelement , false ) ; <START_BUG> if ( f . exists ( ) ) { <END_BUG> currentelement = DirectoryScanner . FILE_UTILS . removeLeadingPath ( basedir , f ) ; myfile = f ; } } if ( ( myfile != null ) && ( myfile . exists ( ) ) ) { if ( ( ! ( followSymlinks ) ) && ( isSymlink ( basedir , currentelement ) ) ) { continue ; } if ( myfile . isDirectory ( ) ) { if ( ( isIncluded ( currentelement ) ) && ( ( currentelement . length ( ) ) > 0 ) ) { accountForIncludedDir ( currentelement , myfile , true ) ; } else { if ( ( currentelement . length ( ) ) > 0 ) { if ( ( currentelement . charAt ( ( ( currentelement . length ( ) ) - 1 ) ) ) != ( File . separatorChar ) ) { currentelement = currentelement + ( File . separatorChar ) ; } } scandir ( myfile , currentelement , true ) ; } } else { boolean included = ( isCaseSensitive ( ) ) ? originalpattern . equals ( currentelement ) : originalpattern . equalsIgnoreCase ( currentelement ) ; if ( included ) { accountForIncludedFile ( currentelement , myfile ) ; } } } } } } protected synchronized void clearResults ( ) { } protected void slowScan ( ) { } protected void scandir ( File dir , String vpath , boolean fast ) { } private void accountForIncludedFile ( String name , File file ) { } private void accountForIncludedDir ( String name , File file , boolean fast ) { } protected boolean isIncluded ( String name ) { } protected boolean couldHoldIncluded ( String name ) { } private boolean isDeeper ( String pattern , String name ) { } private boolean isMorePowerfulThanExcludes ( String name , String includepattern ) { } private boolean contentsExcluded ( String name ) { }

Fix:
if ( ( f != null ) && ( f . exists ( ) ) ) {