You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2022/02/28 15:45:16 UTC

[sling-org-apache-sling-feature-launcher] branch master updated: SLING-11166: add a runWithException method to the bootstrap

This is an automated email from the ASF dual-hosted git repository.

pauls pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git


The following commit(s) were added to refs/heads/master by this push:
     new 7cea27f  SLING-11166: add a runWithException method to the bootstrap
7cea27f is described below

commit 7cea27fc911d05cfd64925017d234ab7cba9fade
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Mon Feb 28 16:45:06 2022 +0100

    SLING-11166: add a runWithException method to the bootstrap
---
 .../sling/feature/launcher/impl/Bootstrap.java     | 31 ++++++++++------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java b/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
index dde1b04..8e9201b 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
@@ -96,6 +96,15 @@ public class Bootstrap {
     }
 
     public void run() {
+        try {
+            runWithException();
+        } catch (Exception ex) {
+            this.logger.error("Error during bootstrap", ex);
+            System.exit(1);
+        }
+    }
+
+    public void runWithException() throws Exception {
         this.logger.info("");
         this.logger.info("Apache Sling Application Launcher");
         this.logger.info("---------------------------------");
@@ -106,8 +115,7 @@ public class Bootstrap {
 
         Iterator<Launcher> iterator = ServiceLoader.load(Launcher.class).iterator();
         if (!iterator.hasNext()) {
-            this.logger.error("Unable to find launcher service.");
-            System.exit(1);
+            throw new IllegalStateException("Unable to find launcher service.");
         }
 
         final Launcher launcher = iterator.next();
@@ -158,21 +166,14 @@ public class Bootstrap {
                     this.config.getInstallation().getBundleMap().clear();
                 }
             } catch ( final Exception iae) {
-                this.logger.error("Error while assembling launcher: {}", iae.getMessage(), iae);
-                System.exit(1);
+                throw new IllegalStateException("Error while assembling launcher: " + iae.getMessage(), iae);
             }
         }
         catch (IOException ex) {
-            this.logger.error("Unable to setup artifact manager: {}", ex.getMessage(), ex);
-            System.exit(1);
+            throw new IOException("Unable to setup artifact manager: " + ex.getMessage(), ex);
         }
 
-        try {
-            run(launcher);
-        } catch ( final Exception iae) {
-            this.logger.error("Error while running launcher: {}", iae.getMessage(), iae);
-            System.exit(1);
-        }
+        run(launcher);
     }
 
     private ArtifactId getFrameworkArtifactId(final Feature app) {
@@ -217,11 +218,7 @@ public class Bootstrap {
             {
                 FeatureJSONWriter.write(writer, app);
             }
-            catch (final IOException ioe)
-            {
-                this.logger.error("Error while writing application file: {}", ioe.getMessage(), ioe);
-                System.exit(1);
-            }
+
             return app;
         }
     }