https://kotlinlang.org logo
#io
Title
# io
e

elect

10/20/2023, 5:11 AM
in
FileHandle
okio, when I use
source().buffer()
shall I close (
use
) only the latter or also the first one?
m

mbonnin

10/20/2023, 9:27 AM
The BufferedSource closes its underlying Source so it's ok to do
Copy code
source.buffer().use {}
👍 1
It'd be nice to add this to the KDocs somewhere, I had the same question
e

elect

10/20/2023, 9:29 AM
next short PR? 😄
m

mbonnin

10/20/2023, 9:31 AM
Maybe here?
e

elect

10/20/2023, 9:31 AM
maybe
m

mbonnin

10/20/2023, 9:32 AM
Another question is whether it's ok to buffer twice the same source. I'm guessing not
e

elect

10/20/2023, 9:32 AM
and/or where it was specified to close the resource
I recall I read that closing twice isn't correct, but won't throw
m

mbonnin

10/20/2023, 9:33 AM
So many questions 😅
😂 2
e

Edoardo Luppi

10/22/2023, 12:56 PM
when I use
source().buffer()
Generally speaking I'd say the concept is the same as buffered resources in Java, just close the buffered one, which internally will take care of the wrapped one.
1