PowerSystemDataModel icon indicating copy to clipboard operation
PowerSystemDataModel copied to clipboard

Let Sources and Sinks implement java.io.Closeable

Open ckittl opened this issue 4 years ago • 1 comments

... to remind the user of closing it. This is especially valuable, as those classes extensively make use of instances, that implement the Closeable interface.

ckittl avatar Oct 29 '20 15:10 ckittl

I like this idea, although I think it doesn't make sense in in several implementations at the moment as the sources and sinks work exactly in the way that they only acquire resources they on request. E.g. take https://github.com/ie3-institute/PowerSystemDataModel/blob/61894db5ff9bffa641eaab8567e51c7d9399d8b6/src/main/java/edu/ie3/datamodel/io/source/csv/CsvDataSource.java#L371 as an example. Here we're using the AutoCloseable interface in the source itself such that there is no real need to close the source after executing a read operation, as the source automatically takes care of this.

After taking a brief look over the code, I didn't found any place in which this would really make a benefit bc all resources of sources and sinks are released automatically. Would you mind point out the places where this would be beneficial bc resources are not released?

johanneshiry avatar Nov 06 '20 12:11 johanneshiry