Skip to content

Move circular reference handling from ResolverChain to NullableResolver #61

Closed

Description

@MessiasLima

Description

ResolverChain currently contains both circular-reference detection and circular-reference handling. The handleCircularReference method decides whether to return null or throw SomeCircularReferenceException based on NullableStrategy. This couples the core resolution chain with nullable-specific strategy behavior.

The goal is to simplify ResolverChain so it only detects circular references and always throws SomeCircularReferenceException. NullableResolver will then catch the exception when resolving non-null instances and decide whether to return null based on the active NullableStrategy.

  • Scope and constraints

    • ResolverChain must retain detectCircularReference and the resolution stack
    • ResolverChain must no longer receive NullableStrategy via its constructor
    • NullableResolver must handle SomeCircularReferenceException when resolving non-null values
    • Non-nullable circular references must still throw SomeCircularReferenceException
    • All existing tests must continue to pass
  • References

    • src/main/kotlin/dev/appoutlet/some/core/ResolverChain.kt
    • src/main/kotlin/dev/appoutlet/some/resolver/NullableResolver.kt
    • src/main/kotlin/dev/appoutlet/some/Some.kt

Scope

In scope:

  • Removing handleCircularReference and nullableStrategy from ResolverChain
  • Updating ResolverChain to always throw SomeCircularReferenceException on circular references
  • Updating NullableResolver to catch SomeCircularReferenceException and decide whether to return null or re-throw based on the active NullableStrategy
  • Updating Some.kt and TestHelpers.kt to stop passing NullableStrategy to ResolverChain

Out of scope:

  • Changing the behavior of NullableStrategy variants
  • Changing the circular-reference detection algorithm in ResolverChain

Acceptance criteria

  • ResolverChain no longer contains handleCircularReference method
  • ResolverChain no longer accepts nullableStrategy as a constructor parameter
  • ResolverChain throws SomeCircularReferenceException for all detected circular references
  • NullableResolver catches SomeCircularReferenceException when calling chain.resolve(nonNullType) and decides whether to return null or re-throw based on the active NullableStrategy
  • Some.kt and TestHelpers.kt no longer pass NullableStrategy to ResolverChain
  • All existing tests pass, including CircularReferenceIntegrationTest

Additional information

The current implementation short-circuits in ResolverChain.resolve() before resolvers are invoked when a circular reference is detected. After this refactor, ResolverChain should detect and throw for all circular references, while NullableResolver handles the exception when resolving non-null values for nullable types.

Activity

  1. added this to the next milestone on Sep 17, 2026
  2. moved this from Ready to In progress in Someon Sep 18, 2026
  3. moved this from In progress to Ready in Someon Sep 18, 2026
  4. moved this from Ready to In progress in Someon Sep 18, 2026
  5. moved this from In progress to Ready in Someon Sep 18, 2026
  6. moved this from Ready to In progress in Someon Sep 18, 2026
  7. MessiasLima commented on Sep 21, 2026

    @MessiasLima
    OwnerAuthor

    The circular reference check happens before getting on the NullableResolver. so the approach suggested on this ticket does not make sense

  8. moved this from In progress to Done in Someon Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem rightwontfixThis will not be worked on

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions