Skip to content

about get msg fields in Session.recv() #13

@kuangtu

Description

@kuangtu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions