JSON-java icon indicating copy to clipboard operation
JSON-java copied to clipboard

JSONTokener should implement java.io.Closeable

Open jtotht opened this issue 2 years ago • 9 comments

While JSONTokener(java.io.Reader) and JSONTokener(java.io.InputStream) constructors have explicit notes about JSONTokener not closing the reader/stream, I’d like to have it close the reader/stream. Implementing java.io.Closeable isn’t backward-incompatible (if the library user doesn’t explicitly close it, nothing happens), and for those who use try-with-resources construct, having to keep a separate reference for the reader/stream is a pain. Although try-with-resources itself is Java 7+, the java.io.Closeable interface is @since 1.5, so implementing the interface can be done without losing Java 6 compatibility.

jtotht avatar Jan 28 '23 13:01 jtotht