Repository navigation
AOT: module serializer table for Akka.Persistence (#8626, part 4) - #8695
Merged
Aaronontheweb merged 1 commit intoSep 30, 2026
Merged
Aaronontheweb merged 1 commit into
Aaronontheweb merged 1 commit into
Conversation
…art 4) Adds PersistenceSerializers, covering persistence.conf's two serializers (PersistenceMessageSerializer id 7, PersistenceSnapshotSerializer id 8) and their two bound types (IMessage, Snapshot), to core's module map. Both classes have a single (system) constructor and neither has a serialization-settings block in persistence.conf, so the factory calls that constructor directly for each. PersistenceSerializersSpec mirrors ClusterSerializersSpec/StreamsSerializersSpec: parity against persistence.conf in both directions, Akka.Hosting AQN spelling resolution, an application.conf override, and building under the default config with the switch off, logging no warning, with ids 7/8 resolving to the right classes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 4 of #8626. Follows #8658's module-table pattern (
Akka.Cluster, part 3a; the Cluster contrib family, part 3b) forAkka.Persistence.Changes
PersistenceSerializers(Akka.Persistence.Serialization) is Persistence's firstModuleSerializerstable. It covers everyserializersandserialization-bindingsrow persistence.conf adds toakka.actor:PersistenceMessageSerializer(id 7, aliasakka-persistence-message) andPersistenceSnapshotSerializer(id 8, aliasakka-persistence-snapshot)."Akka.Persistence", passing a type-name literal toLoad.IMessageandSnapshot, exactly as persistence.conf's two binding rows name them.Constructor choices
Both classes have exactly one constructor, and persistence.conf has no
serialization-settingsblock for either alias, so the factory calls the class's only constructor directly:akka-persistence-message(system)akka-persistence-snapshot(system)No public API changes (verified by
Akka.API.Tests, 23 passed). No IVT changes: Akka core already grantsAkka.PersistenceandAkka.Persistence.Testsaccess to its internals, andAkka.Persistencealready grants its ownTestsproject access toPersistenceSerializers.Neither serializer overrides
Identifierin code (#8694, which adds that, isn't merged yet) -- both still resolve their id throughakka.actor.serialization-identifiers, so this table doesn't depend on it.Behavior with the switch on (see Breaking changes below)
Same shape as #8658/#8666, measured against this module:
serialization-settings.<alias>block for either serializer now builds it instead of throwingMissingMethodException, since neither constructor takes aConfig.TargetInvocationException.ConfigurationException.Tests
PersistenceSerializersSpec(Akka.Persistence.Tests) runs in aDynamicTypeLoadingCollection(non-parallel) and derives fromAkkaSpecwithITestOutputHelper, reusingModuleSerializerSpecs(Akka.Tests.Shared.Internals.Xunit3) for the shared checks:AssertTableMatchesConfig-- the table'sSerializers/BoundTypesname exactly the types persistence.conf's rows name.AssertHostingSpellingResolves-- every row, respelled as anAssemblyQualifiedName, still resolves with the switch off.AssertBuildsWithoutWarning-- builds without a warning; ids 7 and 8 map to the right classes.Identifier, for bound samplesAtLeastOnceDeliverySnapshot(anIMessageimplementer) andSnapshot.Snapshot = bytes) takes effect and leaves the other alias alone.All 5 facts pass on 3 repeated runs. The existing Persistence serializer round-trip tests still pass:
dotnet test src/core/Akka.Persistence.Tests -c Release -f net10.0 --filter "FullyQualifiedName~Serializ"-- 18 passed.Mutation checks (done locally, reverted before this PR)
SnapshotfromBoundTypesfails all 5 facts (table-matches-config, and every other check that depends on resolvingSnapshot).typeof(string)) fails 2 of 5 facts (both directions of the table-matches-config check).Validation
dotnet build -c Release -warnaserror: Akka, Akka.Persistence, Akka.Persistence.Tests, Akka.API.Tests -- 0 warnings.PersistenceSerializersSpecpasses on 3 repeated runs.Akka.API.Tests: 23 passed, no API changes.This completes the per-module serializer tables (#8626) needed before plan PR 3 of #8676.
Breaking changes
Akka.Persistence(serialization)PersistenceMessageSerializer,PersistenceSnapshotSerializer) are now built from an internal module table ahead of reflection, withAkka.DynamicTypeLoadingon as well as off. Both classes have a single(system)constructor and noserialization-settingsblock in their shipped config, so each factory calls that constructor directly. With the switch on, two things differ: (1) aserialization-settings.<alias>block for either serializer now builds it instead of throwingMissingMethodException; (2) a constructor exception is no longer wrapped inTargetInvocationException. With the switch off, both rows now resolve instead of throwingConfigurationException. Same mechanism as #8658.MissingMethodExceptionorTargetInvocationExceptionaroundActorSystem.Createfor these two serializers should catch the inner exception type instead.(The shared
BREAKING_CHANGES_V1.6.mdledger itself is not touched by this PR -- it is updated in a separate batch PR.)