You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Martin Krüger (JIRA)" <ji...@apache.org> on 2015/10/15 13:52:05 UTC

[jira] [Commented] (KARAF-4069) ConsoleSessionImpl does not close the session in function close()

    [ https://issues.apache.org/jira/browse/KARAF-4069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14958783#comment-14958783 ] 

Martin Krüger commented on KARAF-4069:
--------------------------------------

Unfortunately I am not able to provide a patch in this case because I can not say if the order where the session is closed is relevant in the close function.

{code}
public void close() {
        if (!running) {
            return;
        }
        out.println();
        if (reader.getHistory() instanceof PersistentHistory) {
            try {
                ((PersistentHistory) reader.getHistory()).flush();
            } catch (IOException e) {
                // ignore
            }
        }
        running = false;
        pipe.interrupt();
        if (thread != Thread.currentThread()) {
            thread.interrupt();
        }
        reader.shutdown();
        if (closeCallback != null) {
            closeCallback.run();
        }
        if (terminal instanceof Closeable) {
            try {
                ((Closeable) terminal).close();
            } catch (IOException e) {
                // Ignore
            }
        }
    }
{code}

I suggest putting the {code}session.close();{code} at the end of the function. It was not present before and closing the session only improves the situation. But please feel free to put it where it makes sense.

> ConsoleSessionImpl does not close the session in function close()
> -----------------------------------------------------------------
>
>                 Key: KARAF-4069
>                 URL: https://issues.apache.org/jira/browse/KARAF-4069
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-shell
>    Affects Versions: 4.0.2
>            Reporter: Martin Krüger
>
> In the class ConsoleSessionImpl does not close the session originated from the class CommandProcessorImpl (from SessionFactoryImpl.create(...)). Resulting from that the CommandProcessorImpl keeps all open sessions in a WeakHashMap which will grow over time too.
> On the other hand the HeadlessSessionImpl does close the session in its close function.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)