Buggy code:
public class StartApp { public static final boolean DEBUG = true ; private static final String APP_FOLDER = FileUtils . appDirectory ( "Lernkarten" ) ; private static final String DEFAULT_LOG_PATH = ( StartApp . APP_FOLDER ) + "//logs" ; private static final String DEFAULT_SETTINGS_PATH = ( StartApp . APP_FOLDER ) + "//settings.xml" ; private static final String DEFAULT_DATABASE_PATH = ( StartApp . APP_FOLDER ) + "//database_2" ; private static final String PATH_TO_MEDIA = ( StartApp . APP_FOLDER ) + "//media" ; private static InputStream defaultSettings = StartApp . class . getClassLoader ( ) . getResourceAsStream ( "xml//settings.xml" ) ; private static Settings currentSettings ; private static Settings newSettings ; public static void main ( String [ ] args ) { } private static boolean updatedVersion ( ) throws IOException , NumberFormatException , XMLStreamException { } private static void initializeSettings ( ) throws IOException , NumberFormatException , XMLStreamException { StartApp . newSettings = XMLSettingsExchanger . readConfig ( StartApp . defaultSettings ) ; if ( new File ( StartApp . DEFAULT_SETTINGS_PATH ) . isFile ( ) ) { if ( StartApp . DEBUG ) System . out . println ( "Settings<seq2seq4repair_space>already<seq2seq4repair_space>in<seq2seq4repair_space>user<seq2seq4repair_space>folder" ) ; StartApp . currentSettings = XMLSettingsExchanger . readConfig ( StartApp . DEFAULT_SETTINGS_PATH ) ; if ( ( ( StartApp . currentSettings . getDatabaseVersion ( ) ) == 1 ) && ( ( StartApp . newSettings . getDatabaseVersion ( ) ) == 2 ) ) { if ( ! ( new File ( StartApp . DEFAULT_DATABASE_PATH ) . exists ( ) ) ) { CustomInfoHandling . showOldDatabaseInfo ( ) ; System . exit ( 0 ) ; } else { StartApp . currentSettings . setDatabaseVersion ( 2 ) ; StartApp . currentSettings . setPathToDatabase ( StartApp . DEFAULT_DATABASE_PATH ) ; XMLSettingsExchanger . writeConfig ( StartApp . DEFAULT_SETTINGS_PATH , StartApp . currentSettings ) ; if ( StartApp . DEBUG ) System . out . println ( "Updated<seq2seq4repair_space>database<seq2seq4repair_space>version." ) ; } } <START_BUG> if ( ( StartApp . currentSettings . getPathToDatabase ( ) . equals ( "null" ) ) || ( ! ( new File ( StartApp . currentSettings . getPathToDatabase ( ) ) . isDirectory ( ) ) ) ) { <END_BUG> if ( StartApp . DEBUG ) System . out . println ( "Database<seq2seq4repair_space>not<seq2seq4repair_space>where<seq2seq4repair_space>it<seq2seq4repair_space>was<seq2seq4repair_space>expected<seq2seq4repair_space>or<seq2seq4repair_space>not<seq2seq4repair_space>there" ) ; StartApp . currentSettings . setPathToDatabase ( StartApp . DEFAULT_DATABASE_PATH ) ; XMLSettingsExchanger . writeConfig ( StartApp . DEFAULT_SETTINGS_PATH , StartApp . currentSettings ) ; } if ( StartApp . updatedVersion ( ) ) { if ( StartApp . DEBUG ) System . out . println ( "was<seq2seq4repair_space>updated" ) ; XMLSettingsExchanger . writeConfig ( StartApp . DEFAULT_SETTINGS_PATH , StartApp . currentSettings ) ; } } else { if ( StartApp . DEBUG ) System . out . println ( "XML<seq2seq4repair_space>Config<seq2seq4repair_space>not<seq2seq4repair_space>in<seq2seq4repair_space>user<seq2seq4repair_space>folder<seq2seq4repair_space>-><seq2seq4repair_space>copy<seq2seq4repair_space>into<seq2seq4repair_space>user<seq2seq4repair_space>folder" ) ; StartApp . currentSettings = StartApp . newSettings ; StartApp . currentSettings . setPathToDatabase ( StartApp . DEFAULT_DATABASE_PATH ) ; XMLSettingsExchanger . writeConfig ( StartApp . DEFAULT_SETTINGS_PATH , StartApp . currentSettings ) ; } } }

Fix:
if ( ( ! ( StartApp . currentSettings . getPathToDatabase ( ) . endsWith ( "2" ) ) ) || ( ! ( new File ( StartApp . currentSettings . getPathToDatabase ( ) ) . isDirectory ( ) ) ) ) {