#fixed code
                                public static void main(String[] args) {
        Logger log = LoggerFactory.getLogger(HABridge.class);
        DeviceResource theResources;
        HomeManager homeManager;
        HueMulator theHueMulator;
        UDPDatagramSender udpSender;
        UpnpSettingsResource theSettingResponder;
        UpnpListener theUpnpListener;
        SystemControl theSystem;
        BridgeSettings bridgeSettings;
        Version theVersion;
        
        theVersion = new Version();

        log.info("HA Bridge (v" + theVersion.getVersion() + ") starting....");
        
        bridgeSettings = new BridgeSettings();
    	// sparkjava config directive to set html static file location for Jetty
    	staticFileLocation("/public");
        while(!bridgeSettings.getBridgeControl().isStop()) {
        	bridgeSettings.buildSettings();
            bridgeSettings.getBridgeSecurity().removeTestUsers();
            log.info("HA Bridge initializing....");
	        // sparkjava config directive to set ip address for the web server to listen on
	        ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
	        // sparkjava config directive to set port for the web server to listen on
	        port(bridgeSettings.getBridgeSettingsDescriptor().getServerPort());
	        if(!bridgeSettings.getBridgeControl().isReinit())
	        	init();
	        bridgeSettings.getBridgeControl().setReinit(false);
	        // setup system control api first
	        theSystem = new SystemControl(bridgeSettings, theVersion);
	        theSystem.setupServer();
	        // setup the UDP Datagram socket to be used by the HueMulator and the upnpListener
	        udpSender = UDPDatagramSender.createUDPDatagramSender(bridgeSettings.getBridgeSettingsDescriptor().getUpnpResponsePort());
	        if(udpSender == null) {
	        	bridgeSettings.getBridgeControl().setStop(true);	        	
	        }
	        else {
		        //Setup the device connection homes through the manager
		        homeManager = new HomeManager();
		        homeManager.buildHomes(bridgeSettings, udpSender);
		        // setup the class to handle the resource setup rest api
		        theResources = new DeviceResource(bridgeSettings, homeManager);
		        // setup the class to handle the upnp response rest api
		        theSettingResponder = new UpnpSettingsResource(bridgeSettings.getBridgeSettingsDescriptor());
		        theSettingResponder.setupServer();
		        // setup the class to handle the hue emulator rest api
		        theHueMulator = new HueMulator(bridgeSettings, theResources.getDeviceRepository(), homeManager);
		        theHueMulator.setupServer();
		        // wait for the sparkjava initialization of the rest api classes to be complete
		        awaitInitialization();
		
		        // start the upnp ssdp discovery listener
		        theUpnpListener = new UpnpListener(bridgeSettings.getBridgeSettingsDescriptor(), bridgeSettings.getBridgeControl(), udpSender);
		        if(theUpnpListener.startListening())
		        	log.info("HA Bridge (v" + theVersion.getVersion() + ") reinitialization requessted....");
		        else
		        	bridgeSettings.getBridgeControl().setStop(true);
		        if(bridgeSettings.getBridgeSettingsDescriptor().isSettingsChanged())
		        	bridgeSettings.save(bridgeSettings.getBridgeSettingsDescriptor());
		        homeManager.closeHomes();
		        udpSender.closeResponseSocket();
		        udpSender = null;
	        }
	        stop();
	        if(!bridgeSettings.getBridgeControl().isStop()) {
	        	try {
					Thread.sleep(5000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	        }
        }
        bridgeSettings.getBridgeSecurity().removeTestUsers();
        if(bridgeSettings.getBridgeSecurity().isSettingsChanged())
        	bridgeSettings.updateConfigFile();
        log.info("HA Bridge (v" + theVersion.getVersion() + ") exiting....");
        System.exit(0);
    }
#vulnerable code 
                                public static void main(String[] args) {
        Logger log = LoggerFactory.getLogger(HABridge.class);
        DeviceResource theResources;
        HomeManager homeManager;
        HueMulator theHueMulator;
        UDPDatagramSender udpSender;
        UpnpSettingsResource theSettingResponder;
        UpnpListener theUpnpListener;
        SystemControl theSystem;
        BridgeSettings bridgeSettings;
        Version theVersion;
        
        theVersion = new Version();

        log.info("HA Bridge (v" + theVersion.getVersion() + ") starting....");
        
        bridgeSettings = new BridgeSettings();
    	// sparkjava config directive to set html static file location for Jetty
    	staticFileLocation("/public");
        while(!bridgeSettings.getBridgeControl().isStop()) {
        	bridgeSettings.buildSettings();
            log.info("HA Bridge initializing....");
	        // sparkjava config directive to set ip address for the web server to listen on
	        ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
	        // sparkjava config directive to set port for the web server to listen on
	        port(bridgeSettings.getBridgeSettingsDescriptor().getServerPort());
	        if(!bridgeSettings.getBridgeControl().isReinit())
	        	init();
	        bridgeSettings.getBridgeControl().setReinit(false);
	        // setup system control api first
	        theSystem = new SystemControl(bridgeSettings, theVersion);
	        theSystem.setupServer();
	        // setup the UDP Datagram socket to be used by the HueMulator and the upnpListener
	        udpSender = UDPDatagramSender.createUDPDatagramSender(bridgeSettings.getBridgeSettingsDescriptor().getUpnpResponsePort());
	        if(udpSender == null) {
	        	bridgeSettings.getBridgeControl().setStop(true);	        	
	        }
	        else {
		        //Setup the device connection homes through the manager
		        homeManager = new HomeManager();
		        homeManager.buildHomes(bridgeSettings, udpSender);
		        // setup the class to handle the resource setup rest api
		        theResources = new DeviceResource(bridgeSettings, homeManager);
		        // setup the class to handle the upnp response rest api
		        theSettingResponder = new UpnpSettingsResource(bridgeSettings.getBridgeSettingsDescriptor());
		        theSettingResponder.setupServer();
		        // setup the class to handle the hue emulator rest api
		        theHueMulator = new HueMulator(bridgeSettings, theResources.getDeviceRepository(), homeManager);
		        theHueMulator.setupServer();
		        // wait for the sparkjava initialization of the rest api classes to be complete
		        awaitInitialization();
		
		        // start the upnp ssdp discovery listener
		        theUpnpListener = new UpnpListener(bridgeSettings.getBridgeSettingsDescriptor(), bridgeSettings.getBridgeControl(), udpSender);
		        if(theUpnpListener.startListening())
		        	log.info("HA Bridge (v" + theVersion.getVersion() + ") reinitialization requessted....");
		        else
		        	bridgeSettings.getBridgeControl().setStop(true);
		        if(bridgeSettings.getBridgeSettingsDescriptor().isSettingsChanged())
		        	bridgeSettings.save(bridgeSettings.getBridgeSettingsDescriptor());
		        homeManager.closeHomes();
		        udpSender.closeResponseSocket();
		        udpSender = null;
	        }
	        stop();
	        if(!bridgeSettings.getBridgeControl().isStop()) {
	        	try {
					Thread.sleep(5000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	        }
        }
        bridgeSettings.getBridgeSecurity().removeTestUsers();
        if(bridgeSettings.getBridgeSecurity().isSettingsChanged())
        	bridgeSettings.updateConfigFile();
        log.info("HA Bridge (v" + theVersion.getVersion() + ") exiting....");
        System.exit(0);
    } 
                            #location 26 
                            #vulnerability type NULL_DEREFERENCE