[FAST-7] GroupValue.isDefined should handle undefined fields correctly Created: 24/Oct/08  Updated: 24/Oct/08  Resolved: 24/Oct/08

Status: Resolved
Project: OpenFAST
Component/s: Message Object Model
Affects Version/s: 1.0.0
Fix Version/s: 1.0.1

Type: Improvement Priority: Minor
Reporter: Dale Wilson Assignee: Jacob Northey
Resolution: Fixed Votes: 0
Labels: None
Environment:

WinXP SP3; JavaSE 1.5; OpenFAST from SVN trunk.



 Description   

A call to GroupValue.isDefined giving a field name that is not mentioned in the template used to encode/decode the message results in an IllegalArgumentException. The exception is misleading because the field might be defined when other templates are used to transmit this particular message type. isDefined() should simply return "false" if the field is not declared in the template meaning the field is not included in this instance of the message.

The following stack trace shows an occurrence of this problem:

Exception in thread "main" java.lang.IllegalArgumentException: The field "MDEntryID" does not exist in group MDEntries
at org.openfast.GroupValue.getValue(GroupValue.java:180)
at org.openfast.GroupValue.isDefined(GroupValue.java:329)
at com.oci.trader.marketdata.MarketDataConsumer.processMDEntry(MarketDataConsumer.java:121)
<SNIP>

The field MDEntryID is defined for the Market Data Incremental Refresh message being decoded here (see "FIX 4.4 with Errata 20030618 Volume 3" page 68, but this particular counterparty doesn't this optional field so they omitted it from their template.

--------
Work around:

private boolean fieldPresent(GroupValue groupValue, String fieldName)

{ return groupValue.getGroup().hasField(fieldName) && groupValue.isDefined(fieldName); }
Generated at Sat Nov 23 17:59:37 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.