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
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.
Description
ResolverChaincurrently contains both circular-reference detection and circular-reference handling. ThehandleCircularReferencemethod decides whether to returnnullor throwSomeCircularReferenceExceptionbased onNullableStrategy. This couples the core resolution chain with nullable-specific strategy behavior.The goal is to simplify
ResolverChainso it only detects circular references and always throwsSomeCircularReferenceException.NullableResolverwill then catch the exception when resolving non-null instances and decide whether to returnnullbased on the activeNullableStrategy.Scope and constraints
ResolverChainmust retaindetectCircularReferenceand the resolution stackResolverChainmust no longer receiveNullableStrategyvia its constructorNullableResolvermust handleSomeCircularReferenceExceptionwhen resolving non-null valuesSomeCircularReferenceExceptionReferences
src/main/kotlin/dev/appoutlet/some/core/ResolverChain.ktsrc/main/kotlin/dev/appoutlet/some/resolver/NullableResolver.ktsrc/main/kotlin/dev/appoutlet/some/Some.ktScope
In scope:
handleCircularReferenceandnullableStrategyfromResolverChainResolverChainto always throwSomeCircularReferenceExceptionon circular referencesNullableResolverto catchSomeCircularReferenceExceptionand decide whether to returnnullor re-throw based on the activeNullableStrategySome.ktandTestHelpers.ktto stop passingNullableStrategytoResolverChainOut of scope:
NullableStrategyvariantsResolverChainAcceptance criteria
ResolverChainno longer containshandleCircularReferencemethodResolverChainno longer acceptsnullableStrategyas a constructor parameterResolverChainthrowsSomeCircularReferenceExceptionfor all detected circular referencesNullableResolvercatchesSomeCircularReferenceExceptionwhen callingchain.resolve(nonNullType)and decides whether to returnnullor re-throw based on the activeNullableStrategySome.ktandTestHelpers.ktno longer passNullableStrategytoResolverChainCircularReferenceIntegrationTestAdditional information
The current implementation short-circuits in
ResolverChain.resolve()before resolvers are invoked when a circular reference is detected. After this refactor,ResolverChainshould detect and throw for all circular references, whileNullableResolverhandles the exception when resolving non-null values for nullable types.