Skip to content

Commit dec9450

Browse files
committed
fix: Skip building FDv1 fallback factory list when no FDv1 synchronizer is configured
FDv2DataSystem.Create unconditionally constructed a one-entry list with FactoryWithContext(clientContext)(dataSystemConfiguration.FDv1FallbackSynchronizer). When FDv1FallbackSynchronizer was null this still produced a non-null SourceFactory delegate that captured the null configurer. The OUTER composite would then add a phantom FDv1 fallback entry; the moment an action applier advanced to it the entry's factory invocation would NullReferenceException inside FactoryWithContext. Build the list as empty when no FDv1 fallback is configured, so the OUTER composite simply has no FDv1 fallback entry and the data system halts cleanly per the spec.
1 parent 1e0e4a3 commit dec9450

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

pkgs/sdk/server/src/Internal/DataSystem/FDv2DataSystem.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,20 @@ public static FDv2DataSystem Create(Logger logger, Configuration configuration,
7979

8080
var contextWithSelectorSource =
8181
clientContext.WithSelectorSource(new SelectorSourceFacade(writeThroughStore));
82+
// FDv1 fallback synchronizer is optional; only build a list entry when one is
83+
// configured. An always-present list entry that captured a null configurer would
84+
// throw NRE the moment the action applier advanced to the FDv1 fallback entry.
85+
var fdv1FallbackFactories = dataSystemConfiguration.FDv1FallbackSynchronizer == null
86+
? new List<SourceFactory>()
87+
: new List<SourceFactory>
88+
{
89+
FactoryWithContext(clientContext)(dataSystemConfiguration.FDv1FallbackSynchronizer)
90+
};
8291
var compositeDataSource = configuration.Offline ? Components.ExternalUpdatesOnly.Build(contextWithSelectorSource) : FDv2DataSource.CreateFDv2DataSource(
8392
dataSourceUpdates,
8493
dataSystemConfiguration.Initializers.Select(FactoryWithContext(contextWithSelectorSource)).ToList(),
8594
dataSystemConfiguration.Synchronizers.Select(FactoryWithContext(contextWithSelectorSource)).ToList(),
86-
new List<SourceFactory>
87-
{
88-
FactoryWithContext(clientContext)(dataSystemConfiguration.FDv1FallbackSynchronizer)
89-
},
95+
fdv1FallbackFactories,
9096
logger
9197
);
9298

0 commit comments

Comments
 (0)