tototoshi/scala-csv

Resource releasing policy

waagnermann opened this issue · 3 comments

Hi!
Am I right that you close resource only if it is a file?
otherwise (example) you let resource management to users?

Hi @waagnermann .
I believe that the responsibility for closing a resource lies with the person who created it. In this case, the FileInputStream is created internally by scala-csv, so it is scala-csv's responsibility to close it. However, Source or Reader is created by the user of scala-csv, and therefore, the user is responsible for closing it.

you are right about that.
but if a person chooses not to close his resource in order to use it later, another resource, that your library creates here will keep not being closed. is that right?

if so, it enforces the user to remember about this internal resource and close initial resource by means of this method, not the initial resource's .close() method

p.s. cause lineReader created by scala-csv same way as the FileInputStream you mentioned above

@waagnermann
I'm not entirely sure if I fully understand what you're saying, but maybe you are right and I realized that the current code lacks consistency.

I plan to fix this. Could you review the PR once I create it?