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/03/24 17:32:04 UTC

[06/24] git commit: Log exceptions correctly instead of using printStackTrace()

Log exceptions correctly instead of using printStackTrace()


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

Branch: refs/heads/master
Commit: f652fabe523d7b2c56185562132e5a3eba348f16
Parents: 9483e50
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Mon Mar 24 13:21:03 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Mon Mar 24 17:30:12 2014 +0100

----------------------------------------------------------------------
 .../org/apache/karaf/shell/ssh/Activator.java   | 25 ++++++--------------
 1 file changed, 7 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/f652fabe/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
index a61babc..575c871 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
@@ -45,12 +45,16 @@ import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
 import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Activate this bundle
  */
 public class Activator implements BundleActivator, ManagedService {
 
+    static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+
     ServiceRegistration registration;
 
     List<Session> sessions = new CopyOnWriteArrayList<Session>();
@@ -128,7 +132,7 @@ public class Activator implements BundleActivator, ManagedService {
             try {
                 server.start();
             } catch (IOException e) {
-                e.printStackTrace();
+                LOGGER.warn("Exception caught while starting SSH server", e);
             }
         }
     }
@@ -144,7 +148,7 @@ public class Activator implements BundleActivator, ManagedService {
             try {
                 srv.stop();
             } catch (InterruptedException e) {
-                e.printStackTrace();
+                LOGGER.warn("Exception caught while stopping SSH server", e);
             }
         }
     }
@@ -158,8 +162,7 @@ public class Activator implements BundleActivator, ManagedService {
                 try {
                     server.stop();
                 } catch (InterruptedException e) {
-                    // TODO: log exception
-                    e.printStackTrace();
+                    LOGGER.warn("Exception caught while stopping SSH server", e);
                 }
             }
         }
@@ -251,18 +254,4 @@ public class Activator implements BundleActivator, ManagedService {
         return server;
     }
 
-    public void bindCommandSession(Session session) {
-        sessions.add(session);
-        if (agentFactory != null) {
-            agentFactory.registerSession(session);
-        }
-    }
-
-    public void unbindCommandSession(Session session) {
-        sessions.remove(session);
-        if (agentFactory != null) {
-            agentFactory.unregisterSession(session);
-        }
-    }
-
 }