Description
Describe the bug
According to the docs, Avro.decodeFromByteArray
can only throw SerializationException
and IllegalArgumentException
.
However, when testing with some malformatted input data, I came accross two cases where other exceptions were thrown:
- UnsupportedOperationException: cannot read strings longer than 2147483639 bytes
- AvroRuntimeException: Malformed data. Length is negative: -62
These seem to be normal deserialization exceptions, where some data is interpreted as lengths etc.
All exceptions due to a malformatted input should result in a SerializationException
(which I think is the intended exception in the design of the library).
To Reproduce
Experiment with some random data.
If needed, I can try to give some examples.
But regarding the exception messages provided above, it should probably be straight-forward to find the place where they are thrown.
It'll probably be a good idea to add some randomized tests, which call decoding with randomized bytes, to see whether the right exceptions are thrown.
Expected behavior
SerializationException
should be throw for all deserialization-caused exceptions.
Desktop (please complete the following information):
- Kotlin version: 2.1.0
- Avro4k version: 2.1.1
- Other kotlinx-version: 1.8.0
Activity