felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1720091 - /felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
Date Tue, 15 Dec 2015 08:55:32 GMT
Author: gnodet
Date: Tue Dec 15 08:55:32 2015
New Revision: 1720091

URL: http://svn.apache.org/viewvc?rev=1720091&view=rev
Log:
FELIX-5136 Improve startup performance and memory consumption of DirectoryWatcher

Modified:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java?rev=1720091&r1=1720090&r2=1720091&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
Tue Dec 15 08:55:32 2015
@@ -27,7 +27,6 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.security.SecureRandom;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -37,6 +36,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.jar.JarInputStream;
@@ -115,10 +115,6 @@ public class DirectoryWatcher extends Th
     public final static String LOG_STDOUT = "stdout";
     public final static String LOG_JUL = "jul";
 
-    static final SecureRandom random = new SecureRandom();
-
-    final File javaIoTmpdir = new File(System.getProperty("java.io.tmpdir"));
-
     final FileInstall fileInstall;
 
     Map<String, String> properties;
@@ -333,7 +329,7 @@ public class DirectoryWatcher extends Th
         int type = bundleEvent.getType();
         if (type == BundleEvent.UNINSTALLED)
         {
-            for (Iterator it = getArtifacts().iterator(); it.hasNext();)
+            for (Iterator<?> it = getArtifacts().iterator(); it.hasNext();)
             {
                 Artifact artifact = (Artifact) it.next();
                 if (artifact.getBundleId() == bundleEvent.getBundle().getBundleId())
@@ -594,17 +590,18 @@ public class DirectoryWatcher extends Th
     {
         if (tmpDir == null)
         {
+            File javaIoTmpdir = new File(System.getProperty("java.io.tmpdir"));
             if (!javaIoTmpdir.exists() && !javaIoTmpdir.mkdirs()) {
                 throw new IllegalStateException("Unable to create temporary directory " +
javaIoTmpdir);
             }
-            for (;;)
+            Random random = new Random();
+            while (tmpDir == null)
             {
                 File f = new File(javaIoTmpdir, "fileinstall-" + Long.toString(random.nextLong()));
                 if (!f.exists() && f.mkdirs())
                 {
                     tmpDir = f;
                     tmpDir.deleteOnExit();
-                    break;
                 }
             }
         }



Mime
View raw message