Buggy code:
public class PropertyFileFinder implements State { private ConsoleWrapper theConsole ; private final StateValues stateValues ; public PropertyFileFinder ( ConsoleWrapper theConsole , final StateValues stateValues ) { } @ Override public State execute ( ) { stateValues . setKnownGroups ( new HashMap < String , String > ( ) ) ; if ( ( ( stateValues . getOptions ( ) . getGroupProperties ( ) ) != null ) && ( ( stateValues . getOptions ( ) . getUserProperties ( ) ) == null ) ) { return new ErrorState ( theConsole , DomainManagementMessages . MESSAGES . groupPropertiesButNoUserProperties ( stateValues . getOptions ( ) . getGroupProperties ( ) ) , null , stateValues ) ; } List < File > foundFiles = new ArrayList < File > ( 2 ) ; String fileName = stateValues . getOptions ( ) . getUserProperties ( ) ; fileName = ( fileName == null ) ? ( stateValues . getFileMode ( ) ) == ( FileMode . MANAGEMENT ) ? AddUser . MGMT_USERS_PROPERTIES : AddUser . APPLICATION_USERS_PROPERTIES : fileName ; if ( ! ( findFiles ( foundFiles , fileName ) ) ) { return new ErrorState ( theConsole , DomainManagementMessages . MESSAGES . propertiesFileNotFound ( fileName ) , null , stateValues ) ; } fileName = stateValues . getOptions ( ) . getGroupProperties ( ) ; if ( ( fileName != null ) || ( ( stateValues . getFileMode ( ) ) != ( FileMode . UNDEFINED ) ) ) { boolean groupFileMandatory = true ; List < File > foundGroupFiles = new ArrayList < File > ( 2 ) ; if ( ( fileName == null ) && ( ( stateValues . getFileMode ( ) ) == ( FileMode . APPLICATION ) ) ) { fileName = AddUser . APPLICATION_ROLES_PROPERTIES ; } else if ( fileName == null ) { fileName = AddUser . MGMT_GROUPS_PROPERTIES ; groupFileMandatory = false ; } fileName = ( fileName == null ) ? AddUser . APPLICATION_ROLES_PROPERTIES : fileName ; if ( ( ! ( findFiles ( foundGroupFiles , fileName ) ) ) && groupFileMandatory ) { return new ErrorState ( theConsole , DomainManagementMessages . MESSAGES . propertiesFileNotFound ( fileName ) , null , stateValues ) ; } stateValues . setGroupFiles ( foundGroupFiles ) ; try { stateValues . setKnownGroups ( loadAllGroups ( foundGroupFiles ) ) ; } catch ( Exception e ) { return new ErrorState ( theConsole , DomainManagementMessages . MESSAGES . propertiesFileNotFound ( fileName ) , null , stateValues ) ; } } stateValues . setUserFiles ( foundFiles ) ; String realmName = null ; Set < String > foundUsers = new HashSet < String > ( ) ; for ( File current : stateValues . getUserFiles ( ) ) { UserPropertiesFileLoader pfl = null ; try { pfl = loadUsersFile ( current ) ; <START_BUG> foundUsers . addAll ( pfl . getProperties ( ) . stringPropertyNames ( ) ) ; <END_BUG> if ( realmName == null ) { realmName = pfl . getRealmName ( ) ; } else { String nextRealm = pfl . getRealmName ( ) ; if ( ( realmName . equals ( nextRealm ) ) == false ) { return new ErrorState ( theConsole , DomainManagementMessages . MESSAGES . multipleRealmsDetected ( realmName , nextRealm ) , null , stateValues ) ; } } pfl . stop ( null ) ; pfl = null ; } catch ( IOException e ) { return new ErrorState ( theConsole , DomainManagementMessages . MESSAGES . unableToLoadUsers ( current . getAbsolutePath ( ) , e . getMessage ( ) ) , null , stateValues ) ; } finally { if ( pfl != null ) { pfl . stop ( null ) ; pfl = null ; } } } if ( realmName != null ) { if ( ( ( stateValues . getRealmMode ( ) ) == ( RealmMode . USER_SUPPLIED ) ) && ( ( realmName . equals ( stateValues . getRealm ( ) ) ) == false ) ) { return new ErrorState ( theConsole , DomainManagementMessages . MESSAGES . userRealmNotMatchDiscovered ( stateValues . getRealm ( ) , realmName ) , null , stateValues ) ; } stateValues . setRealm ( realmName ) ; stateValues . setRealmMode ( DISCOVERED ) ; } stateValues . setKnownUsers ( foundUsers ) ; return stateValues . isInteractive ( ) ? new PromptRealmState ( theConsole , stateValues ) : new PromptNewUserState ( theConsole , stateValues ) ; } private UserPropertiesFileLoader loadUsersFile ( File file ) throws IOException { } private Map < String , String > loadAllGroups ( List < File > foundGroupsFiles ) throws IOException , StartException { } private boolean findFiles ( final List < File > foundFiles , final String fileName ) { } private File buildFilePath ( final String serverConfigUserDirPropertyName , final String suppliedConfigDir , final String serverConfigDirPropertyName , final String serverBaseDirPropertyName , final String defaultBaseDir , final String fileName ) { } private File buildDirPath ( final String serverConfigUserDirPropertyName , final String suppliedConfigDir , final String serverConfigDirPropertyName , final String serverBaseDirPropertyName , final String defaultBaseDir ) { } }

Fix:
foundUsers . addAll ( pfl . getUserNames ( ) ) ;