From d5049aeae84ac10c86563e14c28acc5e9aeeaabd Mon Sep 17 00:00:00 2001 From: joker23 <2494686+joker23@users.noreply.github.com> Date: Fri, 30 Oct 2026 16:53:04 -0400 Subject: [PATCH 1/5] feat: add support for `usePost` option for FDv2 (#411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Adds a `usePost` option (default `false`) to `HttpConfigurationBuilder`. When the FDv2 data system is configured, polling and streaming requests use POST with the evaluation context JSON in the request body instead of GET with the base64url context in the URL path. This keeps the context out of URL-based request logs and CDN logs. - The FDv1 fallback synchronizer sends REPORT when `usePost` is enabled, because the FDv1 endpoints do not support POST. - `useReport` no longer affects FDv2 requests. The SDK logs one warning when it is set together with the data system. Legacy (non-data-system) FDv1 behavior is unchanged. - Contract tests: the test service declares the `client-use-post` capability, maps the harness's `clientSide.usePost` parameter, and the v3 harness is bumped to v3.2.0-alpha.10 (the release that added the POST test variants). The bump also pulls in stricter events-redaction tests that expose a pre-existing bug in `launchdarkly-java-sdk-internal` (attribute names containing `/` are not escaped as attribute references in `redactedAttributes`). The three affected test groups are suppressed in `testharness-suppressions-fdv2.txt` and tracked by SDK-3338; the suppressions should be removed when that fix ships. Implements CSFDV2 Requirement 2.1.3 (usePost option) and 2.1.4 (useReport ignored with a warning under the FDv2 configuration). Verified locally: full unit suite (752 tests) green; contract tests green on an emulator (v2 suite, and v3 at v3.2.0-alpha.10 with the suppressions above - all POST variants pass). --- > [!NOTE] > **Overview** > Adds a **`usePost`** HTTP option (default off) so that when the FDv2 data system is enabled, polling and streaming send the evaluation context in a **POST** body instead of a **GET** URL with a base64 context segment—keeping context out of URL/CDN logs. FDv2 paths that previously used **REPORT** under `useReport` now use **POST**; **ETag**/`If-None-Match` caching stays on **GET** only. > > With the data system, **`useReport` no longer changes FDv2 traffic**; the builder logs a **one-time warning** that requests stay GET unless `usePost` is on. **FDv1 fallback** still has no POST endpoint, so enabling `usePost` maps to **REPORT** with a body there. > > Contract testing advertises **`client-use-post`**, wires harness `clientSide.usePost`, and bumps the v3 harness to **v3.2.0-alpha.10**. Three new v3 event-redaction cases are **suppressed** pending an internal SDK fix (SDK-3338). > > Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 913ef161d68491acf89127afb4746004a59b4fec. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot). --- Makefile | 4 +- .../launchdarkly/sdktest/Representations.java | 1 + .../launchdarkly/sdktest/SdkClientEntity.java | 4 +- .../com/launchdarkly/sdktest/TestService.java | 3 +- .../sdk/android/ComponentsImpl.java | 3 +- .../sdk/android/DataSystemComponents.java | 11 +- .../sdk/android/DefaultFDv2Requestor.java | 33 ++-- .../sdk/android/FDv2DataSourceBuilder.java | 11 ++ .../android/FDv2StreamingSynchronizer.java | 16 +- .../sdk/android/StandardEndpoints.java | 2 +- .../HttpConfigurationBuilder.java | 24 +++ .../android/subsystems/HttpConfiguration.java | 32 +++- .../sdk/android/DataSystemComponentsTest.java | 181 ++++++++++++++++++ .../sdk/android/DefaultFDv2RequestorTest.java | 36 ++-- .../android/FDv2DataSourceBuilderTest.java | 35 +++- .../FDv2StreamingSynchronizerTest.java | 16 +- .../android/HttpConfigurationBuilderTest.java | 16 ++ testharness-suppressions-fdv2.txt | 5 +- 18 files changed, 369 insertions(+), 64 deletions(-) create mode 100644 launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java diff --git a/Makefile b/Makefile index ed9965b7b..05f23b0a6 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/contract-tests/src/main/java/com/launchdarkly/sdktest/Representations.java b/contract-tests/src/main/java/com/launchdarkly/sdktest/Representations.java index 4b7aa650a..5c94b5806 100644 --- a/contract-tests/src/main/java/com/launchdarkly/sdktest/Representations.java +++ b/contract-tests/src/main/java/com/launchdarkly/sdktest/Representations.java @@ -78,6 +78,7 @@ public static class SdkConfigClientSideParams { LDContext initialContext; boolean evaluationReasons; boolean useReport; + boolean usePost; boolean includeEnvironmentAttributes; } diff --git a/contract-tests/src/main/java/com/launchdarkly/sdktest/SdkClientEntity.java b/contract-tests/src/main/java/com/launchdarkly/sdktest/SdkClientEntity.java index f96277041..2056d47e2 100644 --- a/contract-tests/src/main/java/com/launchdarkly/sdktest/SdkClientEntity.java +++ b/contract-tests/src/main/java/com/launchdarkly/sdktest/SdkClientEntity.java @@ -329,7 +329,9 @@ private LDConfig buildSdkConfig(SdkConfigParams params, LDLogAdapter logAdapter, 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) { diff --git a/contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java b/contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java index 50acf5e51..246388bc7 100644 --- a/contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java +++ b/contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java @@ -45,7 +45,8 @@ 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" }; private static final String MIME_JSON = "application/json"; static final Gson gson = new GsonBuilder() diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/ComponentsImpl.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/ComponentsImpl.java index 34b47a2fe..b3413f857 100644 --- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/ComponentsImpl.java +++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/ComponentsImpl.java @@ -233,7 +233,8 @@ public HttpConfiguration build(ClientContext clientContext) { connectTimeoutMillis, headers, headerTransform, - useReport + useReport, + usePost ); } diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DataSystemComponents.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DataSystemComponents.java index 4d9dfea8f..7e6c5ec1d 100644 --- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DataSystemComponents.java +++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DataSystemComponents.java @@ -141,7 +141,7 @@ public Synchronizer build(DataSourceBuildInputs inputs) { StandardEndpoints.FDV2_STREAMING_REQUEST_BASE_PATH, requestor, initialReconnectDelayMillis, - inputs.isEvaluationReasons(), inputs.getHttp().isUseReport(), + inputs.isEvaluationReasons(), inputs.getHttp().shouldUsePost(), httpProps, inputs.getSharedExecutor(), inputs.getBaseLogger(), null); } @@ -159,10 +159,13 @@ 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(), + inputs.getHttp().shouldUsePost(), LDUtil.makeHttpProperties(inputs.getHttp()), inputs.getCacheDir(), inputs.getBaseLogger() @@ -361,8 +364,8 @@ 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(), + StandardEndpoints.FDV2_POLLING_REQUEST_POST_BASE_PATH, + httpProps, inputs.getHttp().shouldUsePost(), inputs.isEvaluationReasons(), null, inputs.getBaseLogger()); } } diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DefaultFDv2Requestor.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DefaultFDv2Requestor.java index 2ffa79e8c..31c254ddf 100644 --- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DefaultFDv2Requestor.java +++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/DefaultFDv2Requestor.java @@ -31,16 +31,15 @@ /** * Default OkHttp-based implementation of {@link FDv2Requestor}. *
- * 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. *
* 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";
@@ -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;
@@ -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
@@ -80,13 +79,13 @@ 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;
@@ -94,14 +93,14 @@ final class DefaultFDv2Requestor implements FDv2Requestor {
// 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;
@@ -139,8 +138,8 @@ public Future
*/
final class FDv2StreamingSynchronizer implements Synchronizer {
- private static final String METHOD_REPORT = "REPORT";
+ private static final String METHOD_POST = "POST";
private static final String PING = "ping";
private static final long READ_TIMEOUT_MS = 300_000; // 5 minutes
private static final long MAX_RECONNECT_TIME_MS = 300_000; // 5 minutes
@@ -61,7 +61,7 @@ final class FDv2StreamingSynchronizer implements Synchronizer {
private final HttpProperties httpProperties;
private final URI streamBaseUri;
private final String streamRequestPath;
- private final boolean useReport;
+ private final boolean usePost;
private final LDContext evaluationContext;
private final SelectorSource selectorSource;
@Nullable
@@ -92,7 +92,7 @@ final class FDv2StreamingSynchronizer implements Synchronizer {
* @param requestor optional requestor for handling ping events via poll; may be null
* @param initialReconnectDelayMillis delay before reconnecting after an error, in milliseconds
* @param evaluationReasons true to request evaluation reasons in the stream
- * @param useReport true to use HTTP REPORT for the request body
+ * @param usePost true to send the context in the request body via HTTP POST
* @param httpProperties HTTP configuration for the stream request
* @param executor executor used to run the streaming loop on a background
* thread; should use background-priority threads
@@ -107,7 +107,7 @@ final class FDv2StreamingSynchronizer implements Synchronizer {
@Nullable FDv2Requestor requestor,
int initialReconnectDelayMillis,
boolean evaluationReasons,
- boolean useReport,
+ boolean usePost,
@NonNull HttpProperties httpProperties,
@NonNull Executor executor,
@NonNull LDLogger logger,
@@ -120,7 +120,7 @@ final class FDv2StreamingSynchronizer implements Synchronizer {
this.requestor = requestor;
this.initialReconnectDelayMillis = initialReconnectDelayMillis;
this.evaluationReasons = evaluationReasons;
- this.useReport = useReport;
+ this.usePost = usePost;
this.httpProperties = httpProperties;
this.executor = executor;
this.logger = logger;
@@ -188,9 +188,9 @@ private void startStream() {
return reqBuilder.build();
});
- if (useReport) {
+ if (usePost) {
connectStrategy = connectStrategy.methodAndBody(
- METHOD_REPORT,
+ METHOD_POST,
RequestBody.create(JsonSerialization.serialize(evaluationContext), JSON));
}
@@ -244,7 +244,7 @@ private void startStream() {
private URI getStreamUri() {
URI uri = HttpHelpers.concatenateUriPath(streamBaseUri, streamRequestPath);
- if (!useReport) {
+ if (!usePost) {
uri = HttpHelpers.concatenateUriPath(uri, LDUtil.urlSafeBase64(evaluationContext));
}
if (evaluationReasons) {
diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StandardEndpoints.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StandardEndpoints.java
index 06c51e32a..0c216aa34 100644
--- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StandardEndpoints.java
+++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StandardEndpoints.java
@@ -18,7 +18,7 @@ private StandardEndpoints() {}
static final String DIAGNOSTIC_EVENTS_REQUEST_PATH = "/mobile/events/diagnostic";
static final String FDV2_POLLING_REQUEST_GET_BASE_PATH = "/sdk/poll/eval";
- static final String FDV2_POLLING_REQUEST_REPORT_BASE_PATH = "/sdk/poll/eval";
+ static final String FDV2_POLLING_REQUEST_POST_BASE_PATH = "/sdk/poll/eval";
static final String FDV2_STREAMING_REQUEST_BASE_PATH = "/sdk/stream/eval";
/**
diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/integrations/HttpConfigurationBuilder.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/integrations/HttpConfigurationBuilder.java
index d59f1680d..26531d8f5 100644
--- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/integrations/HttpConfigurationBuilder.java
+++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/integrations/HttpConfigurationBuilder.java
@@ -46,6 +46,11 @@ public abstract class HttpConfigurationBuilder implements ComponentConfigurer
+ * This option only takes effect when the data system is configured with
+ * {@link com.launchdarkly.sdk.android.LDConfig.Builder#dataSystem(DataSystemBuilder)}.
+ *
+ * @param usePost true to enable the POST method
+ * @return the builder
+ */
+ public HttpConfigurationBuilder usePost(boolean usePost) {
+ this.usePost = usePost;
+ return this;
+ }
+
/**
* For use by wrapper libraries to set an identifying name for the wrapper being used. This will be included in a
* header during requests to the LaunchDarkly servers to allow recording metrics on the usage of
diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/subsystems/HttpConfiguration.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/subsystems/HttpConfiguration.java
index a0257cc2c..c9e53d15b 100644
--- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/subsystems/HttpConfiguration.java
+++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/subsystems/HttpConfiguration.java
@@ -25,6 +25,7 @@ public final class HttpConfiguration {
private final Map
+ * Payload filters are defined per project in LaunchDarkly. When a filter key is set, the SDK
+ * adds it as the {@code filter} query parameter to its streaming and polling requests, and
+ * LaunchDarkly limits the flags it sends to the ones selected by that filter.
+ *
+ * The key must contain only alphanumeric characters, periods, underscores, and hyphens, and
+ * must start with an alphanumeric character. If the key is invalid, the SDK logs an error and
+ * requests the full environment instead.
+ *
+ * @param payloadFilter the payload filter key, or null for no filter
+ * @return the builder
+ */
+ public Builder payloadFilter(String payloadFilter) {
+ this.payloadFilter = payloadFilter;
+ return this;
+ }
+
/**
* Set to true to opt out of sending diagnostics data.
*
@@ -774,6 +809,19 @@ private static LDLogAdapter defaultLogAdapter() {
return LDTimberLogging.adapter();
}
+ private String validPayloadFilterOrNull(LDLogAdapter actualLogAdapter) {
+ if (payloadFilter == null || payloadFilter.isEmpty()) {
+ return null;
+ }
+ if (!PAYLOAD_FILTER_PATTERN.matcher(payloadFilter).matches()) {
+ LDLogger.withAdapter(actualLogAdapter, loggerName).error(
+ "Payload filter \"{}\" is invalid; the full environment will be requested instead",
+ payloadFilter);
+ return null;
+ }
+ return payloadFilter;
+ }
+
/**
* Returns the configured {@link LDConfig} object.
* @return the configuration
@@ -840,6 +888,7 @@ public LDConfig build() {
generateAnonymousKeys,
autoEnvAttributes,
connectionModeStateDebounceMs,
+ validPayloadFilterOrNull(actualLogAdapter),
persistentDataStore,
actualLogAdapter,
loggerName);
diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/LDUtil.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/LDUtil.java
index 4a77849b2..1ff0fe6f2 100644
--- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/LDUtil.java
+++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/LDUtil.java
@@ -13,9 +13,11 @@
import com.launchdarkly.sdk.android.subsystems.ClientContext;
import com.launchdarkly.sdk.android.subsystems.HttpConfiguration;
import com.launchdarkly.sdk.internal.http.HeadersTransformer;
+import com.launchdarkly.sdk.internal.http.HttpHelpers;
import com.launchdarkly.sdk.internal.http.HttpProperties;
import com.launchdarkly.sdk.json.JsonSerialization;
+import java.net.URI;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -179,6 +181,16 @@ static String urlSafeBase64(LDContext context) {
Base64.URL_SAFE + Base64.NO_WRAP);
}
+ @Nullable
+ static String payloadFilter(ClientContext clientContext) {
+ LDConfig config = clientContext.getConfig();
+ return config == null ? null : config.getPayloadFilter();
+ }
+
+ static URI withPayloadFilter(URI uri, @Nullable String payloadFilter) {
+ return payloadFilter == null ? uri : HttpHelpers.addQueryParam(uri, "filter", payloadFilter);
+ }
+
static HttpProperties makeHttpProperties(ClientContext clientContext) {
return makeHttpProperties(clientContext.getHttp());
}
diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StreamingDataSource.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StreamingDataSource.java
index 3bf6ab92b..fc67c6e95 100644
--- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StreamingDataSource.java
+++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/sdk/android/StreamingDataSource.java
@@ -62,6 +62,7 @@ final class StreamingDataSource implements DataSource {
private final LDContext context;
private final HttpProperties httpProperties;
private final boolean evaluationReasons;
+ private final String payloadFilter;
final int initialReconnectDelayMillis; // visible for testing
private final RetryDelayStrategy normalRetryDelay;
private final RetryDelayStrategy extendedRetryDelay;
@@ -106,6 +107,7 @@ final class StreamingDataSource implements DataSource {
this.streamUri = clientContext.getServiceEndpoints().getStreamingBaseUri();
this.httpProperties = LDUtil.makeHttpProperties(clientContext);
this.evaluationReasons = clientContext.isEvaluationReasons();
+ this.payloadFilter = LDUtil.payloadFilter(clientContext);
this.useReport = clientContext.getHttp().isUseReport();
this.initialReconnectDelayMillis = initialReconnectDelayMillis;
this.normalRetryDelay = RetryDelayStrategy.defaultStrategy()
@@ -230,7 +232,7 @@ private URI getUri(@Nullable LDContext context) {
uri = URI.create(uri.toString() + "?withReasons=true");
}
- return uri;
+ return LDUtil.withPayloadFilter(uri, payloadFilter);
}
@VisibleForTesting
diff --git a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSourceBuildInputsInternalTest.java b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSourceBuildInputsInternalTest.java
index 6ea149573..b11c40d3c 100644
--- a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSourceBuildInputsInternalTest.java
+++ b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSourceBuildInputsInternalTest.java
@@ -34,7 +34,7 @@ private static DataSourceBuildInputsInternal makeInternalInputs(
return new DataSourceBuildInputsInternal(
CONTEXT, null, null, false,
() -> Selector.EMPTY, null, CACHE_DIR,
- LDLogger.none(), envData
+ LDLogger.none(), envData, null
);
}
diff --git a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java
index ed30edac1..55e2b356b 100644
--- a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java
+++ b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/DataSystemComponentsTest.java
@@ -65,11 +65,16 @@ private static HttpConfiguration httpConfig(boolean useReport, boolean usePost)
}
private DataSourceBuildInputsInternal makeInputs(HttpServer server, HttpConfiguration http) {
+ return makeInputs(server, http, null);
+ }
+
+ private DataSourceBuildInputsInternal makeInputs(HttpServer server, HttpConfiguration http,
+ String payloadFilter) {
ServiceEndpoints endpoints = new ServiceEndpoints(
server.getUri(), server.getUri(), server.getUri());
return new DataSourceBuildInputsInternal(
CONTEXT, endpoints, http, false,
- () -> Selector.EMPTY, executor, cacheDir.getRoot(), LOGGER, null);
+ () -> Selector.EMPTY, executor, cacheDir.getRoot(), LOGGER, null, payloadFilter);
}
@Test
@@ -178,4 +183,77 @@ public void fdv1FallbackSynchronizerSendsGetByDefault() throws Exception {
}
}
}
+
+ @Test
+ public void pollingSynchronizerSendsPayloadFilter() throws Exception {
+ try (HttpServer server = HttpServer.start(Handlers.bodyJson(VALID_POLL_RESPONSE_JSON))) {
+ Synchronizer sync = new DataSystemComponents.PollingSynchronizerBuilderImpl()
+ .build(makeInputs(server, httpConfig(false, false), "mobile-flags"));
+ try {
+ sync.next().get(5, TimeUnit.SECONDS);
+
+ RequestInfo req = server.getRecorder().requireRequest();
+ assertEquals("?filter=mobile-flags", req.getQuery());
+ } finally {
+ sync.close();
+ }
+ }
+ }
+
+ @Test
+ public void streamingSynchronizerSendsPayloadFilter() throws Exception {
+ String serverIntent = "event: server-intent\ndata: {\"payloads\":[{\"id\":\"p1\",\"target\":100,\"intentCode\":\"xfer-full\",\"reason\":\"\"}]}";
+ String payloadTransferred = "event: payload-transferred\ndata: {\"state\":\"(p:p1:100)\",\"version\":100}";
+
+ try (HttpServer server = HttpServer.start(Handlers.all(
+ Handlers.SSE.start(),
+ Handlers.SSE.event(serverIntent),
+ Handlers.SSE.event(payloadTransferred),
+ Handlers.SSE.leaveOpen()))) {
+ Synchronizer sync = new DataSystemComponents.StreamingSynchronizerBuilderImpl()
+ .build(makeInputs(server, httpConfig(false, false), "mobile-flags"));
+ try {
+ sync.next().get(5, TimeUnit.SECONDS);
+
+ RequestInfo req = server.getRecorder().requireRequest();
+ assertEquals("?filter=mobile-flags", req.getQuery());
+ } finally {
+ sync.close();
+ }
+ }
+ }
+
+ @Test
+ public void fdv1FallbackSynchronizerSendsPayloadFilterWithGet() throws Exception {
+ try (HttpServer server = HttpServer.start(Handlers.bodyJson(VALID_FDV1_JSON))) {
+ Synchronizer sync = new DataSystemComponents.FDv1PollingSynchronizerBuilderImpl()
+ .build(makeInputs(server, httpConfig(false, false), "mobile-flags"));
+ try {
+ sync.next().get(5, TimeUnit.SECONDS);
+
+ RequestInfo req = server.getRecorder().requireRequest();
+ assertEquals("GET", req.getMethod());
+ assertEquals("?filter=mobile-flags", req.getQuery());
+ } finally {
+ sync.close();
+ }
+ }
+ }
+
+ @Test
+ public void fdv1FallbackSynchronizerSendsPayloadFilterWithReport() throws Exception {
+ try (HttpServer server = HttpServer.start(Handlers.bodyJson(VALID_FDV1_JSON))) {
+ Synchronizer sync = new DataSystemComponents.FDv1PollingSynchronizerBuilderImpl()
+ .build(makeInputs(server, httpConfig(false, true), "mobile-flags"));
+ try {
+ sync.next().get(5, TimeUnit.SECONDS);
+
+ RequestInfo req = server.getRecorder().requireRequest();
+ assertEquals("REPORT", req.getMethod());
+ assertEquals("?filter=mobile-flags", req.getQuery());
+ } finally {
+ sync.close();
+ }
+ }
+ }
}
diff --git a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/FDv2StreamingSynchronizerTest.java b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/FDv2StreamingSynchronizerTest.java
index 17937c138..7646033ab 100644
--- a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/FDv2StreamingSynchronizerTest.java
+++ b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/FDv2StreamingSynchronizerTest.java
@@ -83,6 +83,7 @@ private FDv2StreamingSynchronizer makeSynchronizer(
null,
100,
false,
+ null,
false,
httpProperties(),
executor,
@@ -93,9 +94,15 @@ private FDv2StreamingSynchronizer makeSynchronizer(
private FDv2StreamingSynchronizer makeSynchronizer(
URI streamBaseUri,
boolean evaluationReasons, boolean usePost) {
+ return makeSynchronizer(streamBaseUri, evaluationReasons, usePost, null);
+ }
+
+ private FDv2StreamingSynchronizer makeSynchronizer(
+ URI streamBaseUri,
+ boolean evaluationReasons, boolean usePost, String payloadFilter) {
return new FDv2StreamingSynchronizer(
CONTEXT, EMPTY_SELECTOR_SOURCE, streamBaseUri, STREAM_PATH,
- null, 100, evaluationReasons, usePost,
+ null, 100, evaluationReasons, payloadFilter, usePost,
httpProperties(), executor, LOGGER, null);
}
@@ -1050,6 +1057,33 @@ public void evaluationReasonsAddedToStreamUrl() throws Exception {
}
}
+ @Test
+ public void payloadFilterAddedToStreamUrl() throws Exception {
+ String serverIntent = makeEvent("server-intent", "{\"payloads\":[{\"id\":\"payload-1\",\"target\":100,\"intentCode\":\"xfer-full\",\"reason\":\"payload-missing\"}]}");
+ String payloadTransferred = makeEvent("payload-transferred", "{\"state\":\"(p:payload-1:100)\",\"version\":100}");
+
+ try (HttpServer server = HttpServer.start(Handlers.all(
+ Handlers.SSE.start(),
+ Handlers.SSE.event(serverIntent),
+ Handlers.SSE.event(payloadTransferred),
+ Handlers.SSE.leaveOpen()))) {
+
+ FDv2StreamingSynchronizer sync = makeSynchronizer(server.getUri(),
+ true /* evaluationReasons */, false /* usePost */, "mobile-flags");
+
+ sync.next().get(5, TimeUnit.SECONDS);
+
+ RequestInfo request = server.getRecorder().requireRequest();
+ assertNotNull(request.getQuery());
+ assertTrue("query should contain filter=mobile-flags",
+ request.getQuery().contains("filter=mobile-flags"));
+ assertTrue("query should still contain withReasons=true",
+ request.getQuery().contains("withReasons=true"));
+
+ sync.close();
+ }
+ }
+
@Test
public void usePostMethodForStreamRequest() throws Exception {
String serverIntent = makeEvent("server-intent", "{\"payloads\":[{\"id\":\"payload-1\",\"target\":100,\"intentCode\":\"xfer-full\",\"reason\":\"payload-missing\"}]}");
@@ -1131,7 +1165,7 @@ public void pingEventWithRequestorTriggersPoll() throws Exception {
FDv2StreamingSynchronizer sync = new FDv2StreamingSynchronizer(
CONTEXT, EMPTY_SELECTOR_SOURCE, streamServer.getUri(), STREAM_PATH,
- requestor, 100, false, false,
+ requestor, 100, false, null, false,
httpProperties(), executor, LOGGER, null);
try {
@@ -1171,7 +1205,7 @@ public void close() {
FDv2StreamingSynchronizer sync = new FDv2StreamingSynchronizer(
CONTEXT, EMPTY_SELECTOR_SOURCE, URI.create("http://localhost:9999/"), STREAM_PATH,
- trackingRequestor, 100, false, false,
+ trackingRequestor, 100, false, null, false,
httpProperties(), executor, LOGGER, null);
assertFalse(requestorClosed.get());
diff --git a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/LDConfigTest.java b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/LDConfigTest.java
index 5db264615..c44d9206b 100644
--- a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/LDConfigTest.java
+++ b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/LDConfigTest.java
@@ -49,6 +49,49 @@ public void testBuilderEvaluationReasons() {
assertTrue(config.isEvaluationReasons());
}
+ @Test
+ public void testBuilderPayloadFilterDefaultsToNull() {
+ LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Disabled).build();
+
+ assertNull(config.getPayloadFilter());
+ }
+
+ @Test
+ public void testBuilderPayloadFilterValid() {
+ LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Disabled)
+ .logAdapter(logging.logAdapter)
+ .payloadFilter("mobile.flags_v2-a")
+ .build();
+
+ assertEquals("mobile.flags_v2-a", config.getPayloadFilter());
+ logging.assertNoErrorsLogged();
+ }
+
+ @Test
+ public void testBuilderPayloadFilterEmptyIsIgnored() {
+ LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Disabled)
+ .logAdapter(logging.logAdapter)
+ .payloadFilter("")
+ .build();
+
+ assertNull(config.getPayloadFilter());
+ logging.assertNoErrorsLogged();
+ }
+
+ @Test
+ public void testBuilderPayloadFilterInvalidIsDroppedWithError() {
+ String[] invalidKeys = {"-starts-with-hyphen", ".starts-with-period", "has space", "has/slash", "has&"};
+ for (String key : invalidKeys) {
+ LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Disabled)
+ .logAdapter(logging.logAdapter)
+ .payloadFilter(key)
+ .build();
+
+ assertNull(key, config.getPayloadFilter());
+ logging.assertErrorLogged("Payload filter \"" + key + "\" is invalid");
+ }
+ }
+
@Test
public void testBuilderDiagnosticOptOut() {
LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Disabled).diagnosticOptOut(true).build();
diff --git a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java
index c0be925de..d68aa0e99 100644
--- a/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java
+++ b/launchdarkly-android-client-sdk/src/test/java/com/launchdarkly/sdk/android/StreamingDataSourceTest.java
@@ -159,9 +159,18 @@ private ClientContext makeDataSourceClientContext(
URI streamBaseUri,
MockComponents.MockDataSourceUpdateSink sink,
boolean evaluationReasons, boolean useReport) {
+ return makeDataSourceClientContext(streamBaseUri, sink, evaluationReasons, useReport, null);
+ }
+
+ private ClientContext makeDataSourceClientContext(
+ URI streamBaseUri,
+ MockComponents.MockDataSourceUpdateSink sink,
+ boolean evaluationReasons, boolean useReport, String payloadFilter) {
LDConfig.Builder configBuilder = new LDConfig.Builder(AutoEnvAttributes.Disabled)
+ .logAdapter(logging.logAdapter)
.serviceEndpoints(Components.serviceEndpoints().streaming(streamBaseUri))
- .evaluationReasons(evaluationReasons);
+ .evaluationReasons(evaluationReasons)
+ .payloadFilter(payloadFilter);
if (useReport) {
configBuilder.http(Components.httpConfiguration().useReport(true));
}
@@ -592,6 +601,78 @@ public void startSendsRequestWithReasonsWhenEnabled() throws Exception {
}
}
+ @Test
+ public void startSendsPayloadFilterWithGet() throws Exception {
+ String putEvent = makeSseEvent("put", VALID_PUT_JSON);
+
+ try (HttpServer server = HttpServer.start(Handlers.all(
+ Handlers.SSE.start(),
+ Handlers.SSE.event(putEvent),
+ Handlers.SSE.leaveOpen()))) {
+
+ ClientContext clientContext = makeDataSourceClientContext(
+ server.getUri(), dataSourceUpdateSink, true, false, "mobile-flags");
+ StreamingDataSource sds = (StreamingDataSource) Components.streamingDataSource()
+ .build(clientContext);
+ TrackingCallback callback = new TrackingCallback();
+ startDataSource(sds, callback);
+
+ assertNotNull(callback.awaitSuccess());
+
+ RequestInfo request = server.getRecorder().requireRequest();
+ assertEquals("GET", request.getMethod());
+ assertEquals("?withReasons=true&filter=mobile-flags", request.getQuery());
+ }
+ }
+
+ @Test
+ public void startSendsPayloadFilterWithReport() throws Exception {
+ String putEvent = makeSseEvent("put", VALID_PUT_JSON);
+
+ try (HttpServer server = HttpServer.start(Handlers.all(
+ Handlers.SSE.start(),
+ Handlers.SSE.event(putEvent),
+ Handlers.SSE.leaveOpen()))) {
+
+ ClientContext clientContext = makeDataSourceClientContext(
+ server.getUri(), dataSourceUpdateSink, false, true, "mobile-flags");
+ StreamingDataSource sds = (StreamingDataSource) Components.streamingDataSource()
+ .build(clientContext);
+ TrackingCallback callback = new TrackingCallback();
+ startDataSource(sds, callback);
+
+ assertNotNull(callback.awaitSuccess());
+
+ RequestInfo request = server.getRecorder().requireRequest();
+ assertEquals("REPORT", request.getMethod());
+ assertEquals("?filter=mobile-flags", request.getQuery());
+ }
+ }
+
+ @Test
+ public void startOmitsInvalidPayloadFilter() throws Exception {
+ String putEvent = makeSseEvent("put", VALID_PUT_JSON);
+
+ try (HttpServer server = HttpServer.start(Handlers.all(
+ Handlers.SSE.start(),
+ Handlers.SSE.event(putEvent),
+ Handlers.SSE.leaveOpen()))) {
+
+ ClientContext clientContext = makeDataSourceClientContext(
+ server.getUri(), dataSourceUpdateSink, false, false, "not valid");
+ StreamingDataSource sds = (StreamingDataSource) Components.streamingDataSource()
+ .build(clientContext);
+ TrackingCallback callback = new TrackingCallback();
+ startDataSource(sds, callback);
+
+ assertNotNull(callback.awaitSuccess());
+
+ RequestInfo request = server.getRecorder().requireRequest();
+ assertTrue("query should not contain a filter",
+ request.getQuery() == null || !request.getQuery().contains("filter="));
+ }
+ }
+
@Test
public void startSendsRequestWithoutReasonsWhenDisabled() throws Exception {
String putEvent = makeSseEvent("put", VALID_PUT_JSON);
From 186c9f1e80663f7ee5e2cf337f5f7eb837f3cfbe Mon Sep 17 00:00:00 2001
From: Andrey Belonogov Returns false when there is no client, in which case nothing was recorded and ending the
- * process would demonstrate nothing.
+ * Returns the client they were recorded on, or null when there is none, in which case nothing was
+ * recorded and ending the process would demonstrate nothing.
*/
- private boolean recordExposureAndError(String flagKey) {
- if (ldClient == null) {
- return false;
+ private LDClient recordExposureAndError(String flagKey) {
+ LDClient client = client();
+ if (client == null) {
+ return null;
}
- ldClient.boolVariation(flagKey, false);
- ldClient.track("$ld:telemetry:error");
- return true;
+ client.boolVariation(flagKey, false);
+ client.track("$ld:telemetry:error");
+ return client;
}
/**
@@ -444,10 +575,11 @@ private void setupKillUnsentButton() {
killUnsentButton.setOnClickListener(v -> {
final String flagKey = flagKeyToKillOver();
Timber.w("eval+track+kill flag=%s", flagKey);
- if (!recordExposureAndError(flagKey)) {
+ LDClient client = recordExposureAndError(flagKey);
+ if (client == null) {
return;
}
- ldClient.flush();
+ client.flush();
new Handler(Looper.getMainLooper()).postDelayed(
() -> android.os.Process.killProcess(android.os.Process.myPid()),
5_000);
@@ -468,7 +600,7 @@ private void setupKillNowButton() {
killNowButton.setOnClickListener(v -> {
final String flagKey = flagKeyToKillOver();
Timber.w("eval+track+kill now flag=%s", flagKey);
- if (!recordExposureAndError(flagKey)) {
+ if (recordExposureAndError(flagKey) == null) {
return;
}
android.os.Process.killProcess(android.os.Process.myPid());
@@ -489,7 +621,7 @@ private void setupCrashNowButton() {
crashNowButton.setOnClickListener(v -> {
final String flagKey = flagKeyToKillOver();
Timber.w("eval+track+crash now flag=%s", flagKey);
- if (!recordExposureAndError(flagKey)) {
+ if (recordExposureAndError(flagKey) == null) {
return;
}
throw new RuntimeException(
@@ -512,14 +644,15 @@ private void setupCrashNowButton() {
private void setupOverRefreshButton() {
Button overRefreshButton = findViewById(R.id.over_refresh_button);
overRefreshButton.setOnClickListener(v -> {
- if (ldClient == null) {
+ LDClient client = client();
+ if (client == null) {
return;
}
final String flagKey = "trackevents-test";
Timber.w("over-refresh eval flag=%s", flagKey);
- double filling = averageMicroseconds(flagKey, EVENT_CAPACITY);
- double overCapacity = averageMicroseconds(flagKey, OVER_CAPACITY_EVALUATIONS);
+ double filling = averageMicroseconds(client, flagKey, EVENT_CAPACITY);
+ double overCapacity = averageMicroseconds(client, flagKey, OVER_CAPACITY_EVALUATIONS);
String result = String.format(Locale.US,
"Over-refresh %s\n%d filling: %.0f \u00b5s/eval\n%d over capacity: %.0f \u00b5s/eval",
@@ -540,14 +673,15 @@ private void setupOverRefreshButton() {
private void setupFillBatchesButton() {
Button fillBatchesButton = findViewById(R.id.fill_batches_button);
fillBatchesButton.setOnClickListener(v -> {
- if (ldClient == null) {
+ LDClient client = client();
+ if (client == null) {
return;
}
char[] filler = new char[LARGE_EVENT_DATA_CHARS];
Arrays.fill(filler, 'x');
String padding = new String(filler);
for (int i = 1; i <= LARGE_EVENTS; i++) {
- ldClient.trackData("fill-batches", LDValue.buildObject()
+ client.trackData("fill-batches", LDValue.buildObject()
.put("index", i)
.put("of", LARGE_EVENTS)
.put("padding", padding)
@@ -626,9 +760,10 @@ private void setupOversizedPostButton() {
final Handler main = new Handler(getMainLooper());
final String eventsBaseUri = isStaging() ? "https://mobile." + STAGING_DOMAIN
: "https://mobile.launchdarkly.com";
+ final String mobileKey = selectedMobileKey();
status.setText("Posting 20 MB…");
new Thread(() -> {
- String report = OversizedPostProbe.run(BuildConfig.MOBILE_KEY, eventsBaseUri);
+ String report = OversizedPostProbe.run(mobileKey, eventsBaseUri);
Timber.w("oversized post\n%s", report);
main.post(() -> {
postButton.setEnabled(true);
@@ -680,10 +815,10 @@ private void showResults(final String title, final String results) {
/**
* @return the mean wall time, in microseconds, of {@code count} evaluations of the flag
*/
- private double averageMicroseconds(String flagKey, int count) {
+ private static double averageMicroseconds(LDClient client, String flagKey, int count) {
long start = System.nanoTime();
for (int i = 0; i < count; i++) {
- ldClient.boolVariation(flagKey, false);
+ client.boolVariation(flagKey, false);
}
return (System.nanoTime() - start) / 1_000.0 / count;
}
@@ -699,9 +834,7 @@ private void setupIdentifyButton() {
// an unchanged context still demonstrates that the reset happens either way.
final String userKey = typedKey.isEmpty() ? DEFAULT_USER_KEY : typedKey;
final LDContext updatedContext = LDContext.create(userKey);
- MainActivity.this.doSafeClientAction(() -> {
- ldClient.identify(updatedContext);
- });
+ MainActivity.this.doSafeClientAction(client -> client.identify(updatedContext));
MainActivity.this.updateDedupeStatus();
});
}
@@ -712,7 +845,7 @@ private Switch offlineSwitch() {
private void setupOfflineSwitch() {
offlineSwitch().setOnCheckedChangeListener((compoundButton, isChecked) ->
- MainActivity.this.doSafeClientAction(isChecked ? () -> ldClient.setOffline() : () -> ldClient.setOnline())
+ MainActivity.this.doSafeClientAction(isChecked ? LDClient::setOffline : LDClient::setOnline)
);
}
@@ -734,31 +867,31 @@ private void setupEval() {
String logResult;
switch (type) {
case "String":
- result = MainActivity.this.doSafeClientGet(() -> ldClient.stringVariation(flagKey, "default"));
+ result = MainActivity.this.doSafeClientGet(client -> client.stringVariation(flagKey, "default"));
logResult = result == null ? "no result" : result;
Timber.i(logResult);
((TextView) MainActivity.this.findViewById(R.id.result_textView)).setText(result);
- MainActivity.this.doSafeClientAction(() -> {
- ldClient.registerFeatureFlagListener(flagKey, flagKey1 -> {
+ MainActivity.this.doSafeClientAction(client -> {
+ client.registerFeatureFlagListener(flagKey, flagKey1 -> {
evaluationsRequested.incrementAndGet();
((TextView) MainActivity.this.findViewById(R.id.result_textView))
- .setText(ldClient.stringVariation(flagKey1, "default"));
+ .setText(client.stringVariation(flagKey1, "default"));
MainActivity.this.updateDedupeStatus();
});
});
MainActivity.this.updateDedupeStatus();
return;
case "Boolean":
- result = MainActivity.this.doSafeClientGet(() -> String.valueOf(ldClient.boolVariation(flagKey, false)));
+ result = MainActivity.this.doSafeClientGet(client -> String.valueOf(client.boolVariation(flagKey, false)));
break;
case "Integer":
- result = MainActivity.this.doSafeClientGet(() -> String.valueOf(ldClient.intVariation(flagKey, 0)));
+ result = MainActivity.this.doSafeClientGet(client -> String.valueOf(client.intVariation(flagKey, 0)));
break;
case "Float":
- result = MainActivity.this.doSafeClientGet(() -> String.valueOf(ldClient.doubleVariation(flagKey, 0.0)));
+ result = MainActivity.this.doSafeClientGet(client -> String.valueOf(client.doubleVariation(flagKey, 0.0)));
break;
case "Value":
- result = MainActivity.this.doSafeClientGet(() -> String.valueOf(ldClient.jsonValueVariation(flagKey, null)));
+ result = MainActivity.this.doSafeClientGet(client -> String.valueOf(client.jsonValueVariation(flagKey, null)));
break;
default:
result = null;
diff --git a/test-app/src/main/res/layout/activity_main.xml b/test-app/src/main/res/layout/activity_main.xml
index 3f1fb5185..a1a84cd6f 100644
--- a/test-app/src/main/res/layout/activity_main.xml
+++ b/test-app/src/main/res/layout/activity_main.xml
@@ -71,6 +71,8 @@