public static synchronized Path downloadContentPackZip(final ContentPackZip contentPackZip,
                                                           final Path destDir,
                                                           final ConflictMode conflictMode,
                                                           final HttpClient httpClient) {
        Preconditions.checkNotNull(contentPackZip);
        Preconditions.checkNotNull(destDir);
        Preconditions.checkNotNull(conflictMode);
        Preconditions.checkArgument(Files.isDirectory(destDir));

        final Path destFilePath = buildDestFilePath(contentPackZip, destDir);
        final Path lockFilePath = buildLockFilePath(contentPackZip, destDir);

        ensureDirectoryExists(destDir);

        FileUtil.doUnderFileLock(lockFilePath, () -> {
            // Now we have the lock for this zip file we can see if we need to download it or not

            boolean destFileExists = Files.isRegularFile(destFilePath);

            if (destFileExists && conflictMode.equals(ConflictMode.KEEP_EXISTING)) {
                LOGGER.debug("Requested contentPack {} already exists in {}, keeping existing",
                        contentPackZip.getName(),
                        FileUtil.getCanonicalPath(destFilePath));
            } else {
                if (destFileExists && conflictMode.equals(ConflictMode.OVERWRITE_EXISTING)) {
                    LOGGER.debug("Requested contentPack {} already exists in {}, overwriting existing",
                            contentPackZip.getName(),
                            FileUtil.getCanonicalPath(destFilePath));
                    try {
                        Files.delete(destFilePath);
                        destFileExists = false;
                    } catch (final IOException e) {
                        throw new UncheckedIOException(String.format("Unable to remove existing content pack %s",
                                FileUtil.getCanonicalPath(destFilePath)), e);
                    }
                }

                if (destFileExists) {
                    LOGGER.info("ContentPack {} already exists {}",
                            contentPackZip.getName(),
                            FileUtil.getCanonicalPath(destFilePath));
                } else {
                    final URL fileUrl = getUrl(contentPackZip);
                    LOGGER.info("Downloading contentPack {} from {} to {}",
                            contentPackZip.getName(),
                            fileUrl,
                            FileUtil.getCanonicalPath(destFilePath));

                    downloadFile(fileUrl, destFilePath, httpClient);
                }
            }
        });

        return destFilePath;
    }
synchronized to avoid multiple test threads downloading the same pack concurrently
Don't have to worry about other JVM as this method is called under lock on a single common file.
stroom-test-common/src/main/java/stroom/test/common/util/test/ContentPackZipDownloader.java