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 2012/04/06 11:20:26 UTC

svn commit: r1310257 - in /karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi: InstallBundle.java RestartBundle.java StartBundle.java StopBundle.java

Author: gnodet
Date: Fri Apr  6 09:20:25 2012
New Revision: 1310257

URL: http://svn.apache.org/viewvc?rev=1310257&view=rev
Log:
[KARAF-1040] Commands should not catch exceptions but should rethrow them

Modified:
    karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/InstallBundle.java
    karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RestartBundle.java
    karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StartBundle.java
    karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java

Modified: karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/InstallBundle.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/InstallBundle.java?rev=1310257&r1=1310256&r2=1310257&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/InstallBundle.java (original)
+++ karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/InstallBundle.java Fri Apr  6 09:20:25 2012
@@ -16,17 +16,15 @@
  */
 package org.apache.karaf.shell.osgi;
 
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.karaf.shell.console.MultiException;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
 import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
 import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.karaf.shell.console.MultiException;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
 
 @Command(scope = "osgi", name = "install", description = "Installs one or more bundles.")
 public class InstallBundle extends OsgiCommandSupport {
@@ -52,7 +50,8 @@ public class InstallBundle extends OsgiC
                 try {
                     bundle.start();
                 } catch (Exception e) {
-                    exceptions.add(new Exception("Unable to start bundle " + bundle.getLocation(), e));
+                    exceptions.add(new Exception("Unable to start bundle " + bundle.getLocation() +
+                            (e.getMessage() != null ? ": " + e.getMessage() : ""), e));
                 }
             }
         }
@@ -72,21 +71,4 @@ public class InstallBundle extends OsgiC
         return null;
     }
 
-    protected Bundle install(String location, PrintStream out, PrintStream err) {
-        try {
-            return getBundleContext().installBundle(location, null);
-        } catch (IllegalStateException ex) {
-            err.println(ex.toString());
-        } catch (BundleException ex) {
-            if (ex.getNestedException() != null) {
-                err.println(ex.getNestedException().toString());
-            } else {
-                err.println(ex.toString());
-            }
-        } catch (Exception ex) {
-            err.println(ex.toString());
-        }
-        return null;
-    }
-
 }

Modified: karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RestartBundle.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RestartBundle.java?rev=1310257&r1=1310256&r2=1310257&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RestartBundle.java (original)
+++ karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RestartBundle.java Fri Apr  6 09:20:25 2012
@@ -32,14 +32,16 @@ public class RestartBundle extends Bundl
             try {
                 bundle.stop();
             } catch (Exception e) {
-                exceptions.add(new Exception("Unable to stop bundle " + bundle.getBundleId()));
+                exceptions.add(new Exception("Unable to stop bundle " + bundle.getBundleId() +
+                        (e.getMessage() != null ? ": " + e.getMessage() : ""), e));
             }
         }
         for (Bundle bundle : bundles) {
             try {
                 bundle.start();
             } catch (Exception e) {
-                exceptions.add(new Exception("Unable to start bundle " + bundle.getBundleId()));
+                exceptions.add(new Exception("Unable to start bundle " + bundle.getBundleId() +
+                        (e.getMessage() != null ? ": " + e.getMessage() : ""), e));
             }
         }
         MultiException.throwIf("Error restarting bundles", exceptions);

Modified: karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StartBundle.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StartBundle.java?rev=1310257&r1=1310256&r2=1310257&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StartBundle.java (original)
+++ karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StartBundle.java Fri Apr  6 09:20:25 2012
@@ -32,7 +32,8 @@ public class StartBundle extends Bundles
             try {
                 bundle.start();
             } catch (Exception e) {
-                exceptions.add(new Exception("Unable to start bundle " + bundle.getBundleId()));
+                exceptions.add(new Exception("Unable to start bundle " + bundle.getBundleId() +
+                        (e.getMessage() != null ? ": " + e.getMessage() : ""), e));
             }
         }
         MultiException.throwIf("Error starting bundles", exceptions);

Modified: karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java?rev=1310257&r1=1310256&r2=1310257&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java (original)
+++ karaf/branches/karaf-2.3.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java Fri Apr  6 09:20:25 2012
@@ -32,7 +32,8 @@ public class StopBundle extends BundlesC
             try {
                 bundle.stop();
             } catch (Exception e) {
-                exceptions.add(new Exception("Unable to stop bundle " + bundle.getBundleId()));
+                exceptions.add(new Exception("Unable to stop bundle " + bundle.getBundleId() +
+                        (e.getMessage() != null ? ": " + e.getMessage() : ""), e));
             }
         }
         MultiException.throwIf("Error stopping bundles", exceptions);