[QFJ-406] No way for FileStore to be closed Created: 27/Feb/09  Updated: 15/Nov/12  Resolved: 06/Apr/10

Status: Closed
Project: QuickFIX/J
Component/s: None
Affects Version/s: 1.4.0
Fix Version/s: 1.5.0

Type: Improvement Priority: Default
Reporter: Jerry Shea Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Windows XP sp3, Java 6


Attachments: Text File 406.patch    
Issue Links:
Duplicate
duplicates QFJ-224 Automatically close logs and message ... Closed

 Description   

If I create a ThreadedSocketInitiator with a FileStoreFactory, start, stop and re-start it, I get the following in stderr:

File delete failed: ...\FIX.4.2-xxx.header
File delete failed: ...\FIX.4.2-xxx.body
File delete failed: ...\FIX.4.2-xxx.seqnums

This seems to be because ThreadedSocketInitiator gets a new FileStore from FileStoreFactory which then locks files (for example - initializeMessageIndex opens a FileOutputStream for the header file).

When I stop the initiator this FileStore is never closed - the FileStore doesn't actually have any kind of close or dispose method.

When I restart the initiator it gets a new FileStore which barfs with the above errors when it can't delete the files.

I'm happy to work up a patch for this but would appreciate some guidance as to what the commiters think should close the FileStore.



 Comments   
Comment by Jörg Thönnes [ 27/Feb/09 ]

In reply to QFJ-406:
> I'm happy to work up a patch for this but would appreciate some guidance as to
> what the commiters think should close the FileStore.

Would be great if you could suggest patches. Looking at the FileStore, there are already internal methods to close the files.
But these methods are called on initialize, since there is no MessageStore API method to close it.

Could you also suggest how to extend the MessageStore API to provide a close() method and more important where in the QF/J code you would call this method?

Thanks, Jörg

Comment by Steve Bate [ 03/Mar/09 ]

One approach is to create an interface for objects to listen to Connector start/stop events. The Connector implementations could automatically register stores or logs as listeners if they implement that interface.

Comment by Jerry Shea [ 03/Mar/09 ]

Hi Steve,
unfortunately the Connector does have access to, for example, message stores. It passes a MessageStoreFactory to the Session which creates a MessageStore when invoking the SessionState constructor, which keeps a handle to the message store.
The way I've implemented this initially is to add a close method to Session, SessionState, and MessageStore (and impls.) and modified SessionConnector.logoutAllSessions to call Session.close, which calls SessionState.close which calls MessageStore.close. I could add a close method to Log and all impls. too and call this in the same place? (as I use SLF4JLog I haven't noticed any issues with logs remaining open).
This solution solves my problem but I'm happy for suggestions or changes to the code to be made.
Cheers, Jerry

Comment by Jerry Shea [ 15/Jun/09 ]

Guys, is there any chance we could get this change assigned to 1.4.1 release? Let me know if there's anything else I can do to help this along

Comment by Steve Bate [ 06/Apr/10 ]

This will be worked under the original QFJ-224 issue.

Generated at Sun May 05 11:53:59 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.