789770
diff --git a/Makefile.am b/Makefile.am
789770
index 3f73cff7..1112bf49 100644
789770
--- a/Makefile.am
789770
+++ b/Makefile.am
789770
@@ -956,10 +956,10 @@ if ENABLE_NATIVE_LAUNCHERS
789770
 # there is curently harecoded sh, so it can somehow basically work
789770
 # see the DESKTOP_SUFFIX for final tuning
789770
 launcher.build/$(javaws) launcher.build/$(itweb_settings) launcher.build/$(policyeditor): rust-launcher/src/main.rs rust-launcher/Cargo.toml
789770
-	export ITW_TMP_REPLACEMENT=$(TESTS_DIR)/rust_tests_tmp ; \
789770
-	mkdir -p $$ITW_TMP_REPLACEMENT; \
789770
 	filename=`basename $@` ; \
789770
 	type=$${filename%.*} ; \
789770
+	export ITW_TMP_REPLACEMENT=$(TESTS_DIR)/rust_tests_tmp/$$type ; \
789770
+	mkdir -p $$ITW_TMP_REPLACEMENT; \
789770
 	srcs=$(TOP_SRC_DIR)/rust-launcher ; \
789770
 	outs=$(TOP_BUILD_DIR)/launcher.in.$$type  ; \
789770
 	mkdir -p launcher.build  ; \
789770
diff --git a/configure.ac b/configure.ac
789770
index 5bcb1046..03796e39 100644
789770
--- a/configure.ac
789770
+++ b/configure.ac
789770
@@ -71,7 +71,7 @@ AM_CONDITIONAL([ENABLE_NATIVE_LAUNCHERS], [test ! x"$RUSTC" = x -a ! x"$CARGO" =
789770
 build_linux=no
789770
 build_windows=no
789770
 case "${host_os}" in
789770
-    linux*)
789770
+    linux*|freebsd*)
789770
         build_linux=yes
789770
         ;;
789770
     cygwin*)
789770
diff --git a/netx/net/sourceforge/jnlp/Launcher.java b/netx/net/sourceforge/jnlp/Launcher.java
789770
index bcfd7b34..1ff42421 100644
789770
--- a/netx/net/sourceforge/jnlp/Launcher.java
789770
+++ b/netx/net/sourceforge/jnlp/Launcher.java
789770
@@ -552,7 +552,7 @@ public class Launcher {
789770
             }
789770
 
789770
             OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Starting application [" + mainName + "] ...");
789770
-            
789770
+
789770
             Class mainClass = app.getClassLoader().loadClass(mainName);
789770
 
789770
             Method main = mainClass.getMethod("main", new Class[] { String[].class });
789770
@@ -572,6 +572,7 @@ public class Launcher {
789770
 
789770
             main.setAccessible(true);
789770
 
789770
+            JNLPRuntime.addStartupTrackingEntry("invoking main()");
789770
             OutputController.getLogger().log("Invoking main() with args: " + Arrays.toString(args));
789770
             main.invoke(null, new Object[] { args });
789770
 
789770
diff --git a/netx/net/sourceforge/jnlp/OptionsDefinitions.java b/netx/net/sourceforge/jnlp/OptionsDefinitions.java
789770
index c87b4a79..16ef46d3 100644
789770
--- a/netx/net/sourceforge/jnlp/OptionsDefinitions.java
789770
+++ b/netx/net/sourceforge/jnlp/OptionsDefinitions.java
789770
@@ -78,6 +78,7 @@ public class OptionsDefinitions {
789770
         JNLP("-jnlp","BOJnlp", NumberOfArguments.ONE),
789770
         HTML("-html","BOHtml", NumberOfArguments.ONE_OR_MORE),
789770
         BROWSER("-browser", "BrowserArg", NumberOfArguments.ONE_OR_MORE),
789770
+        STARTUP_TRACKER("-startuptracker","BOStartupTracker"),
789770
         //itweb settings
789770
         LIST("-list", "IBOList"),
789770
         GET("-get", "name", "IBOGet", NumberOfArguments.ONE_OR_MORE),
789770
@@ -222,7 +223,8 @@ public class OptionsDefinitions {
789770
             OPTIONS.TRUSTNONE,
789770
             OPTIONS.JNLP,
789770
             OPTIONS.HTML,
789770
-            OPTIONS.BROWSER
789770
+            OPTIONS.BROWSER,
789770
+            OPTIONS.STARTUP_TRACKER
789770
         });
789770
     }
789770
 
789770
diff --git a/netx/net/sourceforge/jnlp/cache/CacheEntry.java b/netx/net/sourceforge/jnlp/cache/CacheEntry.java
789770
index 3a241acb..c5f1f329 100644
789770
--- a/netx/net/sourceforge/jnlp/cache/CacheEntry.java
789770
+++ b/netx/net/sourceforge/jnlp/cache/CacheEntry.java
789770
@@ -47,6 +47,8 @@ public class CacheEntry {
789770
     /** info about the cached file */
789770
     private final PropertiesFile properties;
789770
 
789770
+    private File localFile;
789770
+
789770
     /**
789770
      * Create a CacheEntry for the resources specified as a remote
789770
      * URL.
789770
@@ -58,8 +60,8 @@ public class CacheEntry {
789770
         this.location = location;
789770
         this.version = version;
789770
         
789770
-        File infoFile = CacheUtil.getCacheFile(location, version);
789770
-        infoFile = new File(infoFile.getPath() + CacheDirectory.INFO_SUFFIX); // replace with something that can't be clobbered
789770
+        this.localFile = CacheUtil.getCacheFile(location, version);
789770
+        File infoFile = new File(localFile.getPath() + CacheDirectory.INFO_SUFFIX); // replace with something that can't be clobbered
789770
 
789770
         properties = new PropertiesFile(infoFile, R("CAutoGen"));
789770
     }
789770
@@ -130,7 +132,11 @@ public class CacheEntry {
789770
      * @return whether the cache contains the version
789770
      */
789770
     public boolean isCurrent(long lastModified) {
789770
-        boolean cached = isCached();
789770
+        return isCurrent(lastModified, null);
789770
+    }
789770
+
789770
+    public boolean isCurrent(long lastModified, File cachedFile) {
789770
+        boolean cached = isCached(cachedFile);
789770
         OutputController.getLogger().log("isCurrent:isCached " + cached);
789770
 
789770
         if (!cached) {
789770
@@ -153,7 +159,16 @@ public class CacheEntry {
789770
      * @return true if the resource is in the cache
789770
      */
789770
     public boolean isCached() {
789770
-        File localFile = getCacheFile();
789770
+        return isCached(null);
789770
+    }
789770
+
789770
+    public boolean isCached(File cachedFile) {
789770
+        final File localFile;
789770
+        if (null == version && null != cachedFile) {
789770
+            localFile = cachedFile;
789770
+        } else {
789770
+            localFile = getCacheFile();
789770
+        }
789770
         if (!localFile.exists())
789770
             return false;
789770
 
789770
@@ -224,4 +239,7 @@ public class CacheEntry {
789770
         return properties.isHeldByCurrentThread();
789770
     }
789770
 
789770
+    public File getLocalFile() {
789770
+        return localFile;
789770
+    }
789770
 }
789770
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
789770
index 486421b9..d298d203 100644
789770
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java
789770
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
789770
@@ -422,14 +422,13 @@ public class CacheUtil {
789770
      * @return whether the cache contains the version
789770
      * @throws IllegalArgumentException if the source is not cacheable
789770
      */
789770
-    public static boolean isCurrent(URL source, Version version, long lastModifed) {
789770
+    public static boolean isCurrent(URL source, Version version, long lastModifed, CacheEntry entry, File cachedFile) {
789770
 
789770
         if (!isCacheable(source, version))
789770
             throw new IllegalArgumentException(R("CNotCacheable", source));
789770
 
789770
         try {
789770
-            CacheEntry entry = new CacheEntry(source, version); // could pool this
789770
-            boolean result = entry.isCurrent(lastModifed);
789770
+            boolean result = entry.isCurrent(lastModifed, cachedFile);
789770
 
789770
             OutputController.getLogger().log("isCurrent: " + source + " = " + result);
789770
 
789770
@@ -796,6 +795,8 @@ public class CacheUtil {
789770
             }
789770
             URL undownloaded[] = urlList.toArray(new URL[urlList.size()]);
789770
 
789770
+            final int maxUrls = Integer.parseInt(JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_MAX_URLS_DOWNLOAD_INDICATOR));
789770
+
789770
             listener = indicator.getListener(app, title, undownloaded);
789770
 
789770
             do {
789770
@@ -810,20 +811,30 @@ public class CacheUtil {
789770
 
789770
                 int percent = (int) ((100 * read) / Math.max(1, total));
789770
 
789770
+                int urlCounter = 0;
789770
                 for (URL url : undownloaded) {
789770
+                    if (urlCounter > maxUrls) {
789770
+                        break;
789770
+                    }
789770
                     listener.progress(url, "version",
789770
                                       tracker.getAmountRead(url),
789770
                                       tracker.getTotalSize(url),
789770
                                       percent);
789770
+                    urlCounter += 1;
789770
                 }
789770
             } while (!tracker.waitForResources(resources, indicator.getUpdateRate()));
789770
 
789770
             // make sure they read 100% until indicator closes
789770
+            int urlCounter = 0;
789770
             for (URL url : undownloaded) {
789770
+                if (urlCounter > maxUrls) {
789770
+                    break;
789770
+                }
789770
                 listener.progress(url, "version",
789770
                                   tracker.getTotalSize(url),
789770
                                   tracker.getTotalSize(url),
789770
                                   100);
789770
+                urlCounter += 1;
789770
             }
789770
         } catch (InterruptedException ex) {
789770
             OutputController.getLogger().log(ex);
789770
diff --git a/netx/net/sourceforge/jnlp/cache/CachedDaemonThreadPoolProvider.java b/netx/net/sourceforge/jnlp/cache/CachedDaemonThreadPoolProvider.java
789770
index 1cd4df23..ff48662d 100644
789770
--- a/netx/net/sourceforge/jnlp/cache/CachedDaemonThreadPoolProvider.java
789770
+++ b/netx/net/sourceforge/jnlp/cache/CachedDaemonThreadPoolProvider.java
789770
@@ -36,9 +36,14 @@
789770
  exception statement from your version. */
789770
 package net.sourceforge.jnlp.cache;
789770
 
789770
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
789770
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
789770
+
789770
 import java.util.concurrent.ExecutorService;
789770
-import java.util.concurrent.Executors;
789770
+import java.util.concurrent.LinkedBlockingQueue;
789770
 import java.util.concurrent.ThreadFactory;
789770
+import java.util.concurrent.ThreadPoolExecutor;
789770
+import java.util.concurrent.TimeUnit;
789770
 import java.util.concurrent.atomic.AtomicInteger;
789770
 
789770
 public class CachedDaemonThreadPoolProvider {
789770
@@ -81,6 +86,19 @@ public class CachedDaemonThreadPoolProvider {
789770
         }
789770
     }
789770
 
789770
-    public static final ExecutorService DAEMON_THREAD_POOL = Executors.newCachedThreadPool(new DaemonThreadFactory());
789770
+    public static synchronized ExecutorService getThreadPool() {
789770
+        if (null == DAEMON_THREAD_POOL) {
789770
+            final int nThreads = Integer.parseInt(JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_BACKGROUND_THREADS_COUNT));
789770
+            ThreadPoolExecutor pool = new ThreadPoolExecutor(nThreads, nThreads,
789770
+                    60L, TimeUnit.SECONDS,
789770
+                    new LinkedBlockingQueue<Runnable>(),
789770
+                    new DaemonThreadFactory());
789770
+            pool.allowCoreThreadTimeOut(true);
789770
+            DAEMON_THREAD_POOL = pool;
789770
+        }
789770
+        return DAEMON_THREAD_POOL;
789770
+    }
789770
+
789770
+    private static ExecutorService DAEMON_THREAD_POOL = null;
789770
 
789770
 }
789770
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java b/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java
789770
index 643b46fd..e0a123bb 100644
789770
--- a/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java
789770
+++ b/netx/net/sourceforge/jnlp/cache/ResourceDownloader.java
789770
@@ -153,7 +153,12 @@ public class ResourceDownloader implements Runnable {
789770
             URLConnection connection = ConnectionFactory.getConnectionFactory().openConnection(location.URL); // this won't change so should be okay not-synchronized
789770
             connection.addRequestProperty("Accept-Encoding", "pack200-gzip, gzip");
789770
 
789770
-            File localFile = CacheUtil.getCacheFile(resource.getLocation(), resource.getDownloadVersion());
789770
+            File localFile = null;
789770
+            if (resource.getRequestVersion() == resource.getDownloadVersion()) {
789770
+                localFile = entry.getLocalFile();
789770
+            } else {
789770
+                localFile = CacheUtil.getCacheFile(resource.getLocation(), resource.getDownloadVersion());
789770
+            }
789770
             Long size = location.length;
789770
             if (size == null) {
789770
                 size = connection.getContentLengthLong();
789770
@@ -162,7 +167,7 @@ public class ResourceDownloader implements Runnable {
789770
             if (lm == null) {
789770
                 lm = connection.getLastModified();
789770
             }
789770
-            boolean current = CacheUtil.isCurrent(resource.getLocation(), resource.getRequestVersion(), lm) && resource.getUpdatePolicy() != UpdatePolicy.FORCE;
789770
+            boolean current = CacheUtil.isCurrent(resource.getLocation(), resource.getRequestVersion(), lm, entry, localFile) && resource.getUpdatePolicy() != UpdatePolicy.FORCE;
789770
             if (!current) {
789770
                 if (entry.isCached()) {
789770
                     entry.markForDelete();
789770
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
789770
index f4ad69be..972a10cf 100644
789770
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
789770
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
789770
@@ -28,10 +28,7 @@ import static net.sourceforge.jnlp.cache.Resource.Status.PROCESSING;
789770
 import java.io.File;
789770
 import java.net.MalformedURLException;
789770
 import java.net.URL;
789770
-import java.util.ArrayList;
789770
-import java.util.Collection;
789770
-import java.util.EnumSet;
789770
-import java.util.List;
789770
+import java.util.*;
789770
 
789770
 import net.sourceforge.jnlp.DownloadOptions;
789770
 import net.sourceforge.jnlp.Version;
789770
@@ -105,6 +102,7 @@ public class ResourceTracker {
789770
 
789770
     /** the resources known about by this resource tracker */
789770
     private final List<Resource> resources = new ArrayList<>();
789770
+    private final HashMap<String, Resource> resourcesMap = new HashMap<>();
789770
 
789770
     /** download listeners for this tracker */
789770
     private final List<DownloadListener> listeners = new ArrayList<>();
789770
@@ -155,6 +153,7 @@ public class ResourceTracker {
789770
                 return;
789770
             resource.addTracker(this);
789770
             resources.add(resource);
789770
+            resourcesMap.put(location.toString(), resource);
789770
         }
789770
 
789770
         if (options == null) {
789770
@@ -190,6 +189,7 @@ public class ResourceTracker {
789770
 
789770
             if (resource != null) {
789770
                 resources.remove(resource);
789770
+                resourcesMap.remove(location.toString());
789770
                 resource.removeTracker(this);
789770
             }
789770
 
789770
@@ -508,7 +508,7 @@ public class ResourceTracker {
789770
      * @param resource  resource to be download
789770
      */
789770
     protected void startDownloadThread(Resource resource) {
789770
-        CachedDaemonThreadPoolProvider.DAEMON_THREAD_POOL.execute(new ResourceDownloader(resource, lock));
789770
+        CachedDaemonThreadPoolProvider.getThreadPool().execute(new ResourceDownloader(resource, lock));
789770
     }
789770
 
789770
     static Resource selectByFilter(Collection<Resource> source, Filter<Resource> filter) {
789770
@@ -569,6 +569,12 @@ public class ResourceTracker {
789770
      */
789770
     private Resource getResource(URL location) {
789770
         synchronized (resources) {
789770
+            if (null != location) {
789770
+                Resource res = resourcesMap.get(location.toString());
789770
+                if (null != res && UrlUtils.urlEquals(res.getLocation(), location)) {
789770
+                    return res;
789770
+                }
789770
+            }
789770
             for (Resource resource : resources) {
789770
                 if (UrlUtils.urlEquals(resource.getLocation(), location))
789770
                     return resource;
789770
diff --git a/netx/net/sourceforge/jnlp/config/Defaults.java b/netx/net/sourceforge/jnlp/config/Defaults.java
789770
index 8e316e4f..78f9b3e6 100644
789770
--- a/netx/net/sourceforge/jnlp/config/Defaults.java
789770
+++ b/netx/net/sourceforge/jnlp/config/Defaults.java
789770
@@ -466,6 +466,21 @@ public class Defaults {
789770
                         BasicValueValidators.getRangedIntegerValidator(0, 1000),
789770
                         String.valueOf(10)// treshold when applet is considered as too small
789770
                 },
789770
+                {
789770
+                        DeploymentConfiguration.KEY_ENABLE_CACHE_FSYNC,
789770
+                        BasicValueValidators.getBooleanValidator(),
789770
+                        String.valueOf(false)
789770
+                },
789770
+                {
789770
+                        DeploymentConfiguration.KEY_BACKGROUND_THREADS_COUNT,
789770
+                        BasicValueValidators.getRangedIntegerValidator(1, 16),
789770
+                        String.valueOf(3)
789770
+                },
789770
+                {
789770
+                        DeploymentConfiguration.KEY_MAX_URLS_DOWNLOAD_INDICATOR,
789770
+                        BasicValueValidators.getRangedIntegerValidator(1, 1024),
789770
+                        String.valueOf(16)
789770
+                },
789770
                 //**************
789770
                 //* Native (rust) only - beggin
789770
                 //**************
789770
diff --git a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
789770
index de7425e3..84f77075 100644
789770
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
789770
+++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
789770
@@ -250,7 +250,10 @@ public final class DeploymentConfiguration {
789770
     public static final String KEY_SMALL_SIZE_OVERRIDE_TRESHOLD = "deployment.small.size.treshold";
789770
     public static final String KEY_SMALL_SIZE_OVERRIDE_WIDTH = "deployment.small.size.override.width";
789770
     public static final String KEY_SMALL_SIZE_OVERRIDE_HEIGHT = "deployment.small.size.override.height";
789770
-    
789770
+    public static final String KEY_ENABLE_CACHE_FSYNC = "deployment.enable.cache.fsync";
789770
+    public static final String KEY_BACKGROUND_THREADS_COUNT = "deployment.background.threads.count";
789770
+    public static final String KEY_MAX_URLS_DOWNLOAD_INDICATOR = "deployment.max.urls.download.indicator";
789770
+
789770
     public static final String TRANSFER_TITLE = "Legacy configuration and cache found. Those will be now transported to new locations";
789770
     
789770
     private ConfigurationException loadingException = null;
789770
diff --git a/netx/net/sourceforge/jnlp/resources/Messages.properties b/netx/net/sourceforge/jnlp/resources/Messages.properties
789770
index 773f134b..0e87bce3 100644
789770
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties
789770
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties
789770
@@ -357,6 +357,7 @@ BXoffline   = Prevent ITW network connection. Only cache will be used. Applicati
789770
 BOHelp1     = Prints out information about supported command and basic usage.
789770
 BOHelp2     = Prints out information about supported command and basic usage. Can also take an parameter, and then it prints detailed help for this command.
789770
 BOTrustnone = Instead of asking user, will foretold all answers as no.
789770
+BOStartupTracker = Enable startup time tracker
789770
 
789770
 # Itweb-settings boot commands
789770
 IBOList=Shows a list of all the IcedTea-Web settings and their current values.
789770
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot.java b/netx/net/sourceforge/jnlp/runtime/Boot.java
789770
index 7317b989..a9990909 100644
789770
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java
789770
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java
789770
@@ -107,6 +107,10 @@ public final class Boot implements PrivilegedAction<Void> {
789770
 
789770
         optionParser = new OptionParser(argsIn, OptionsDefinitions.getJavaWsOptions());
789770
 
789770
+        if (optionParser.hasOption(OptionsDefinitions.OPTIONS.STARTUP_TRACKER)) {
789770
+            JNLPRuntime.initStartupTracker();
789770
+        }
789770
+
789770
         if (optionParser.hasOption(OptionsDefinitions.OPTIONS.VERBOSE)) {
789770
             JNLPRuntime.setDebug(true);
789770
         }
789770
diff --git a/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java b/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java
789770
index 9746f5d0..811d132e 100644
789770
--- a/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java
789770
+++ b/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java
789770
@@ -43,6 +43,7 @@ import java.io.FileOutputStream;
789770
 import java.io.IOException;
789770
 import java.io.InputStream;
789770
 import java.io.OutputStream;
789770
+import java.net.URISyntaxException;
789770
 import java.net.URL;
789770
 import java.net.URLConnection;
789770
 import java.security.AccessController;
789770
@@ -103,9 +104,11 @@ final class CachedJarFileCallback implements URLJarFileCallBack {
789770
 
789770
         if (UrlUtils.isLocalFile(localUrl)) {
789770
             // if it is known to us, just return the cached file
789770
-            JarFile returnFile = new JarFile(localUrl.getPath());
789770
+            JarFile returnFile=null;
789770
             
789770
             try {
789770
+            	localUrl.toURI().getPath();
789770
+            	returnFile = new JarFile(localUrl.toURI().getPath());
789770
                 
789770
                 // Blank out the class-path because:
789770
                 // 1) Web Start does not support it
789770
@@ -117,6 +120,8 @@ final class CachedJarFileCallback implements URLJarFileCallBack {
789770
 
789770
             } catch (NullPointerException npe) {
789770
                 // Discard NPE here. Maybe there was no manifest, maybe there were no attributes, etc.
789770
+			} catch (URISyntaxException e) {
789770
+				// should not happen as localUrl was built using localFile.toURI().toURL(), see JNLPClassLoader.activateJars(List<JARDesc>)
789770
             }
789770
 
789770
             return returnFile;
789770
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
789770
index 3785707a..77576fdd 100644
789770
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
789770
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
789770
@@ -709,7 +709,9 @@ public class JNLPClassLoader extends URLClassLoader {
789770
             fillInPartJars(initialJars); // add in each initial part's lazy jars
789770
         }
789770
 
789770
+        JNLPRuntime.addStartupTrackingEntry("JARs download enter");
789770
         waitForJars(initialJars); //download the jars first.
789770
+        JNLPRuntime.addStartupTrackingEntry("JARs download complete");
789770
 
789770
         //A ZipException will propagate later on if the jar is invalid and not checked here
789770
         if (shouldFilterInvalidJars()) {
789770
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
789770
index 295744db..919f78fd 100644
789770
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
789770
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
789770
@@ -170,6 +170,7 @@ public class JNLPRuntime {
789770
 
789770
     private static Boolean onlineDetected = null;
789770
 
789770
+    private static long startupTrackerMoment = 0;
789770
 
789770
     /** 
789770
      * Header is not checked and so eg
789770
@@ -891,6 +892,19 @@ public class JNLPRuntime {
789770
         JNLPRuntime.ignoreHeaders = ignoreHeaders;
789770
     }
789770
 
789770
+    // may only be called from Boot
789770
+    public static void initStartupTracker() {
789770
+        startupTrackerMoment = System.currentTimeMillis();
789770
+    }
789770
+
789770
+    public static void addStartupTrackingEntry(String message) {
789770
+        if (startupTrackerMoment > 0) {
789770
+            long time = (System.currentTimeMillis() - startupTrackerMoment)/1000;
789770
+            String msg = "Startup tracker: seconds elapsed: [" + time + "], message: [" + message + "]";
789770
+            OutputController.getLogger().log(OutputController.Level.ERROR_ALL, msg);
789770
+        }
789770
+    }
789770
+
789770
     private static boolean isPluginDebug() {
789770
         if (pluginDebug == null) {
789770
             try {
789770
diff --git a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
789770
index eb26dc69..7fd5d92f 100644
789770
--- a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
789770
+++ b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
789770
@@ -39,15 +39,18 @@ import java.util.Enumeration;
789770
 import java.util.HashMap;
789770
 import java.util.List;
789770
 import java.util.Map;
789770
-import java.util.Vector;
789770
+import java.util.concurrent.Callable;
789770
+import java.util.concurrent.Future;
789770
 import java.util.jar.JarEntry;
789770
 import java.util.regex.Pattern;
789770
 
789770
 import net.sourceforge.jnlp.JARDesc;
789770
 import net.sourceforge.jnlp.JNLPFile;
789770
 import net.sourceforge.jnlp.LaunchException;
789770
+import net.sourceforge.jnlp.cache.CachedDaemonThreadPoolProvider;
789770
 import net.sourceforge.jnlp.cache.ResourceTracker;
789770
 import net.sourceforge.jnlp.runtime.JNLPClassLoader.SecurityDelegate;
789770
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
789770
 import net.sourceforge.jnlp.security.AppVerifier;
789770
 import net.sourceforge.jnlp.security.CertVerifier;
789770
 import net.sourceforge.jnlp.security.CertificateUtils;
789770
@@ -226,37 +229,36 @@ public class JarCertVerifier implements CertVerifier {
789770
     private void verifyJars(List<JARDesc> jars, ResourceTracker tracker)
789770
             throws Exception {
789770
 
789770
+        List<String> filesToVerify = new ArrayList<>();
789770
         for (JARDesc jar : jars) {
789770
+            File jarFile = tracker.getCacheFile(jar.getLocation());
789770
 
789770
-            try {
789770
-
789770
-                File jarFile = tracker.getCacheFile(jar.getLocation());
789770
-
789770
-                // some sort of resource download/cache error. Nothing to add
789770
-                // in that case ... but don't fail here
789770
-                if (jarFile == null) {
789770
-                    continue;
789770
-                }
789770
+            // some sort of resource download/cache error. Nothing to add
789770
+            // in that case ... but don't fail here
789770
+            if (jarFile == null) {
789770
+                continue;
789770
+            }
789770
 
789770
-                String localFile = jarFile.getAbsolutePath();
789770
-                if (verifiedJars.contains(localFile)
789770
-                        || unverifiedJars.contains(localFile)) {
789770
-                    continue;
789770
-                }
789770
+            String localFile = jarFile.getAbsolutePath();
789770
+            if (verifiedJars.contains(localFile)
789770
+                    || unverifiedJars.contains(localFile)) {
789770
+                continue;
789770
+            }
789770
 
789770
-                VerifyResult result = verifyJar(localFile);
789770
+            filesToVerify.add(localFile);
789770
+        }
789770
 
789770
-                if (result == VerifyResult.UNSIGNED) {
789770
-                    unverifiedJars.add(localFile);
789770
-                } else if (result == VerifyResult.SIGNED_NOT_OK) {
789770
-                    verifiedJars.add(localFile);
789770
-                } else if (result == VerifyResult.SIGNED_OK) {
789770
-                    verifiedJars.add(localFile);
789770
-                }
789770
-            } catch (Exception e) {
789770
-                // We may catch exceptions from using verifyJar()
789770
-                // or from checkTrustedCerts
789770
-                throw e;
789770
+        List<VerifiedJarFile> verified = verifyJarsParallel(filesToVerify);
789770
+
789770
+        for (VerifiedJarFile vjf : verified) {
789770
+            VerifyResult result = verifyJarEntryCerts(vjf.file, vjf.hasManifest, vjf.entriesVec);
789770
+            String localFile = vjf.file;
789770
+            if (result == VerifyResult.UNSIGNED) {
789770
+                unverifiedJars.add(localFile);
789770
+            } else if (result == VerifyResult.SIGNED_NOT_OK) {
789770
+                verifiedJars.add(localFile);
789770
+            } else if (result == VerifyResult.SIGNED_OK) {
789770
+                verifiedJars.add(localFile);
789770
             }
789770
         }
789770
 
789770
@@ -264,6 +266,31 @@ public class JarCertVerifier implements CertVerifier {
789770
             checkTrustedCerts(certPath);
789770
     }
789770
 
789770
+    private List<VerifiedJarFile> verifyJarsParallel(List<String> files) throws Exception {
789770
+        JNLPRuntime.addStartupTrackingEntry("JARs verification enter");
789770
+        List<Callable<VerifiedJarFile>> callables = new ArrayList<>(files.size());
789770
+        for (final String fi : files) {
789770
+            callables.add(new Callable<VerifiedJarFile>() {
789770
+                @Override
789770
+                public VerifiedJarFile call() throws Exception {
789770
+                    return verifyJar(fi);
789770
+                }
789770
+            });
789770
+        }
789770
+        List<Future<VerifiedJarFile>> futures = CachedDaemonThreadPoolProvider.getThreadPool().invokeAll(callables);
789770
+        List<VerifiedJarFile> results = new ArrayList<>(files.size());
789770
+        try {
789770
+            for (Future<VerifiedJarFile> fu : futures) {
789770
+                results.add(fu.get());
789770
+            }
789770
+        } catch (Exception e) {
789770
+            OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
789770
+            throw e;
789770
+        }
789770
+        JNLPRuntime.addStartupTrackingEntry("JARs verification complete");
789770
+        return results;
789770
+    }
789770
+
789770
     /**
789770
      * Checks through all the jar entries of jarName for signers, storing all the common ones in the certs hash map.
789770
      * 
789770
@@ -273,15 +300,15 @@ public class JarCertVerifier implements CertVerifier {
789770
      * @throws Exception
789770
      *             Will be thrown if there are any problems with the jar.
789770
      */
789770
-    private VerifyResult verifyJar(String jarName) throws Exception {
789770
+    private VerifiedJarFile verifyJar(String jarName) throws Exception {
789770
         try (JarFile jarFile = new JarFile(jarName, true)) {
789770
-            Vector<JarEntry> entriesVec = new Vector<JarEntry>();
789770
+            List<JarEntry> entriesVec = new ArrayList<>();
789770
             byte[] buffer = new byte[8192];
789770
 
789770
             Enumeration<JarEntry> entries = jarFile.entries();
789770
             while (entries.hasMoreElements()) {
789770
                 JarEntry je = entries.nextElement();
789770
-                entriesVec.addElement(je);
789770
+                entriesVec.add(je);
789770
 
789770
                 InputStream is = jarFile.getInputStream(je);
789770
                 try {
789770
@@ -295,8 +322,7 @@ public class JarCertVerifier implements CertVerifier {
789770
                     }
789770
                 }
789770
             }
789770
-            return verifyJarEntryCerts(jarName, jarFile.getManifest() != null,
789770
-                    entriesVec);
789770
+            return new VerifiedJarFile(jarName, null != jarFile.getManifest(), entriesVec);
789770
 
789770
         } catch (Exception e) {
789770
             OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
789770
@@ -318,7 +344,7 @@ public class JarCertVerifier implements CertVerifier {
789770
      *             Will be thrown if there are issues with entries.
789770
      */
789770
     VerifyResult verifyJarEntryCerts(String jarName, boolean jarHasManifest,
789770
-            Vector<JarEntry> entries) throws Exception {
789770
+            List<JarEntry> entries) throws Exception {
789770
         // Contains number of entries the cert with this CertPath has signed.
789770
         Map<CertPath, Integer> jarSignCount = new HashMap<>();
789770
         int numSignableEntriesInJar = 0;
789770
@@ -629,4 +655,16 @@ public class JarCertVerifier implements CertVerifier {
789770
         }
789770
         return sum;
789770
     }
789770
+
789770
+    private static class VerifiedJarFile {
789770
+        final String file;
789770
+        final boolean hasManifest;
789770
+        private final List<JarEntry> entriesVec;
789770
+
789770
+        private VerifiedJarFile(String file, boolean hasManifest, List<JarEntry> entriesVec) {
789770
+            this.file = file;
789770
+            this.hasManifest = hasManifest;
789770
+            this.entriesVec = entriesVec;
789770
+        }
789770
+    }
789770
 }
789770
diff --git a/netx/net/sourceforge/jnlp/util/PropertiesFile.java b/netx/net/sourceforge/jnlp/util/PropertiesFile.java
789770
index 2f0918f6..c399ef20 100644
789770
--- a/netx/net/sourceforge/jnlp/util/PropertiesFile.java
789770
+++ b/netx/net/sourceforge/jnlp/util/PropertiesFile.java
789770
@@ -23,6 +23,8 @@ import java.io.IOException;
789770
 import java.io.InputStream;
789770
 import java.util.Properties;
789770
 
789770
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
789770
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
789770
 import net.sourceforge.jnlp.util.lockingfile.LockedFile;
789770
 import net.sourceforge.jnlp.util.logging.OutputController;
789770
 
789770
@@ -168,7 +170,9 @@ public class PropertiesFile extends Properties {
789770
                 store(s, header);
789770
 
789770
                 // fsync()
789770
-                s.getChannel().force(true);
789770
+                if (Boolean.parseBoolean(JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_ENABLE_CACHE_FSYNC))) {
789770
+                    s.getChannel().force(true);
789770
+                }
789770
                 lastStore = file.lastModified();
789770
             } finally {
789770
                 if (s != null) s.close();
789770
diff --git a/tests/netx/unit/net/sourceforge/jnlp/runtime/CachedJarFileCallbackTest.java b/tests/netx/unit/net/sourceforge/jnlp/runtime/CachedJarFileCallbackTest.java
789770
new file mode 100644
789770
index 00000000..bc564db5
789770
--- /dev/null
789770
+++ b/tests/netx/unit/net/sourceforge/jnlp/runtime/CachedJarFileCallbackTest.java
789770
@@ -0,0 +1,55 @@
789770
+package net.sourceforge.jnlp.runtime;
789770
+
789770
+import java.io.File;
789770
+import java.io.IOException;
789770
+import java.net.URL;
789770
+import java.net.URLEncoder;
789770
+import java.nio.charset.StandardCharsets;
789770
+import java.util.Arrays;
789770
+import java.util.List;
789770
+import java.util.jar.JarFile;
789770
+
789770
+import org.junit.After;
789770
+import org.junit.Before;
789770
+import org.junit.Test;
789770
+
789770
+import net.sourceforge.jnlp.util.FileTestUtils;
789770
+import net.sourceforge.jnlp.util.FileUtils;
789770
+
789770
+public class CachedJarFileCallbackTest {
789770
+	private File tempDirectory;
789770
+
789770
+	@Before
789770
+	public void before() throws IOException {
789770
+		tempDirectory = FileTestUtils.createTempDirectory();
789770
+	}
789770
+
789770
+	@After
789770
+	public void after() throws IOException {
789770
+		FileUtils.recursiveDelete(tempDirectory, tempDirectory.getParentFile());
789770
+	}
789770
+
789770
+	@Test
789770
+	public void testRetrieve() throws Exception {
789770
+		List<String> names = Arrays.asList("test1.0.jar", "test@1.0.jar");
789770
+		
789770
+		for (String name: names) {
789770
+			// URL-encode the filename
789770
+			name = URLEncoder.encode(name, StandardCharsets.UTF_8.name());
789770
+			// create temp jar file
789770
+			File jarFile = new File(tempDirectory, name);
789770
+			FileTestUtils.createJarWithContents(jarFile /* no contents */);
789770
+
789770
+			// JNLPClassLoader.activateJars uses toUri().toURL() to get the local file URL
789770
+			URL localUrl = jarFile.toURI().toURL();
789770
+			URL remoteUrl = new URL("http://localhost/" + name);
789770
+			// add jar to cache
789770
+			CachedJarFileCallback cachedJarFileCallback = CachedJarFileCallback.getInstance();
789770
+			cachedJarFileCallback.addMapping(remoteUrl, localUrl);
789770
+			// retrieve from cache (throws exception if file not found)
789770
+			try (JarFile fromCacheJarFile = cachedJarFileCallback.retrieve(remoteUrl)) {
789770
+				// nothing to do, we just wanted to make sure that the local file existed
789770
+			}
789770
+		}
789770
+	}
789770
+}