squah-confluent commented on PR #22264:
URL: https://github.com/apache/kafka/pull/22264#issuecomment-4445243062
Thanks for the patch! I'm not comfortable with catching `RuntimeException`
as it's very broad (it makes me wonder why we don't do an `Exception` or
`Throwable` catch-all?).
I'd be in favor of fixing this at a deeper level. We don't have a
well-defined idea of the exceptions that deserialization can throw (and there's
no javadoc documenting the exceptions either). In testing, we can get
`SchemaException`, `RuntimeException` and `IllegalArgumentException` all for
truncated inputs. I think all these should be `SchemaException`s wrapping
`BufferUnderflowException`s. This is a bigger change to the serialization
codegen and it's hard to tell if we rely on it throwing `RuntimeException`s
anywhere, through catch blocks for example (I haven't checked yet).
`non-nullable field was serialized as null` should also be a `SchemaException`
in my opinion.
<details>
<summary>Subscription v3 (len=67)</summary>
| Truncated length | exception |
|---|---|
| 0–1 | `SchemaException: Buffer underflow while parsing consumer protocol's
header` |
| 2–5 | `SchemaException: Buffer underflow while parsing consumer protocol's
subscription` |
| 6–7 | `RuntimeException: Tried to allocate a collection of size 2, but
there are only {0,1} bytes remaining.` |
| 8–10 | `RuntimeException: Error reading byte array of 3 byte(s): only
{0,1,2} byte(s) available` |
| 11–12 | `SchemaException: Buffer underflow while parsing consumer
protocol's subscription` |
| 13–15 | `RuntimeException: Error reading byte array of 3 byte(s): only
{0,1,2} byte(s) available` |
| 16–19 | `SchemaException: Buffer underflow while parsing consumer
protocol's subscription` |
| 20–24 | `IllegalArgumentException: newLimit > capacity: (5 > {0,1,2,3,4})`
|
| 25–28 | `SchemaException: Buffer underflow while parsing consumer
protocol's subscription` |
| 29–30 | `RuntimeException: Tried to allocate a collection of size 2, but
there are only {0,1} bytes remaining.` |
| 31–33 | `RuntimeException: Error reading byte array of 3 byte(s): only
{0,1,2} byte(s) available` |
| 34–37 | `SchemaException: Buffer underflow while parsing consumer
protocol's subscription` |
| 38 | `RuntimeException: Tried to allocate a collection of size 1, but
there are only 0 bytes remaining.` |
| 39–43 | `SchemaException: Buffer underflow while parsing consumer
protocol's subscription` |
| 44–46 | `RuntimeException: Error reading byte array of 3 byte(s): only
{0,1,2} byte(s) available` |
| 47–50 | `SchemaException: Buffer underflow while parsing consumer
protocol's subscription` |
| 51 | `RuntimeException: Tried to allocate a collection of size 1, but
there are only 0 bytes remaining.` |
| 52–60 | `SchemaException: Buffer underflow while parsing consumer
protocol's subscription` |
| 61–66 | `RuntimeException: Error reading byte array of 6 byte(s): only
{0..5} byte(s) available` |
| 67 | OK |
</details>
<details>
<summary>Assignment v0–v3 (len=41)</summary>
| Truncated length | exception |
|---|---|
| 0–1 | `SchemaException: Buffer underflow while parsing consumer protocol's
header` |
| 2–5 | `SchemaException: Buffer underflow while parsing consumer protocol's
assignment` |
| 6–7 | `RuntimeException: Tried to allocate a collection of size 2, but
there are only {0,1} bytes remaining.` |
| 8–10 | `RuntimeException: Error reading byte array of 3 byte(s): only
{0,1,2} byte(s) available` |
| 11–14 | `SchemaException: Buffer underflow while parsing consumer
protocol's assignment` |
| 15 | `RuntimeException: Tried to allocate a collection of size 1, but
there are only 0 bytes remaining.` |
| 16–20 | `SchemaException: Buffer underflow while parsing consumer
protocol's assignment` |
| 21–23 | `RuntimeException: Error reading byte array of 3 byte(s): only
{0,1,2} byte(s) available` |
| 24–27 | `SchemaException: Buffer underflow while parsing consumer
protocol's assignment` |
| 28 | `RuntimeException: Tried to allocate a collection of size 1, but
there are only 0 bytes remaining.` |
| 29–35 | `SchemaException: Buffer underflow while parsing consumer
protocol's assignment` |
| 36–40 | `IllegalArgumentException: newLimit > capacity: (5 > {0,1,2,3,4})`
|
| 41 | OK |
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]