Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private async Task UpdateTaskAsync()
try
{
var dataAndHeaders = await _featureRequestor.GetAllDataAsync();
if (dataAndHeaders.DataSet is null)
if (dataAndHeaders is null || dataAndHeaders.DataSet is null)
{
// This means it was cached, and alreadyInited was true
_dataSourceUpdates.UpdateStatus(DataSourceState.Valid, null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using LaunchDarkly.Sdk.Server.Interfaces;
using LaunchDarkly.Sdk.Server.Internal.DataSystem;
using LaunchDarkly.Sdk.Server.Internal.Model;
using LaunchDarkly.Sdk.Server.Subsystems;
Expand Down Expand Up @@ -258,6 +259,41 @@ public void InitIsNotRepeatedIfServerReturnsNotModifiedStatus()
}
}

[Fact]
public void StatusRemainsValidIfServerReturnsNotModifiedStatus()
{
var etag = @"""abc123"""; // note that etag strings must be quoted
var responses = Handlers.SequentialWithLastRepeating(
Handlers.Header("Etag", etag).Then(PollingResponse(AllData)),
Handlers.Status(304)
);

using (var server = HttpServer.Start(responses))
{
using (var dataSource = MakeDataSource(server.Uri,
c => c.DataSource(Components.PollingDataSource().PollIntervalNoMinimum(BriefInterval))))
{
dataSource.Start();

_updateSink.Inits.ExpectValue();
server.Recorder.RequireRequest();
server.Recorder.RequireRequest();
server.Recorder.RequireRequest();

// We've set it up above so that all requests except the first one return a 304
// status. That just means the data is unchanged, which is a healthy state, so it
// should not be reported as an interruption or logged as a failure.
Assert.All(_updateSink.GetAllStatusUpdates(), status =>
{
Assert.Equal(DataSourceState.Valid, status.State);
Assert.Null(status.LastError);
});
AssertLogMessageRegex(false, Logging.LogLevel.Warn,
"Polling for feature flag updates failed");
}
}
}

[Fact]
public void ResponseWithNewEtagUpdatesEtag()
{
Expand Down
Loading