In general Java it is up to the creator of a "stream" to close it, the same 
applies to Clojure pretty much.

Java has "try with resources" and in Clojure you can use "with-open":

(with-open [rdr (open-the-reader)]
  (edn/read rdr {}))

This will ensure .close is called in a finally block.

HTH,
Thomas

On Friday, September 2, 2016 at 2:24:31 PM UTC+2, John Valente wrote:
>
> Running on Windows, I found that I could not delete an edn file that I had 
> read from.  I've looked at a few examples of reading edn, and none of them 
> seem to suggest that the user code should explicitly call close() on the 
> Java object, or that it needs to use with-open.  Should I be doing 
> something like that?
>
> I wonder why Clojure doesn't call close when it hits EOF:
>
>
> https://github.com/clojure/clojure/blob/c6756a8bab137128c8119add29a25b0a88509900/src/jvm/clojure/lang/EdnReader.java#L134
>
> Maybe it shouldn't be necessary, but it seems safe to me:
>
>
> https://docs.oracle.com/javase/7/docs/api/java/io/PushbackReader.html#close()
>
> I've mostly worked on a Mac, where I haven't had trouble.  This only 
> happened to me on Windows, and only once (so far).  I haven't tried to 
> reproduce it.  It is certainly possible I did something else wrong to cause 
> the file to get into an undeletable state.  Still, it does seem to me it 
> would be safe to have the Clojure Java source code call close(), unless I'm 
> missing something.
>
> Thanks,
> John
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to