#vulnerable code 
                                public Device getDevice(UUID deviceId, User currentUser, Device currentDevice) {

        Device device = deviceDAO.findByUUIDWithNetworkAndDeviceClass(deviceId);
        device.getDeviceClass();//initializing properties
        device.getNetwork();

        if (device == null || !checkPermissions(device, currentUser, currentDevice)) {
            throw new HiveException("Device Not found", NOT_FOUND.getStatusCode());
        }
        return device;
    } 
                            #location 4 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public Device getDevice(UUID deviceId, User currentUser, Device currentDevice) {

        Device device = deviceDAO.findByUUIDWithNetworkAndDeviceClass(deviceId);

        if (device == null || !checkPermissions(device, currentUser, currentDevice)) {
            throw new HiveException("Device Not found", NOT_FOUND.getStatusCode());
        }

        device.getDeviceClass();//initializing properties
        device.getNetwork();
        return device;
    }