[QFJ-261] Date/time field constructors use current time by default Created: 26/Oct/07  Updated: 15/Jan/08  Resolved: 22/Dec/07

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.3.0
Fix Version/s: 1.3.1

Type: Improvement Priority: Default
Reporter: Qiyan Li Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

The TransactionTime() constructor in version 1.2.1 used to return a TransactionTime with the current system time in it, and this has changed in the 1.3.0 where the time of the first call to this constructor is returned. Is this intentional? There's no Javadocs, so I can't tell for sure.

If this is not intentional, the problem lies with the createDate() method of quickfix.DateField.java:

private static Date createDate() {
synchronized (calendar)

{ return calendar.getTime(); }

}

where calendar is also static.



 Comments   
Comment by Toli Kuznets [ 26/Oct/07 ]

Qiyan

I think that this is a bug as well - i brought it up in an email thread http://www.nabble.com/No-arg-constructor-for-DateFields-tf4577998.html#a13068511 , but then ended up coding around it and, unfortunately, never followed up.

Essentially, due to teh fact that the calendar in DateField is static, the times are cached so code like this ends up getting the same time value for both fields:
Message msg = new Message();
msg.setField(new TransactTime());
sleep(20 seconds)
msg.setField(new SendingTime());

Comment by Qiyan Li [ 26/Oct/07 ]

I have worked around the problem, but the real problem is that the semantics of the default constructor changed between releases. This can cause problems to code relying on backward compatibility.

Comment by Steve Bate [ 22/Dec/07 ]

Modified the default constructor of the DateField object to use new Date().

Generated at Sat Nov 23 10:25:33 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.