I ran into a situation where verifyBeforeRead="true" with first frame byte being the size field and last frame byte being a checksum led to the checksum being calculated over all received bytes, rather that all bytes of a frame excluding the checksum byte.
This may or may not be how you expect it to behave - it wasn't what I expected though, as it makes very little sense to me to calculate the checksum if you haven't read the size field. I can think of two possible improvements:
- try to read the size and then calculate checksum,
- Add some verbage to the 'verifyBeforeRead' documentation along these lines:
- verifyBeforeRead can be dangerous: verifyBeforeRead="true" causes a checksum calculation across all received bytes prior to evaluation of the 'size' layer. If you may receive multiple frames consecutively(, or partial frames ?), this can lead to frames being discarded.
I ran into a situation where verifyBeforeRead="true" with first frame byte being the size field and last frame byte being a checksum led to the checksum being calculated over all received bytes, rather that all bytes of a frame excluding the checksum byte.
This may or may not be how you expect it to behave - it wasn't what I expected though, as it makes very little sense to me to calculate the checksum if you haven't read the size field. I can think of two possible improvements: