Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector opened on line 64 in never closed #10

Open
larsmaes opened this issue Apr 1, 2014 · 1 comment
Open

Selector opened on line 64 in never closed #10

larsmaes opened this issue Apr 1, 2014 · 1 comment

Comments

@larsmaes
Copy link

larsmaes commented Apr 1, 2014

The Selecotr that is opened on line 64 in never closed. This will eventually cause a "Too many files open" Exception.

@chrisinmtown
Copy link

Suggest replacing the existing close() method with the following:

    /**
     * The OutputStream passed to Expect constructor is closed; the InputStream
     * is not closed (there is no need to close the InputStream).<br>
     * It is suggested that this method be called after the InputStream has come
     * to EOF. For example, when you connect through SSH, send an "exit" command
     * first, and then call this method.<br>
     * <br>
     * 
     * When this method is called, the thread which write to the sink of the
     * pipe will end.
     */
    public void close() {
        try {
            this.output.close();
        } catch (IOException e) {
            log.warn("Exception when closing OutputStream", e);
            //e.printStackTrace();
        }
        try {
            this.inputChannel.close();
        } catch (IOException e) {
            log.warn("Exception when closing input Channel", e);
            //e.printStackTrace();
        }
        try {
            this.selector.close();
        } catch (IOException e) {
            log.warn("Exception when closing selector", e);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants