You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/05/28 13:48:42 UTC

[2/4] git commit: Avoid useless framework refreshes from bundle watcher

Avoid useless framework refreshes from bundle watcher

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/400c4794
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/400c4794
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/400c4794

Branch: refs/heads/master
Commit: 400c47944ef98b2f89aaea855596dc6fb418e529
Parents: f6d4208
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Tue May 27 17:52:36 2014 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Tue May 27 17:52:36 2014 +0200

----------------------------------------------------------------------
 .../bundle/core/internal/BundleWatcherImpl.java | 34 +++++++++++---------
 1 file changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/400c4794/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
index cb52567..5181bc3 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
@@ -115,22 +115,24 @@ public class BundleWatcherImpl implements Runnable, BundleListener, BundleWatche
                         logger.error("Error updating bundle.", ex);
                     }
                 }
-                try {
-                    final CountDownLatch latch = new CountDownLatch(1);
-                    wiring.refreshBundles(updated, new FrameworkListener() {
-                        public void frameworkEvent(FrameworkEvent event) {
-                            latch.countDown();
-                        }
-                    });
-                    latch.await();
-                } catch (InterruptedException e) {
-                    running.set(false);
-                }
-                for (Bundle bundle : updated) {
+                if (!updated.isEmpty()) {
                     try {
-                        bundle.start(Bundle.START_TRANSIENT);
-                    } catch (BundleException ex) {
-                        logger.warn("Error starting bundle", ex);
+                        final CountDownLatch latch = new CountDownLatch(1);
+                        wiring.refreshBundles(updated, new FrameworkListener() {
+                            public void frameworkEvent(FrameworkEvent event) {
+                                latch.countDown();
+                            }
+                        });
+                        latch.await();
+                    } catch (InterruptedException e) {
+                        running.set(false);
+                    }
+                    for (Bundle bundle : updated) {
+                        try {
+                            bundle.start(Bundle.START_TRANSIENT);
+                        } catch (BundleException ex) {
+                            logger.warn("Error starting bundle", ex);
+                        }
                     }
                 }
             }
@@ -151,7 +153,7 @@ public class BundleWatcherImpl implements Runnable, BundleListener, BundleWatche
     }
 
     private void updateBundleIfNecessary(File localRepository, List<Bundle> updated, Bundle bundle)
-        throws FileNotFoundException, BundleException, IOException {
+        throws BundleException, IOException {
         File location = getBundleExternalLocation(localRepository, bundle);
         if (location != null && location.exists() && location.lastModified() > bundle.getLastModified()) {
             InputStream is = new FileInputStream(location);