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 2018/01/18 16:12:18 UTC

[karaf] branch master updated (004638a -> 4078698)

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

gnodet pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git.


    from 004638a  [KARAF-5558] Expose Quartz Scheduler configuration
     new 3dec614  Clean a bit the console branding loading code
     new 4078698  Catch all Throwable in order to more easily debug possible problems

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/karaf/shell/impl/console/Branding.java  | 63 +++++++---------------
 .../shell/impl/console/ConsoleSessionImpl.java     |  2 +-
 .../apache/karaf/util/tracker/BaseActivator.java   |  2 +-
 3 files changed, 20 insertions(+), 47 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@karaf.apache.org" <co...@karaf.apache.org>'].

[karaf] 01/02: Clean a bit the console branding loading code

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git

commit 3dec614120d7eda283e03afd45cb89074e0608d7
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Jan 18 17:11:23 2018 +0100

    Clean a bit the console branding loading code
---
 .../apache/karaf/shell/impl/console/Branding.java  | 63 +++++++---------------
 .../shell/impl/console/ConsoleSessionImpl.java     |  2 +-
 2 files changed, 19 insertions(+), 46 deletions(-)

diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java
index 6af4691..775c5ea 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java
@@ -18,7 +18,6 @@
  */
 package org.apache.karaf.shell.impl.console;
 
-import org.apache.karaf.shell.api.console.Terminal;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,60 +30,34 @@ public final class Branding {
 
     private Branding() { }
 
-    public static Properties loadBrandingProperties() {
+    public static Properties loadBrandingProperties(boolean ssh) {
         Properties props = new Properties();
-        loadProps(props, "org/apache/karaf/shell/console/branding.properties");
-        loadProps(props, "org/apache/karaf/branding/branding.properties");
+        String name = ssh ? "branding-ssh.properties" : "branding.properties";
+        loadPropsFromResource(props, "org/apache/karaf/shell/console/" + name);
+        loadPropsFromResource(props, "org/apache/karaf/branding/" + name);
+        loadPropsFromFile(props, System.getProperty("karaf.etc") + "/" + name);
         return props;
     }
 
-    public static Properties loadBrandingProperties(Terminal terminal) {
-        Properties props = new Properties();
-        if (terminal != null && terminal.getClass().getName().endsWith("SshTerminal")) {
-            loadProps(props, "org/apache/karaf/shell/console/branding-ssh.properties");
-            loadProps(props, "org/apache/karaf/branding/branding.properties");
-            return loadEtcBrandingFile("branding-ssh.properties",props);
-        } else {
-            loadProps(props, "org/apache/karaf/shell/console/branding.properties");
-            loadProps(props, "org/apache/karaf/branding/branding.properties");
-            return loadEtcBrandingFile("branding.properties",props);
+    private static void loadPropsFromFile(Properties props, String fileName) {
+        try (FileInputStream is = new FileInputStream(fileName)) {
+            loadProps(props, is);
+        } catch (IOException e) {
+            LOGGER.trace("Could not load branding.", e);
         }
     }
 
-    private static Properties loadEtcBrandingFile(String fileName, Properties props){
-        File etcBranding = new File(System.getProperty("karaf.etc"), fileName);
-        if (etcBranding.exists()) {
-            FileInputStream etcBrandingIs = null;
-            try {
-                etcBrandingIs = new FileInputStream(etcBranding);
-            } catch (FileNotFoundException e) {
-                LOGGER.trace("Could not load branding.", e);
-            }
-            loadProps(props, etcBrandingIs);
+    private static void loadPropsFromResource(Properties props, String resource) {
+        try (InputStream is = Branding.class.getClassLoader().getResourceAsStream(resource)) {
+            loadProps(props, is);
+        } catch (IOException e) {
+            LOGGER.trace("Could not load branding.", e);
         }
-        return props;
     }
 
-    protected static void loadProps(Properties props, String resource) {
-        InputStream is = Branding.class.getClassLoader().getResourceAsStream(resource);
-        loadProps(props, is);
-    }
-
-    protected static void loadProps(Properties props, InputStream is) {
-        try {
-            if (is != null) {
-                props.load(is);
-            }
-        } catch (IOException e) {
-            // ignore
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    // Ignore
-                }
-            }
+    private static void loadProps(Properties props, InputStream is) throws IOException {
+        if (is != null) {
+            props.load(is);
         }
     }
 
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index b0e2765..1563ad0 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -153,7 +153,7 @@ public class ConsoleSessionImpl implements Session {
             }
         }
 
-        brandingProps = Branding.loadBrandingProperties(terminal);
+        brandingProps = Branding.loadBrandingProperties(terminal.getClass().getName().endsWith("SshTerminal"));
 
         // Create session
         session = processor.createSession(jlineTerminal.input(),

-- 
To stop receiving notification emails like this one, please contact
"commits@karaf.apache.org" <co...@karaf.apache.org>.

[karaf] 02/02: Catch all Throwable in order to more easily debug possible problems

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git

commit 4078698e8dcde80c5c4dc0c1c492374c7db0ca98
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Jan 18 17:11:51 2018 +0100

    Catch all Throwable in order to more easily debug possible problems
---
 util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java b/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java
index 63b2622..c2c7204 100644
--- a/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java
+++ b/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java
@@ -91,7 +91,7 @@ public class BaseActivator implements BundleActivator, Runnable, ThreadFactory {
                     .allMatch(t -> t.getService() != null)) {
             try {
                 doStart();
-            } catch (Exception e) {
+            } catch (Throwable e) {
                 logger.warn("Error starting activator", e);
                 doStop();
             }

-- 
To stop receiving notification emails like this one, please contact
"commits@karaf.apache.org" <co...@karaf.apache.org>.