penberg / falcon

Falcon, the open source ultra low-latency FIX engine for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

about get msg fields in Session.recv()

kuangtu opened this issue · comments

Hi,
In the recv() method(Session.java), parse a step message and get it's fields. The code is below:
while (rxBuf.position() < checksumOffset) {
int tag = Protocol.parseInt(rxBuf, (byte)'=');
ByteString value = Protocol.parseString(rxBuf, (byte)0x01);
fields.add(new Field(tag, value));
}
Maybe there is a bug in while loop:
parseString(ByteBuffer buf, byte delimiter) {
int start = buf.position();
for (;;) {
byte ch = buf.get();
if (ch == delimiter) {
break;
}
}
//buffer's posion is one after delimiter
//the end is pointer to delimiter
int end = buf.position() - 1;
buf.position(start);
return ByteString.of(buf, end-start);
}
after return ,the buffer's postion is pointer to delimiter. If next call parseInt(), the tag is error.
I think it should add rxBuf.get() before fields.add().
And I submit a SessionTest for this. Please check it. Thanks.