Skip to content
Open
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "5.17.0"
".": "5.18.0"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to the LaunchDarkly Android SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [5.18.0](https://github.com/launchdarkly/android-client-sdk/compare/5.17.0...5.18.0) (2026-10-30)


### Features

* add support for `usePost` option for FDv2 ([#411](https://github.com/launchdarkly/android-client-sdk/issues/411)) ([d5049ae](https://github.com/launchdarkly/android-client-sdk/commit/d5049aeae84ac10c86563e14c28acc5e9aeeaabd))

## [5.17.0](https://github.com/launchdarkly/android-client-sdk/compare/5.16.1...5.17.0) (2026-10-15)


Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ run-contract-tests:
| VERSION=v2 PARAMS="-url http://localhost:8001 -host 10.0.2.2 -debug -skip-from $(SUPPRESSION_FILE) $(TEST_HARNESS_PARAMS_V2)" sh
@echo "Running SDK contract test v3..."
@curl $${GITHUB_TOKEN:+ -H "Authorization: Token $${GITHUB_TOKEN}"} \
-s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v3.1.0-alpha.6/downloader/run.sh \
| VERSION=v3.1.0-alpha.6 PARAMS="-url http://localhost:8001 -host 10.0.2.2 -debug -stop-service-at-end -skip-from $(SUPPRESSION_FILE_FDV2) $(TEST_HARNESS_PARAMS_V3)" sh
-s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v3.2.0-alpha.10/downloader/run.sh \
| VERSION=v3.2.0-alpha.10 PARAMS="-url http://localhost:8001 -host 10.0.2.2 -debug -stop-service-at-end -skip-from $(SUPPRESSION_FILE_FDV2) $(TEST_HARNESS_PARAMS_V3)" sh

contract-tests: build-contract-tests start-emulator start-contract-test-service run-contract-tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public static class SdkConfigParams {
public static class SdkConfigStreamParams {
String baseUri;
Long initialRetryDelayMs;
String filter;
}

public static class SdkConfigPollParams {
String baseUri;
Long pollIntervalMs;
String filter;
}

public static class SdkConfigEventParams {
Expand Down Expand Up @@ -78,6 +80,7 @@ public static class SdkConfigClientSideParams {
LDContext initialContext;
boolean evaluationReasons;
boolean useReport;
boolean usePost;
boolean includeEnvironmentAttributes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,17 @@ private LDConfig buildSdkConfig(SdkConfigParams params, LDLogAdapter logAdapter,
builder.events(eventsBuilder);
}

if (params.streaming != null && params.streaming.filter != null) {
builder.payloadFilter(params.streaming.filter);
} else if (params.polling != null && params.polling.filter != null) {
builder.payloadFilter(params.polling.filter);
}

builder.evaluationReasons(params.clientSide.evaluationReasons);
builder.http(
Components.httpConfiguration().useReport(params.clientSide.useReport)
Components.httpConfiguration()
.useReport(params.clientSide.useReport)
.usePost(params.clientSide.usePost)
);

if (params.tags != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public class TestService extends NanoHTTPD {
"client-per-context-summaries",
"client-event-source-http-errors",
"retry-conformance-fdv1-streaming",
"retry-conformance-fdv1-polling"
"retry-conformance-fdv1-polling",
"client-use-post",
"filtering",
"filtering-strict"
};
private static final String MIME_JSON = "application/json";
static final Gson gson = new GsonBuilder()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# org.gradle.parallel=true

#x-release-please-start-version
version=5.17.0
version=5.18.0
#x-release-please-end

sonatypeUsername=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ public HttpConfiguration build(ClientContext clientContext) {
connectTimeoutMillis,
headers,
headerTransform,
useReport
useReport,
usePost
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ final class DataSourceBuildInputsInternal extends DataSourceBuildInputs {
@Nullable
private final PersistentDataStoreWrapper.ReadOnlyPerEnvironmentData perEnvironmentData;

@Nullable
private final String payloadFilter;

DataSourceBuildInputsInternal(
LDContext evaluationContext,
ServiceEndpoints serviceEndpoints,
Expand All @@ -39,11 +42,13 @@ final class DataSourceBuildInputsInternal extends DataSourceBuildInputs {
ScheduledExecutorService sharedExecutor,
@NonNull File cacheDir,
LDLogger baseLogger,
@Nullable PersistentDataStoreWrapper.ReadOnlyPerEnvironmentData perEnvironmentData
@Nullable PersistentDataStoreWrapper.ReadOnlyPerEnvironmentData perEnvironmentData,
@Nullable String payloadFilter
) {
super(evaluationContext, serviceEndpoints, http, evaluationReasons,
selectorSource, sharedExecutor, cacheDir, baseLogger);
this.perEnvironmentData = perEnvironmentData;
this.payloadFilter = payloadFilter;
}

/**
Expand All @@ -64,6 +69,7 @@ static DataSourceBuildInputsInternal get(DataSourceBuildInputs inputs) {
inputs.getSharedExecutor(),
inputs.getCacheDir(),
inputs.getBaseLogger(),
null,
null
);
}
Expand All @@ -72,4 +78,9 @@ static DataSourceBuildInputsInternal get(DataSourceBuildInputs inputs) {
PersistentDataStoreWrapper.ReadOnlyPerEnvironmentData getPerEnvironmentDataIfAvailable() {
return perEnvironmentData;
}

@Nullable
String getPayloadFilter() {
return payloadFilter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public Synchronizer build(DataSourceBuildInputs inputs) {
StandardEndpoints.FDV2_STREAMING_REQUEST_BASE_PATH,
requestor,
initialReconnectDelayMillis,
inputs.isEvaluationReasons(), inputs.getHttp().isUseReport(),
inputs.isEvaluationReasons(),
DataSourceBuildInputsInternal.get(inputs).getPayloadFilter(),
inputs.getHttp().shouldUsePost(),
httpProps, inputs.getSharedExecutor(),
inputs.getBaseLogger(), null);
}
Expand All @@ -159,10 +161,14 @@ public FDv1PollingSynchronizerBuilderImpl pollIntervalMillis(int pollIntervalMil

@Override
public Synchronizer build(DataSourceBuildInputs inputs) {
// The FDv1 endpoints have no POST variant. When usePost is enabled, the fetcher
// sends the context in the request body with REPORT so it stays out of the
// request URI. useReport has no effect inside the data system.
FeatureFetcher fetcher = new HttpFeatureFlagFetcher(
inputs.getServiceEndpoints().getPollingBaseUri(),
inputs.isEvaluationReasons(),
inputs.getHttp().isUseReport(),
DataSourceBuildInputsInternal.get(inputs).getPayloadFilter(),
inputs.getHttp().shouldUsePost(),
LDUtil.makeHttpProperties(inputs.getHttp()),
inputs.getCacheDir(),
inputs.getBaseLogger()
Expand Down Expand Up @@ -361,8 +367,10 @@ private static FDv2Requestor makePollingRequestor(DataSourceBuildInputs inputs,
return new DefaultFDv2Requestor(
inputs.getEvaluationContext(), pollingBase,
StandardEndpoints.FDV2_POLLING_REQUEST_GET_BASE_PATH,
StandardEndpoints.FDV2_POLLING_REQUEST_REPORT_BASE_PATH,
httpProps, inputs.getHttp().isUseReport(),
inputs.isEvaluationReasons(), null, inputs.getBaseLogger());
StandardEndpoints.FDV2_POLLING_REQUEST_POST_BASE_PATH,
httpProps, inputs.getHttp().shouldUsePost(),
inputs.isEvaluationReasons(),
DataSourceBuildInputsInternal.get(inputs).getPayloadFilter(),
inputs.getBaseLogger());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@
/**
* Default OkHttp-based implementation of {@link FDv2Requestor}.
* <p>
* Builds GET or REPORT requests to the FDv2 polling endpoint. If the current selector is
* Builds GET or POST requests to the FDv2 polling endpoint. If the current selector is
* non-empty, its state is sent as the {@code basis} query parameter. ETag tracking is used
* to detect 304 Not Modified responses; when the server returns 304 the application layer
* treats it as {@code ChangeSetType.None} (no flags changed), so no OkHttp disk cache is
* needed or used.
* needed or used. ETag tracking runs only for GET requests.
* <p>
* The OkHttpClient is closed by {@link #close()}.
*/
final class DefaultFDv2Requestor implements FDv2Requestor {
private static final String METHOD_REPORT = "REPORT";
private static final String BASIS_PARAM = "basis";
private static final String FILTER_PARAM = "filter";
private static final String WITH_REASONS_PARAM = "withReasons";
Expand All @@ -50,10 +49,10 @@ final class DefaultFDv2Requestor implements FDv2Requestor {
private final OkHttpClient httpClient;
private final URI pollingUri;
private final okhttp3.Headers headers;
private final boolean useReport;
private final boolean usePost;
private final boolean evaluationReasons;
@Nullable
private final RequestBody reportBody;
private final RequestBody postBody;
@Nullable
private final String payloadFilter;
private final LDLogger logger;
Expand All @@ -68,9 +67,9 @@ final class DefaultFDv2Requestor implements FDv2Requestor {
* @param evaluationContext the context to evaluate flags for
* @param baseUri polling base URI from service endpoints
* @param getRequestPath path for GET requests (context appended as a path segment)
* @param reportRequestPath path for REPORT requests (context sent in the request body)
* @param postRequestPath path for POST requests (context sent in the request body)
* @param httpProperties SDK HTTP configuration (timeouts, proxy, TLS, user-agent, etc.)
* @param useReport if true, send context in the request body via REPORT; otherwise
* @param usePost if true, send context in the request body via POST; otherwise
* append the base64-encoded context to the GET path
* @param evaluationReasons if true, append {@code withReasons=true} to the query string
* @param payloadFilter optional payload filter key; sent as {@code filter} query param
Expand All @@ -80,28 +79,28 @@ final class DefaultFDv2Requestor implements FDv2Requestor {
@NonNull LDContext evaluationContext,
@NonNull URI baseUri,
@NonNull String getRequestPath,
@NonNull String reportRequestPath,
@NonNull String postRequestPath,
@NonNull HttpProperties httpProperties,
boolean useReport,
boolean usePost,
boolean evaluationReasons,
@Nullable String payloadFilter,
@NonNull LDLogger logger) {
this.useReport = useReport;
this.usePost = usePost;
this.evaluationReasons = evaluationReasons;
this.payloadFilter = payloadFilter;
this.logger = logger;
this.headers = httpProperties.toHeadersBuilder().build();

// Precompute the base polling URI for the chosen request method. For GET, the
// base64-encoded context is a fixed path segment (context never changes after
// construction). For REPORT, the context goes in the request body so no path
// construction). For POST, the context goes in the request body so no path
// segment is needed.
URI basePollingUri = HttpHelpers.concatenateUriPath(baseUri,
useReport ? reportRequestPath : getRequestPath);
this.pollingUri = useReport
usePost ? postRequestPath : getRequestPath);
this.pollingUri = usePost
? basePollingUri
: HttpHelpers.concatenateUriPath(basePollingUri, LDUtil.urlSafeBase64(evaluationContext));
this.reportBody = useReport
this.postBody = usePost
? RequestBody.create(JsonSerialization.serialize(evaluationContext), JSON)
: null;

Expand Down Expand Up @@ -139,8 +138,8 @@ public Future<FDv2PayloadResponse> poll(@NonNull Selector selector) {
.url(requestUri.toURL())
.headers(headers);

if (useReport) {
reqBuilder.method(METHOD_REPORT, reportBody);
if (usePost) {
reqBuilder.post(postBody);
} else {
synchronized (etagLock) {
if (!requestUri.equals(lastRequestUri)) {
Expand Down Expand Up @@ -207,7 +206,7 @@ private void handleResponse(
return;
}

if (!useReport) {
if (!usePost) {
synchronized (etagLock) {
cachedEtag = response.header(ETAG_HEADER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class FDv2DataSourceBuilder implements ComponentConfigurer<DataSource>, Closeabl
private boolean includeInitializers = true; // start with initializers
private ScheduledExecutorService sharedExecutor;

// The useReport warning logs once per builder; build runs again on every
// connection mode switch.
private boolean useReportWarningLogged;

FDv2DataSourceBuilder() {
this(DataSystemComponents.makeDefaultModeTable(), ConnectionMode.STREAMING, ModeResolutionTable.MOBILE);
}
Expand Down Expand Up @@ -98,6 +102,13 @@ ModeDefinition getModeDefinition(@NonNull ConnectionMode mode) {

@Override
public DataSource build(ClientContext clientContext) {
if (clientContext.getHttp().isUseReport() && !useReportWarningLogged) {
useReportWarningLogged = true;
clientContext.getBaseLogger().warn(
"The useReport option has no effect when the data system is configured;"
+ " requests use GET unless usePost is enabled.");
}

if (sharedExecutor == null) {
// Pool size 4: supports the FDv2DataSource main loop (1), an active synchronizer
// such as the streaming event loop (1), FDv2DataSource condition timers for
Expand Down Expand Up @@ -163,7 +174,8 @@ private DataSourceBuildInputsInternal makeInputs(ClientContext clientContext) {
sharedExecutor,
impl.getPlatformState().getCacheDir(),
clientContext.getBaseLogger(),
impl.getPerEnvironmentDataIfAvailable()
impl.getPerEnvironmentDataIfAvailable(),
LDUtil.payloadFilter(clientContext)
);
}

Expand Down
Loading
Loading