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

jline3 example should close Terminal (using try-with-resource or try-finally) #1168

Closed
dwalluck opened this issue Sep 10, 2020 · 3 comments
Closed
Milestone

Comments

@dwalluck
Copy link
Contributor

Should this line ensure that the terminal is closed?

Terminal terminal = TerminalBuilder.builder().build();

In the docs https://www.javadoc.io/doc/org.jline/jline/3.14.1/org/jline/terminal/Terminal.html it states that "Terminals should be closed by calling the Closeable.close() method in order to restore their original state" although I cannot tellw ithout looking at the code what resources it might actually free and what constitutes the "original state".

@remkop
Copy link
Owner

remkop commented Sep 11, 2020

Yes, looking at some Terminal implementations it seems quite important that close is called.
See for example AbstractWindowsTerminal.

Thank you for pointing this out!
I will fix this when I get a chance.

@dwalluck
Copy link
Contributor Author

Yes, looking at some Terminal implementations it seems quite important that close is called.
See for example AbstractWindowsTerminal.

Thank you for pointing this out!
I will fix this when I get a chance.

It seems it is doing quite a bit, thanks! If you want I can make a PR for you for the example. If I remember correctly, you are on Java 1.5, so try-with-resource is not an option.

@remkop
Copy link
Owner

remkop commented Sep 11, 2020

A PR would be really great!

That module (picocli-shell-jline3) is compiled with Java 8 because JLine3 requires Java 8, so actually both the doc and the running example could use try-with-resources.

Thanks as always for your help!

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

No branches or pull requests

2 participants