pjfanning opened a new pull request, #3751: URL: https://github.com/apache/pekko/pull/3751
### Motivation Since #3495, `Serialization.deserialize(bytes, 0, manifest)` with a non-empty manifest returns `Success(null)`, whatever the bytes contain. Id 0 is a common default for a missing int value, so a corrupt stored record can load as a `null` payload instead of failing, and callers that rely on a failure to fall back never get one. ### Modification - `NullSerializer.fromBinary` throws `NotSerializableException` for non-empty input. `toBinary` only ever produces an empty array, so such input cannot have come from this serializer. - Document the behaviour of serializer id 0 in `serialization.md`. ### Result | Call with serializer id 0 | Before | After | |---|---|---| | garbage bytes, `"not-a-class"` manifest | `Success(null)` | `Failure(NotSerializableException)` | | garbage bytes, `""` manifest | `Success(null)` | `Failure(NotSerializableException)` | | `deserializeByteBuffer` with garbage bytes | returns `null` | throws `NotSerializableException` | | empty bytes (a real serialized `null`) | `null` | `null` (unchanged) | #3495 stays in place and no class loading is added. This also closes the older empty-manifest path, so anything relying on id 0 discarding non-empty input now gets a failure. That needs a line in the 2.0.1 release notes. Id 0 with empty bytes and a non-empty manifest still returns `Success(null)`. The issue doesn't ask to change this, and rejecting it would need a check in `Serialization` rather than in the serializer. ### Tests - `sbt "actor-tests/testOnly org.apache.pekko.serialization.*"`: 171 passed. The new rejection test failed before the fix. - `sbt "remote/testOnly org.apache.pekko.remote.classic.transport.PekkoProtocolSpec org.apache.pekko.remote.artery.ActorSelectionQueueDistributionSpec"`: 25 passed (these build messages with serializer id 0). - `sbt actor/mimaReportBinaryIssues`: no issues. - `scalafmt --mode diff-ref=upstream/main` and `git diff --check`: run. - `sbt docs/paradox`: not run locally, left to CI. - Scala 3 and the full test matrix: not run locally, left to CI. ### References Fixes #3749 -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
