Re: Problem disposing java objects

2018-09-03 Thread aboy021
Sorted!

Thank you.


On Monday, 3 September 2018 17:32:15 UTC+12, Alexander Yakushev wrote:
>
> I suspect the problem is with map which is lazy. If you discard the 
> result of the top-level expression it might not be fully completed or not 
> even run at all.
>
> To force a lazy collection (thus, triggering the side effects you desire) 
> you could do the following things:
>
> (mapv close pages)  ;; mapv returns a vector, thus is eager
> (dorun (map close pages))   ;; dorun walks the lazy collection and forces 
> the side effects
> (run! close pages)  ;; run! is like map for side effects - 
> preferred in this case
>
> On Monday, September 3, 2018 at 5:44:38 AM UTC+3, aboy021 wrote:
>>
>> I have a problem related to disposing of resources.
>>
>> I’m trying to retrieve portions of pdf files and combine them into a new 
>> pdf file. I’m using Apache PDFBox for the purpose.
>> Splitting a pdf into pages creates a PDDocument for each page, and 
>> PDDocuments need to be explicitly closed. If you do not, there’s a log 
>> message that comes from the finalizer “Warning: You did not close a PDF 
>> Document”.
>>
>> I’ve prepared some naive code that demonstrates the problem. Here I’m 
>> splitting a pdf and recombining it. When the finalizer eventually runs 
>> every page in the pdf seems to produce an error message.
>>
>> [org.apache.pdfbox/pdfbox "2.0.11"]
>>
>> (import '[org.apache.pdfbox.multipdf PDFMergerUtility])(import 
>> '[org.apache.pdfbox.multipdf Splitter])(import '[org.apache.pdfbox.pdmodel 
>> PDDocument])
>> (let [pdf (PDDocument/load (File. "input.pdf"))
>>   splitter (Splitter.)
>>   pages (into [] (.split splitter pdf))
>>   merger (PDFMergerUtility.)
>>   append (fn [x y] (.appendDocument merger x y) x)
>>   close #(when % (.close %))]
>>   (try
>> (-> (reduce append (first pages) (rest pages))
>> (.save "output.pdf")
>> (close))
>> (finally
>>   (close pdf)
>>   (map close pages
>>
>> Any help would be appreciated.
>>
>> Also, are there any good resources online for best practice in dealing 
>> with sequences of disposables?
>>
>> Thanks,
>>
>> Arthur
>> ​
>>
>

-- 
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.


Re: [ANN] nREPL 0.4.5 released!

2018-09-03 Thread Lars Rune Nøstdal
Hi,
I still get this when I do `cider-jack-in`: 
   ;; CIDER 0.18.0 (package: 20180902.1638) (Saigon), nREPL 0.2.13


..I've removed all mentions of "nrepl" in package.clj, but it seems lein (I 
think?) still loads the old 0.2.13 version.

Thanks for your work on this stuff by the way; it's fantastic!

mvh,
Lars

-- 
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.


core.async pipeline bug?

2018-09-03 Thread Paul Rutledge
Hi all,

I've been using the 'pipeline' function in core.async and the docstring 
says that the 'from' channel won't be consumed anymore after the 'to' 
channel is closed (since you probably don't care anymore). In reality, I'm 
finding that my 'from' channel is still being taken from and the pipeline 
transducer continues to execute long after I've closed the 'to' channel. Am 
I misunderstanding the stated behavior or is this a bug? I'm using the 
latest version (0.4.474). If someone can confirm this is an issue I'm happy 
to create a jira ticket and attempt a patch.

Minimal example here: 
https://gist.github.com/RutledgePaulV/6ddb7b29578de4442cd8d946885c38a8

Thanks,
Paul

-- 
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.