[QFJ-162] Weekly session fails on Sundays Created: 19/Apr/07  Updated: 20/Feb/10  Resolved: 20/Feb/10

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.0.5
Fix Version/s: 1.2.0

Type: Bug Priority: Critical
Reporter: Christian Braeuner Assignee: Steve Bate
Resolution: Fixed Votes: 0
Labels: None
Environment:

Unix Sun JVM 1.4.2_06 and XP Sun JVM 1.6.0_01


Attachments: File SessionSchedule.java    
Issue Links:
Relates
is related to QFJ-142 Weekday session schedule and default ... Closed

 Description   

When the weekly Session starts on a Sunday, the QF engine resets but does not start at the configured time.
This is quite a serious error for Reuters because the bug has made it into our production system because production has a different Schedule than development. The production system now needs to be started manually with temporary config changes every Sunday evening until we can deploy a fix.

The SessionSchedule class has a bug in TimeInterval.theMostRecentIntervalBefore() when the start or end date is a Sunday. The following code is making the wrong assumptions:
if (startTime.getDay() != -1) {
startCal.set(Calendar.DAY_OF_WEEK, startTime.getDay());
}
This code and the equivalent for endCal assume that the calendar moves backward if startTime is less than the current setting and moves forward if startTime is later than the current setting. I.e. if startCal is Wednesday=4 then the calendar would move back if set to Sunday=1 and forward if set to Friday=5. This is not the always the case and depends on Calendar.getFirstDayOfWeek(). In our case the first day of the week is Monday=2. So for example when the current date is Thu Apr 19 and the session starts on Sunday, then startCal(Calendar.DAY_OF_WEEK, 1) is not moving backwards to Sun 15 Apr, but forwards to Sun 22 Apr, because the week is 2,3,...,6,7,1. This is then returning the wrong interval and prevents the adapter from starting up.

The fix is to insert startCal.setFirstDayOfWeek(1) and endCal.setFirstDayOfWeek(1) at the appropiate lines in this method.

Regards,
Christian



 Comments   
Comment by Steve Bate [ 19/Apr/07 ]

Thanks for the report. Is it possible to provide a patch file? You can attach it to the issue.

Comment by Christian Braeuner [ 19/Apr/07 ]

Added 2 lines to correct scheduling bug:
151:startCal.setFirstDayOfWeek(1);
173:endCal.setFirstDayOfWeek(1);

Comment by Steve Bate [ 19/May/07 ]

I've added tests and, by default, I'm running the unit test in a non-US locale to help catch these problems earlier in the future.

Comment by Steve Bate [ 20/Feb/10 ]

Reopening to remove spam comment

Generated at Sat Nov 23 07:41:57 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.