Skip to content

fix: RejectOnType<TMessage> should use Rejection, not Failure - #8231

Merged
Aaronontheweb merged 3 commits into
akkadotnet:v1.5from
Aaronontheweb:fix/reject-ontype
Jun 3, 2026
Merged

Aaronontheweb merged 3 commits into
akkadotnet:v1.5from
Aaronontheweb:fix/reject-ontype

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Description

Fixes a copy-paste bug in JournalWriteBehavior.cs where RejectOnType<TMessage>() was calling FailOnType(typeof(TMessage)) instead of RejectOnType(typeof(TMessage)).

This caused the test journal to fail/crash instead of rejecting messages of the specified type, defeating the purpose of the RejectOnType<T>() API.

Changes

  • RejectOnType<TMessage>() now delegates to RejectOnType(Type) which correctly uses JournalInterceptors.Rejection.Instance

Impact

This is a test kit fix only — it affects Akka.Persistence.TestKit which is used in unit/integration tests. No production code changes.

The generic RejectOnType<TMessage>() was incorrectly calling FailOnType,
causing the journal to crash instead of rejecting. Fixed to delegate
to RejectOnType(Type) which uses the correct Rejection interceptor.
- RejectOnType<TMessage>() should reject matching types, not fail
- Non-matching types should still pass through normally
- This prevents the bug where RejectOnType<T>() was calling FailOnType

Closes akkadotnet#8231
- PersistActor.WriteMessage.Data changed from string to object to support typed messages
- RejectOnType<T> matching types are rejected (not failed)
- RejectOnType<T> non-matching types pass through normally

Fixes the bug where RejectOnType<TMessage>() was calling FailOnType instead of RejectOnType(Type)
@Aaronontheweb
Aaronontheweb enabled auto-merge (squash) June 3, 2026 05:42
@Aaronontheweb
Aaronontheweb merged commit 7d04bb4 into akkadotnet:v1.5 Jun 3, 2026
11 checks passed
Aaronontheweb added a commit that referenced this pull request Jun 3, 2026
…#8232)

* fix: RejectOnType<TMessage> should use Rejection, not Failure

The generic RejectOnType<TMessage>() was incorrectly calling FailOnType,
causing the journal to crash instead of rejecting. Fixed to delegate
to RejectOnType(Type) which uses the correct Rejection interceptor.

* test: add regression tests for RejectOnType<T>()

- RejectOnType<TMessage>() should reject matching types, not fail
- Non-matching types should still pass through normally
- This prevents the bug where RejectOnType<T>() was calling FailOnType

Closes #8231

* test: add regression tests for RejectOnType<T>()

- PersistActor.WriteMessage.Data changed from string to object to support typed messages
- RejectOnType<T> matching types are rejected (not failed)
- RejectOnType<T> non-matching types pass through normally

Fixes the bug where RejectOnType<TMessage>() was calling FailOnType instead of RejectOnType(Type)
@Aaronontheweb
Aaronontheweb deleted the fix/reject-ontype branch June 12, 2026 16:06
@Aaronontheweb Aaronontheweb added this to the 1.5.69 milestone Jun 12, 2026
This was referenced Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant