Repository navigation
Move circular reference handling from ResolverChain to NullableResolver #61
Description
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
ResolverChainmust retaindetectCircularReferenceand the resolution stackResolverChainmust no longer receiveNullableStrategyvia its constructorNullableResolvermust handleSomeCircularReferenceExceptionwhen 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.ktsrc/main/kotlin/dev/appoutlet/some/resolver/NullableResolver.ktsrc/main/kotlin/dev/appoutlet/some/Some.kt
Scope
In scope:
- Removing
handleCircularReferenceandnullableStrategyfromResolverChain - Updating
ResolverChainto always throwSomeCircularReferenceExceptionon circular references - Updating
NullableResolverto catchSomeCircularReferenceExceptionand decide whether to returnnullor re-throw based on the activeNullableStrategy - Updating
Some.ktandTestHelpers.ktto stop passingNullableStrategytoResolverChain
Out of scope:
- Changing the behavior of
NullableStrategyvariants - Changing the circular-reference detection algorithm in
ResolverChain
Acceptance criteria
-
ResolverChainno longer containshandleCircularReferencemethod -
ResolverChainno longer acceptsnullableStrategyas a constructor parameter -
ResolverChainthrowsSomeCircularReferenceExceptionfor all detected circular references -
NullableResolvercatchesSomeCircularReferenceExceptionwhen callingchain.resolve(nonNullType)and decides whether to returnnullor re-throw based on the activeNullableStrategy -
Some.ktandTestHelpers.ktno longer passNullableStrategytoResolverChain - 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.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
MessiasLima commentedon Sep 21, 2026
The circular reference check happens before getting on the NullableResolver. so the approach suggested on this ticket does not make sense