Listener feature completed #3

wants to merge 5 commits into


None yet

2 participants


Listener is open for basic dependency injection for tests and the reader is closed at program exit. Updated To-Do and feature lists to reflect changes.


This is incorrect. You're creating a new instance and then closing the reader that belongs to that one, not the one you used to populate the String userInput. If you explore some profiling tools, you should be able to diagnose a memory leak and see that you've nicely written a virus. :)

What you need to do is retain an instance of the original listener you create to get the user's input string (as opposed to getting a new one every time) and then call closeListener on that original instance.

Remember that object creation is expensive and needs to be carefully managed.


You should hang on to the reference of the Listener you create and keep calling getInput() on that one, not create a new one every time.

Listener inputGrabber = Listener.create();
String firstInput = inputGrabber.getInput();
String secondInput = inputGrabber.getInput();


This isn't quite there. Clean up the issues in the comments.

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