Fix unbounded event Hub, System.nanoTime in hooks, integer overflow, and vacuous test assertions#108
Merged
EtaCassiopeia merged 2 commits intoMay 12, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hub.unbounded replaced with Hub.dropping(256)
FeatureFlagsStateusedHub.unboundedfor provider events, growing without limit when subscribers are slow or absent. Replaced withHub.dropping(256)— missing an intermediate event is acceptable since the next evaluation picks up current state.System.nanoTime replaced with Clock.nanoTime in hooks
structuredLoggingandmetricsDetailedhooks calledjava.lang.System.nanoTime()directly inafter/errorcallbacks, bypassing ZIO's Clock and breaking testability with TestClock. Now usesClock.nanoTimeconsistently (matchingbeforewhich already did).ContextConverter integer overflow for large values
valueToAttributeconverted whole-number doubles via.toInt, silently overflowing for values >Int.MaxValue(e.g., Unix timestamps). Now producesLongValuefor values outside Int range.Java hook error callback ClassCastException
wrapJavaHookusedasInstanceOf[Exception]on the error cause, which throwsClassCastExceptionforErrorsubclasses. Now wraps non-ExceptionThrowableinRuntimeException.Registry tapBoth with no-op error arm
FeatureFlagRegistryLive.setProviderusedtapBothwith_ => ZIO.unitas the error handler. Replaced with.tapwhich expresses the intent more clearly.CircuitBreaker.transitionToHalfOpen demotes Closed circuit
The CAS loop's
case _arm matchedClosed, demoting a healthy circuit to half-open. Added explicitcase Closed => done = trueto preserve healthy state.HoconProvider.reload silently serves stale config on failure
If
ConfigFactory.load()threw during reload, provider state stayedREADYwith stale config. Now sets state toERRORon failure andREADYon success.EnvVarProvider dead AtomicReference field
state: AtomicReference[ProviderState]was declared but never updated. ReplacedgetStatewith a directProviderState.READYreturn and removed the unused field.TestFeatureProvider failureProbability accepts invalid values
setFailureProbabilityaccepted values outside [0.0, 1.0] — e.g., 1.5 caused constant failures with no indication why. Values are now clamped to [0.0, 1.0].Vacuous test assertions replaced
Multiple HookSpec tests for logging/structuredLogging had
assertTrue(true)as the only assertion. Now assert thathookDatacontains the expected start time entry, or useassertCompletes.