Skip to content

IncludeHandlers does not filter stream request handlers #52

@ngcsontrh

Description

@ngcsontrh

While working on a project that uses DispatchR with a limited handler set, I noticed an issue with handler registration.

In this project, one service only needs to register two handlers, so DispatchR is configured with IncludeHandlers, and I expected DispatchR to register only those handlers from the assembly. However, stream request handlers from the same assembly were still being registered.

After checking the registration logic, it looks like IncludeHandlers / ExcludeHandlers are only applied to concrete IRequestHandler<,> implementations. Concrete IStreamRequestHandler<,> implementations are included through otherHandlerTypes, so they bypass IsHandlerIncluded(...).

This causes applications that intentionally register only a small subset of handlers to pull unrelated stream handlers into DI. In my case, the service started requiring dependencies for handlers it does not use.

The expected behavior is that IncludeHandlers / ExcludeHandlers should apply to both:

  • concrete IRequestHandler<,>
  • concrete IStreamRequestHandler<,>

Pipeline and notification discovery should remain unchanged.

I opened a PR with a fix here: #51

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions