quickfixj icon indicating copy to clipboard operation
quickfixj copied to clipboard

QFJ-962: `FieldMap.setField(int key, Field<?> field)` does not properly convert values

Open WojciechZankowski opened this issue 6 years ago • 0 comments

I have some concers:

  1. I wasn't really sure how to convert DateField / UtcTimeField / UtcDateField. Check how I did it.
  2. Abstract method convertToString requires changes from users that made custom extensions of Field class. I don't know it is an use case, but it was possible to do.

What I did:

  • I made Field abstract
  • Added abstract method convertToString
  • I added method setField(int, BytesField), but I am not sure about concept with BytesField. I have seen in comments and implementation that we don't convert BytesField into StringField, but for example there is method getField(int)
    StringField getField(int field) throws FieldNotFound {
        final StringField f = (StringField) fields.get(field);
        if (f == null) {
            throw new FieldNotFound(field);
        }
        return f;
    }

So it will fail anytime we would try to access bytes field that was set using one of methods

setField(int, BytesField)
setField(BytesField)
setBytes(int, byte[])

Anyway I wouldn't touch in scope of this defect.

Sorry for commit name and for small formatting changes. I used formatter and I didn't see them.

WojciechZankowski avatar Jul 26 '19 22:07 WojciechZankowski