So I put more thought into this last night and since TupleStream has an open method it makes try-with-resources not really applicable. In the case here, it will call close twice as implemented. try-with-resources can't be pushed into getTuples since try-with-resources doesn't work with a open method.
Thinking about this brought up the following thoughts:
- What should happen when open is called twice?
- What should happen when close is called twice?
- What should happen when close is called without open being called?
- Are there places in the code where open/close is called without a try/finally? Will that cause issues?
- Are there places in the code where TupleStream.open is called without a related close call?
There are no checks currently to see if a stream has already been opened or closed. This is what is causing the different NPE exceptions like in
For this ticket, I think just implementing Closeable on TupleStream and not changing the tests is appropriate. The above items should be addressed though. This will make the patch smaller and the tests can be improved in followup JIRAS.
Joel Bernstein/Jason Gerlowski - Thoughts on the above?