Details
Description
The following error occurs when disconnecting the file system where log files are written on:
{quote}
[java] java.lang.StackOverflowError
[java] at java.io.FileOutputStream.writeBytes(Native Method)
[java] at java.io.FileOutputStream.write(FileOutputStream.java:247)
[java] at quickfix.FileLog.writeTimeStamp(FileLog.java:116)
[java] at quickfix.FileLog.writeMessage(FileLog.java:97)
[java] at quickfix.FileLog.onEvent(FileLog.java:111)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:47)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:60)
[java] at quickfix.FileLog.writeMessage(FileLog.java:106)
[java] at quickfix.FileLog.onEvent(FileLog.java:111)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:47)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:60)
[java] at quickfix.FileLog.writeMessage(FileLog.java:106)
[java] at quickfix.FileLog.onEvent(FileLog.java:111)
{quote}
Repro steps:
* Start quickfixj engine using a directory on a removable drive (for instance usb key) as log dir
* Disconnect removable drive while quickfixj engine is running
{quote}
[java] java.lang.StackOverflowError
[java] at java.io.FileOutputStream.writeBytes(Native Method)
[java] at java.io.FileOutputStream.write(FileOutputStream.java:247)
[java] at quickfix.FileLog.writeTimeStamp(FileLog.java:116)
[java] at quickfix.FileLog.writeMessage(FileLog.java:97)
[java] at quickfix.FileLog.onEvent(FileLog.java:111)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:47)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:60)
[java] at quickfix.FileLog.writeMessage(FileLog.java:106)
[java] at quickfix.FileLog.onEvent(FileLog.java:111)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:47)
[java] at quickfix.LogUtil.logThrowable(LogUtil.java:60)
[java] at quickfix.FileLog.writeMessage(FileLog.java:106)
[java] at quickfix.FileLog.onEvent(FileLog.java:111)
{quote}
Repro steps:
* Start quickfixj engine using a directory on a removable drive (for instance usb key) as log dir
* Disconnect removable drive while quickfixj engine is running
I suggest the following patch :
This should prevent StackOverflow error when an exception is raised while logging an exception.
I would also suggest:
This will make sure MessageStore#refresh() is called on logon, so that in case of filesystem failure, file storing sequence numbers is reopen when trying to reconnect. By the way, I did not understood clearly why this method returns false when ConnectionType property is set to Initiator
- In quickfix.FileLog class, writeMessage(FileOutputStream stream, String message, boolean forceTimestamp) method:
This should prevent StackOverflow error when an exception is raised while logging an exception. I would also suggest:- In quickfix.Session class isStateRefreshNeeded(String msgType) method :
This will make sure MessageStore#refresh() is called on logon, so that in case of filesystem failure, file storing sequence numbers is reopen when trying to reconnect. By the way, I did not understood clearly why this method returns false when ConnectionType property is set to Initiator