Although this is technically two different bug reports, they are very closely related, and should probably be tested / fixed together, so I'm reporting them both here... hope that's okay
Both qpid::messaging::decode functions can assert, or throw an unexpected qpid::framing::IllegalArgumentException on invalid input.
Consider the following code fragment:
In that example, the qpid::messaging::decode function will result in an assertion in qpid::framing::Buffer::getLong as that function assumes / requires the buffer to be at least 4 bytes. Clearly in this case the decode should fail, but ideally it should fail in a catchable way, not an assertion.
I would think the right solution would be to add a minimum size check to the qpid::framing::FieldTable::decode function. But it could also be solved by adding the size check to the qpid::messaging::decode and/or qpid::framing::Buffer::getLong functions.
As a temporary workaround, client code can add a size check before the decode call, like:
But now if we extend the message a little, so that it is at least 4 bytes long like so:
Then we run into a second problem. In that case, the "done" line is still not reached, because a qpid::framing::IllegalArgumentException is thrown in qpid::framing::FieldTable::decode with message "Not enough data for field table.". However, this exception type is not listed in the documentation for the qpid::messaging::decode function - the documentation only mentions EncodingException, and the two share no common ancestry until right back at std::exception.
Although one solution might be just to add IllegalArgumentException to the documentation, I suspect a preferable solution would be to catch the IllegalArgumentException in qpid::messaging::decode and re-throw it as an EncodingException like:
A quick code review shows that qpid::framing::FieldTable::decode (and thus qpid::messaging::decode) can also throw the OutOfBounds exception, which, like IllegalArgumentException, descends from qpid::Exception. So a final solution might look something like:
|Transition||Time In Source Status||Execution Times||Last Executer||Last Execution Date|
|2d 3h 21m||1||Gordon Sim||24/Aug/11 15:43|
|179d 19h 31m||1||Paul Colby||20/Feb/12 10:15|
|Status||Resolved [ 5 ]||Closed [ 6 ]|
|Status||Open [ 1 ]||Resolved [ 5 ]|
|Fix Version/s||0.13 [ 12316854 ]|
|Resolution||Fixed [ 1 ]|
|Field||Original Value||New Value|
|Assignee||Gordon Sim [ gsim ]|