Repository: karaf
Updated Branches:
  refs/heads/master c773bbf78 -> ab9c504e4


[KARAF-4068] Remove ssh session list causing memory leak


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

Branch: refs/heads/master
Commit: e004006697aeeb68cfa28f7b255f3a623ba7faa3
Parents: 738281e
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Tue Oct 20 08:48:55 2015 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Tue Oct 20 08:48:55 2015 +0200

----------------------------------------------------------------------
 .../karaf/shell/impl/console/SessionFactoryImpl.java    | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/e0040066/shell/core/src/main/java/org/apache/karaf/shell/impl/console/SessionFactoryImpl.java
----------------------------------------------------------------------
diff --git 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/SessionFactoryImpl.java
 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/SessionFactoryImpl.java
index ba20338..8b3f57d 100644
--- 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/SessionFactoryImpl.java
+++ 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/SessionFactoryImpl.java
@@ -41,7 +41,6 @@ public class SessionFactoryImpl extends RegistryImpl 
implements SessionFactory,
 
     final CommandProcessorImpl commandProcessor;
     final ThreadIO threadIO;
-    final List<Session> sessions = new ArrayList<Session>();
     final Map<String, SubShellCommand> subshells = new HashMap<String, 
SubShellCommand>();
     boolean closed;
 
@@ -108,12 +107,11 @@ public class SessionFactoryImpl extends RegistryImpl 
implements SessionFactory,
 
     @Override
     public Session create(InputStream in, PrintStream out, PrintStream err, 
Terminal term, String encoding, Runnable closeCallback) {
-        synchronized (sessions) {
+        synchronized (commandProcessor) {
             if (closed) {
                 throw new IllegalStateException("SessionFactory has been 
closed");
             }
             final Session session = new ConsoleSessionImpl(this, 
commandProcessor, threadIO, in, out, err, term, encoding, closeCallback);
-            sessions.add(session);
             return session;
         }
     }
@@ -125,22 +123,18 @@ public class SessionFactoryImpl extends RegistryImpl 
implements SessionFactory,
 
     @Override
     public Session create(InputStream in, PrintStream out, PrintStream err, 
Session parent) {
-        synchronized (sessions) {
+        synchronized (commandProcessor) {
             if (closed) {
                 throw new IllegalStateException("SessionFactory has been 
closed");
             }
             final Session session = new HeadlessSessionImpl(this, 
commandProcessor, in, out, err, parent);
-            sessions.add(session);
             return session;
         }
     }
 
     public void stop() {
-        synchronized (sessions) {
+        synchronized (commandProcessor) {
             closed = true;
-            for (Session session : sessions) {
-                session.close();
-            }
             commandProcessor.stop();
         }
     }

Reply via email to