AxonFramework/AxonFramework — pull request #98 by hovenko (2013-09-26 13:37:57+00:00)
Title: Close FileInputStream after event stream read

FIX: AXON-184 FileInputStream passed into FileSystemBufferedReaderDomainEventStream is not closed after reading

FileSystemEventStore.readEvents(..) returns a FileSystemBufferedReaderDomainEventStream which is backed by a FileInputStream. This FileInputStream is never closed.

This becomes a problem when running integration tests on Windows (yes, some developers actually prefer this), where we want to delete the event store on disk after tests are finished running.

A possible solution will be to make FileSystemBufferedReaderDomainEventStream Closeable and to close it after the DomainEventStream is read.

I have made a patch that alters 3 Java files and adds a new utility class. I changed FileSystemBufferedReaderDomainEventStream to implement Closeable, and added functions to call close on DomainEventStream instances that also implements the Closeable interface. Since there are many DomainEventStream implementations out there (possibly also custom ones, not just in the axonframework libraries), I landed on this runtime detection of Closeable capability.