felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r909487 - /felix/trunk/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
Date Fri, 12 Feb 2010 16:23:56 GMT
Author: gnodet
Date: Fri Feb 12 16:23:55 2010
New Revision: 909487

URL: http://svn.apache.org/viewvc?rev=909487&view=rev
Log:
Catch exceptions while iterating over bundles entries
This removes the strack trace from the console, but it looks to me that iterating over an
uninstalled bundle is a bad idea

Modified:
    felix/trunk/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java

Modified: felix/trunk/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java?rev=909487&r1=909486&r2=909487&view=diff
==============================================================================
--- felix/trunk/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
(original)
+++ felix/trunk/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
Fri Feb 12 16:23:55 2010
@@ -120,45 +120,53 @@
     public void bundleChanged(BundleEvent bundleEvent) {
             Bundle bundle = bundleEvent.getBundle();
             if (bundleEvent.getType() == BundleEvent.RESOLVED) {
-                Enumeration featuresUrlEnumeration = bundle.findEntries("/META-INF/" + FEATURE_PATH
+ "/", "*.xml", false);
-                while (featuresUrlEnumeration != null && featuresUrlEnumeration.hasMoreElements())
{
-                    URL url = (URL) featuresUrlEnumeration.nextElement();
-                    try {
-                        featuresService.addRepository(url.toURI());
-                        for (Repository repo : featuresService.listRepositories()) {
-                            if (repo.getURI().equals(url.toURI())) {
-                                Set<Feature> features = new HashSet<Feature>(Arrays.asList(repo.getFeatures()));
-                                    featuresService.installFeatures(features, EnumSet.noneOf(FeaturesService.Option.class));
+                try {
+                    Enumeration featuresUrlEnumeration = bundle.findEntries("/META-INF/"
+ FEATURE_PATH + "/", "*.xml", false);
+                    while (featuresUrlEnumeration != null && featuresUrlEnumeration.hasMoreElements())
{
+                        URL url = (URL) featuresUrlEnumeration.nextElement();
+                        try {
+                            featuresService.addRepository(url.toURI());
+                            for (Repository repo : featuresService.listRepositories()) {
+                                if (repo.getURI().equals(url.toURI())) {
+                                    Set<Feature> features = new HashSet<Feature>(Arrays.asList(repo.getFeatures()));
+                                        featuresService.installFeatures(features, EnumSet.noneOf(FeaturesService.Option.class));
+                                }
                             }
+                        } catch (Exception e) {
+                            LOGGER.error("Unable to install features", e);
                         }
-                    } catch (Exception e) {
-                        LOGGER.error("Unable to install features", e);
                     }
+                } catch (Exception e) {
+                    // Ignore exceptions thrown when searching or iterating over the bundle
entries
                 }
             } else if (bundleEvent.getType() == BundleEvent.UNINSTALLED) {
-                Enumeration featuresUrlEnumeration = bundle.findEntries("/META-INF/" + FEATURE_PATH
+ "/", "*.xml", false);
-                while (featuresUrlEnumeration != null && featuresUrlEnumeration.hasMoreElements())
{
-                    URL url = (URL) featuresUrlEnumeration.nextElement();
-                    for (Repository repo : featuresService.listRepositories()) {
-                        try {
-                            if (repo.getURI().equals(url.toURI())) {
-                                for (Feature f : repo.getFeatures()) {
-                                    try {
-                                        featuresService.uninstallFeature(f.getName(), f.getVersion());
-                                    } catch (Exception e) {
-                                        LOGGER.error("Unable to uninstall feature: " + f.getName(),
e);
+                try {
+                    Enumeration featuresUrlEnumeration = bundle.findEntries("/META-INF/"
+ FEATURE_PATH + "/", "*.xml", false);
+                    while (featuresUrlEnumeration != null && featuresUrlEnumeration.hasMoreElements())
{
+                        URL url = (URL) featuresUrlEnumeration.nextElement();
+                        for (Repository repo : featuresService.listRepositories()) {
+                            try {
+                                if (repo.getURI().equals(url.toURI())) {
+                                    for (Feature f : repo.getFeatures()) {
+                                        try {
+                                            featuresService.uninstallFeature(f.getName(),
f.getVersion());
+                                        } catch (Exception e) {
+                                            LOGGER.error("Unable to uninstall feature: "
+ f.getName(), e);
+                                        }
                                     }
                                 }
+                            } catch (Exception e) {
+                                LOGGER.error("Unable to uninstall features: " + url, e);
                             }
-                        } catch (Exception e) {
-                            LOGGER.error("Unable to uninstall features: " + url, e);
+                        }
+                        try {
+                            featuresService.removeRepository(url.toURI());
+                        } catch (URISyntaxException e) {
+                            LOGGER.error("Unable to remove repository: " + url, e);
                         }
                     }
-                    try {
-                        featuresService.removeRepository(url.toURI());
-                    } catch (URISyntaxException e) {
-                        LOGGER.error("Unable to remove repository: " + url, e);
-                    }
+                } catch (Exception e) {
+                    // Ignore exceptions thrown when searching or iterating over the bundle
entries
                 }
             }
     }



Mime
View raw message