#vulnerable code 
                                protected void manage(Architecture arch, String version) {
        httpClient = new HttpClient(config());
        try (HttpClient wdmHttpClient = httpClient) {
            downloader = new Downloader(getDriverManagerType());
            urlFilter = new UrlFilter();

            boolean getLatest = isVersionLatest(version);
            boolean cache = config().isForceCache();

            if (getLatest) {
                version = detectDriverVersionFromBrowser();
            }

            // For Chromium snap
            if (getDriverManagerType() == CHROMIUM && isSnap
                    && ((ChromiumDriverManager) this).snapDriverExists()) {
                return;
            }

            getLatest = isNullOrEmpty(version);

            // Check latest version
            if (getLatest && !config().isUseBetaVersions()) {
                Optional<String> lastVersion = getLatestVersion();
                getLatest = !lastVersion.isPresent();
                if (!getLatest) {
                    version = lastVersion.get();
                }
            }

            // For Edge
            if (checkPreInstalledVersion(version)) {
                return;
            }

            String os = config().getOs();
            log.trace("Managing {} arch={} version={} getLatest={} cache={}",
                    getDriverName(), arch, version, getLatest, cache);

            if (getLatest && latestVersion != null) {
                log.debug("Latest version of {} is {} (recently resolved)",
                        getDriverName(), latestVersion);
                version = latestVersion;
                cache = true;
            }

            Optional<String> driverInCache = handleCache(arch, version, os,
                    getLatest, cache);

            String versionStr = getLatest ? "(latest version)" : version;
            if (driverInCache.isPresent() && !config().isOverride()) {
                storeVersionToDownload(version);
                downloadedVersion = version;
                log.debug("Driver {} {} found in cache", getDriverName(),
                        versionStr);
                exportDriver(driverInCache.get());
            } else {
                List<URL> candidateUrls = filterCandidateUrls(arch, version,
                        getLatest);
                if (candidateUrls.isEmpty()) {
                    String errorMessage = getDriverName() + " " + versionStr
                            + " for " + os + arch.toString() + " not found in "
                            + getDriverUrl();
                    log.error(errorMessage);
                    throw new WebDriverManagerException(errorMessage);
                }

                downloadCandidateUrls(candidateUrls);
            }

        } catch (Exception e) {
            handleException(e, arch, version);
        }
    } 
                            #location 47 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                protected void manage(Architecture arch, String version) {
        httpClient = new HttpClient(config());
        try (HttpClient wdmHttpClient = httpClient) {
            downloader = new Downloader(getDriverManagerType());
            urlFilter = new UrlFilter();

            boolean getLatest = isVersionLatest(version);
            boolean cache = config().isForceCache();

            if (getLatest) {
                version = detectDriverVersionFromBrowser();
            }

            // Special case for Chromium snap packages
            if (getDriverManagerType() == CHROMIUM && isSnap
                    && ((ChromiumDriverManager) this).snapDriverExists()) {
                return;
            }

            getLatest = isNullOrEmpty(version);

            // Check latest version
            if (getLatest && !config().isUseBetaVersions()) {
                Optional<String> lastVersion = getLatestVersion();
                getLatest = !lastVersion.isPresent();
                if (!getLatest) {
                    version = lastVersion.get();
                }
            }

            // Special case for Edge
            if (checkPreInstalledVersion(version)) {
                return;
            }

            String os = config().getOs();
            log.trace("Managing {} arch={} version={} getLatest={} cache={}",
                    getDriverName(), arch, version, getLatest, cache);

            if (getLatest && latestVersion != null) {
                log.debug("Latest version of {} is {} (recently resolved)",
                        getDriverName(), latestVersion);
                version = latestVersion;
                cache = true;
            }

            // Manage driver
            downloadAndExport(arch, version, getLatest, cache, os);

        } catch (Exception e) {
            handleException(e, arch, version);
        }
    }