Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors are logged when app starts without network connections #107

Closed
valeriyo opened this issue Sep 24, 2020 · 6 comments
Closed

Errors are logged when app starts without network connections #107

valeriyo opened this issue Sep 24, 2020 · 6 comments

Comments

@valeriyo
Copy link

When my app starts without network connection (e.g. WiFi is off) - the LD library logs the following errors:

2020-09-23 22:49:28.514 11484-11560/app E/DiagnosticEventProcessor: Unhandled exception in LaunchDarkly client attempting to connect to URI: https://mobile.launchdarkly.com/mobile/events/diagnostic
    java.net.UnknownHostException: Unable to resolve host "mobile.launchdarkly.com": No address associated with hostname
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
        at java.net.InetAddress.getAllByName(InetAddress.java:1152)
        at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
        at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at com.launchdarkly.android.SSLHandshakeInterceptor.intercept(TLSUtils.java:72)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(com.google.firebase:firebase-perf@@19.0.8:5)
        at com.launchdarkly.android.DiagnosticEventProcessor.sendDiagnosticEventSync(DiagnosticEventProcessor.java:114)
        at com.launchdarkly.android.DiagnosticEventProcessor.access$300(DiagnosticEventProcessor.java:21)
        at com.launchdarkly.android.DiagnosticEventProcessor$4.run(DiagnosticEventProcessor.java:99)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
        at libcore.io.Linux.android_getaddrinfo(Native Method)
        at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
        at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202)
        at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) 
        at java.net.InetAddress.getAllByName(InetAddress.java:1152) 
        at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49) 
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164) 
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129) 
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71) 
        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205) 
        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) 
        at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) 
        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) 
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at com.launchdarkly.android.SSLHandshakeInterceptor.intercept(TLSUtils.java:72) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) 
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) 
        at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(com.google.firebase:firebase-perf@@19.0.8:5) 
        at com.launchdarkly.android.DiagnosticEventProcessor.sendDiagnosticEventSync(DiagnosticEventProcessor.java:114) 
        at com.launchdarkly.android.DiagnosticEventProcessor.access$300(DiagnosticEventProcessor.java:21) 
        at com.launchdarkly.android.DiagnosticEventProcessor$4.run(DiagnosticEventProcessor.java:99) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 
2020-09-23 22:49:28.744 11484-11560/app E/DiagnosticEventProcessor: Unhandled exception in LaunchDarkly client attempting to connect to URI: https://mobile.launchdarkly.com/mobile/events/diagnostic
    java.net.UnknownHostException: Unable to resolve host "mobile.launchdarkly.com": No address associated with hostname
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:124)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
        at java.net.InetAddress.getAllByName(InetAddress.java:1152)
        at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
        at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at com.launchdarkly.android.SSLHandshakeInterceptor.intercept(TLSUtils.java:72)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(com.google.firebase:firebase-perf@@19.0.8:5)
        at com.launchdarkly.android.DiagnosticEventProcessor.sendDiagnosticEventSync(DiagnosticEventProcessor.java:114)
        at com.launchdarkly.android.DiagnosticEventProcessor.access$300(DiagnosticEventProcessor.java:21)
        at com.launchdarkly.android.DiagnosticEventProcessor$4.run(DiagnosticEventProcessor.java:99)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)

It's understandable that the library would try to connect to the mothership and that would fail - but treating these failures as ERRORS is not right. This spams the logs for no good reason.

Please, maybe consider, logging these as Warnings? Ideally, you wouldn't even try to connect if there is no internet connectivity. Thanks.

@gwhelanLD
Copy link
Contributor

Hi @valeriyo,

Thanks for the report, you're absolutely correct in these points. I've filed them internally (ch90774) to be addressed when we get the chance. We have logic elsewhere in the SDK for avoiding calls when the network is known to be unavailable, but apparently we missed handling that for this feature. We'll adapt that, as well as update the logging level for this message if a request fails when the network is not known to be unavailable.

Thanks!
@gwhelanLD

@gwhelanLD gwhelanLD mentioned this issue May 7, 2021
gwhelanLD added a commit that referenced this issue May 7, 2021
## [3.0.0] - 2021-05-07
This major version has an accompanying [Migration Guide](https://docs.launchdarkly.com/sdk/client-side/android/migration-2-to-3). Please see the guide for more information on updating to this version of the SDK, as the following is just a summary of the changes.

Usages of `Gson` provided types have been removed from the public API, replacing `JsonElement` with `LDValue` provided by the SDK. `LDValue` can represent the same values as a `JsonElement`, but has a diferent API. See the [API documentation](https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/LDValue.html) for a detailed reference.
### Added
- `LDConfig.Builder` customization:
  * The `autoAliasingOptOut` configuration option that is used to control the new automatic aliasing behavior of the `identify` method; by setting `autoAliasingOptOut` to true, `identify` will not automatically generate alias events.
  * The `headerTransform` configuration option that supersedes the previous `additionalHeaders` configuration option by allowing fully dynamic updating of headers for requests the SDK makes to the LaunchDarkly service.
  * The `privateAttributes` configuration option that replaces `setPrivateAttributeNames`, specifying the private attributes as vararg `UserAttribute` arguments rather than a `Set<String>`. This allows easily specifying built-in attributes.
- `LDUser(String)` constructor that creates a fully default user.
- New accessors for `LDUser`
  * `getAttribute(UserAttribute)` for programmatically retrieving attribute values.
  * `getCustomAttributes()` for retrieving the currently set custom attributes.
  * `getPrivateAttributes()` for retrieving the attributes set to be private on this user.
  * `isAttributePrivate(UserAttribute)` for checking if a given attribute is private.
  * Getters for all built-in attributes, e.g. `getName()`
- New `LDUser.Builder` methods  overloads for `custom` and `privateCustom`:
  * `custom(String, boolean)` and `privateCustom(String, boolean)` for setting custom attributes to boolean values.
  * `custom(String, int)`, `privateCustom(String, int)`, `custom(String, double)`, and `privateCustom(String, double)` for setting custom attributes to numeric values.
  * `custom(String, LDValue)` and `privateCustom(String, LDValue)` for setting custom attributes to arbitrary data.
- The `UserAttribute` class, which provides a less error-prone way to refer to user attribute names in configuration. This class can also be used to get arbitrary attribute- `LDClient` functionality:
  * The `alias` method that is used to associate two user objects for analytics purposes with an alias event.
  * `jsonValueVariation` and `jsonValueVariationDetail`. These are equivalent to the removed `jsonVariation` and `jsonVariationDetail` other than using `LDValue` instead of `JsonElement`.
  * `trackData(String, LDValue)` which replaces `track(String, JsonElement)`. Other than changing to use `LDValue` the behavior is the same.
  * `trackMetric(String, LDValue, double)` which replaces `track(String, JsonElement, Double)`. This also uses `LDValue` rather than `JsonElement`, and requires a metric value. Otherwise use `trackData`.
- The `LDGson` and `LDJackson` classes, which allow SDK classes like `LDUser` to be easily converted to or from JSON using the popular Gson and Jackson frameworks.
- `EvaluationDetail.fromValue` and `EvaluationDetail.error` factory methods.
- `LDHeaderUpdater` interface for the new `headerTransform` configuration option.
### Fixed
- Fixed an issue where the SDK could log error level messages when attempting to send diagnostic events without an internet connection. The SDK will no longer attempt to send diagnostic events when an internet connection is known to be unavailable, and will not log an error level message if the connection fails. Thanks to @valeriyo for reporting ([#107](#107)).
- Fixed an issue where `LDUser` instances created before calling `LDClient.init` without specifying a key would have the key `UNKNOWN_ANDROID` rather than a device unique key.
- Fixed an issue where flags listeners would be informed of changes to unchanged flags whenever the SDK receives an entire flag set (on a new stream connection, a poll request, or any stream updates behind a relay proxy).
- Fixed an issue where a `NullPointerException` is thrown if `LDClient.close()` is called multiple times.
- Improved the proguard/R8 configuration to allow more optimization. Thanks to @valeriyo for requesting ([#106](#106))
- Fixed a potential issue where the SDK could cause additional throttling on requests to the backend service when previously throttled requests had been cancelled before completion.
### Changed (requirements/dependencies/build)
- Migrated from using the Android Support Libraries to using AndroidX from Jetpack. Using AndroidX requires the `android.useAndroidX` Android Gradle plugin flag to be set to `true` in your application's `gradle.properties` file. If your application previously set the `android.enableJetifier` Android Gradle plugin flag to `true` in it's `gradle.properties` file soley for the LaunchDarkly SDK, this flag can now be removed. Thanks to everyone who requested this enhancement ([#103](#103)).
- The minimum Android API version has been raised from API level 16 (Android 4.1 Jelly Bean) to API level 21 (Android 5.0 Lollipop).
- The SDK no longer has a dependency on Google Play Services. This dependency was only used on pre-21 Android API levels to improve TLS 1.2 compatibility, as the minimum Android version has been raised to 21, the dependency is no longer necessary.
- The SDK is now built with modern Gradle (6.7, Android plugin 4.1.3) and uses Java 8.
### Changed (API)
- Package names have changed: the main SDK classes are now in `com.launchdarkly.sdk` and `com.launchdarkly.sdk.android`.
- All `LDConfig.Builder` setters have been renamed to remove the `set` prefix, e.g. `LDConfig.Builder.setMobileKey` has been renamed to `LDConfig.Builder.mobileKey`.
- `LDClient` API changes:
  * `boolVariation` and `intVariation` no longer use nullable object types for argument and return values, instead using primitive types, e.g. `Boolean boolVariation(String, Boolean)` became `boolean boolVariation(String, boolean)`.
  * `boolVariationDetail` and `intVariationDetail` no longer use nullable object types for argument values, instead using primitive types, e.g. `boolVariationDetail(String, Boolean)` became `boolVariationDetail(String, boolean)`.
  * `floatVariation` and `floatVariationDetail` have been changed to have the same behavior as the removed `doubleVariation` and `doubleVariationDetail`.
  * `allFlags()` now returns `Map<String, LDValue>` rather than `Map<String, ?>`. Rather than the returned `Map` containing `Boolean`, `Float`, and `String` typed objects, with JSON values represented as strings, the `Map` contains `LDValue` typed objects which return the source type (including complex types such as JSON arrays and objects).
- `EvaluationDetail.getVariationIndex()` now returns `int` instead of `Integer`. No variation index is now represented as the constant `EvaluationReason.NO_VARIATION`.
- `EvaluationReason` is now a single concrete class rather than an abstract base class. Usages of the sub-classes can be replaced with the base class. 
### Changed (behavioral)
- The default polling domain (configurable with `LDConfig.Builder.pollUri`) has changed from `app.launchdarkly.com` to `clientsdk.launchdarkly.com`.
- The default `eventsUri` used to send events to the service has changed from `https://mobile.launchdarkly.com/mobile` to `https://mobile.launchdarkly.com`. The SDK will now append the expected endpoint path (`/mobile`) to the configured `Uri`, which is more consistent with other LaunchDarkly SDKs.
- For compatibility with older SDK behavior, the `LDClient.stringVariation` method could be used to retrieve JSON flags in a serialized representation. This compatibility behavior has been removed, and attempts to request a JSON valued flag using `stringVariation` will behave the same as other mismatched type variation calls.
- The `LDClient.identify` method will now automatically generate an alias event when switching from an anonymous to a known user. This event associates the two users for analytics purposes as they most likely represent a single person. This behavior can be disabled with the `autoAliasingOptOut` configuration option.
- All log messages are now tagged `LaunchDarklySdk` for easier filtering. Thanks to @valeriyo for the suggestion ([#113](#113)).
- `LDUser` now overrides `equals`, `hashCode`, and `toString` with appropriate implementations.
- `LDUser.Builder.country(String)` and `LDUser.Builder.privateCountry(String)` no longer attempt to look up the country from the provided `String` (attempting to match it as an ISO-3166-1 alpha-2, alpha-3 code; or a country name) and set the country to the resultant IOS-3166-1 alpha-2 only if successful. The SDK no longer gives this attribute special behavior, and sets the user's country attribute directly as the provided `String`.
### Removed
- `LDConfig.Builder`:
  * `setBaseUri(Uri)` has been removed. Please use `setPollUri(Uri)` instead.
  * `setAdditionalHeaders(Map<String,String>)` has been removed. Please use `headerTransform(LDHeaderUpdater)` instead.
  * `setPrivateAttributeNames(Set<String>)` has been removed. Please use `privateAttributes(UserAttribute...)` instead.
- `LDUser.Builder`:
  * `country(LDCountryCode)` and `privateCountry(LDCountryCode)` have been removed. Use `country(String)` or `privateCountry(String)` to set the country value on a user.
  * `custom(String, Number)` and `privateCustom(String, Number)` have been removed. Use the `(String, int)` or `(String, double)` overloads instead.
  * `custom(String, Boolean)` and `privateCustom(String, Boolean)` have been removed. Use `custom(String, boolean)` or `privateCustom(String, boolean)` instead.
  * `custom(String, List<String>)`, `LDUser.customString(String, List<String>)`, `LDUser.privateCustomString(String, List<String>)`. Use `custom(String, LDValue)` and `privateCustom(String, LDValue)` instead.
  * `customNumber(String, List<Number>)` and `LDUser.privateCustomNumber(String, List<Number>)`. Use `custom(String, LDValue)` and `privateCustom(String, LDValue)` instead.
- `LDClient`:
  * `doubleVariation` and `doubleVariationDetail` have been removed. Use `floatVariation` and `floatVariationDetail` instead.
  * `jsonVariation` and `jsonVariationDetail` have been removed. Use `jsonValueVariation` and `jsonValueVariationDetail` instead.
  * `track(String, JsonElement)` and `track(String, JsonElement, Double)` overloads have been removed, please use the designated methods `trackData(String, LDValue)` and `trackMetric(String, LDValue, double)` instead.
- The public constructor for `EvaluationDetail` has been hidden. Use the new factory methods `EvaluationDetail.fromValue` and `EvaluationDetail.error` instead.
- The concrete sub-classes of `EvaluationReason` have been removed in favor of making `EvaluationReason` a concrete class. The accessors on the sub-classes have been moved to the base class. Instead of using `instanceOf` to determine the type, use `getKind()`.
- `LDCountryCode` has been removed as no SDK APIs use this class.
- All classes and interfaces in the `com.launchdarkly.sdk.android.flagstore`, `com.launchdarkly.sdk.android.gson`, `com.launchdarkly.sdk.android.response`, and `com.launchdarkly.sdk.android.tls` packages. These classes and interfaces were not intended for external use.
- `Debounce`, `FeatureFlagFetcher`, `SummaryEventSharedPreferences`, `UserSummaryEventSharedPreferences`, and `Util` in `com.launchdarkly.sdk.android`. These deprecated classes and interfaces were not intended for external use.
@gwhelanLD
Copy link
Contributor

Thanks again for pointing this issue out, it should now be fixed in the 3.0.0 release. The SDK will avoid network calls for diagnostics when the network is known to be unavailable, and if there is an exception here regardless it will no longer be logged at an error level. This should bring the behavior of this functionality in line with the other network behavior of the SDK.

Thanks,
@gwhelanLD

@tariana
Copy link

tariana commented Jun 15, 2021

Hi @gwhelanLD,
I noticed this issue is still happening after updating to 3.0.0 version. Could you please consider taking a look at it again? Thanks!

@gwhelanLD
Copy link
Contributor

Hi @tariana,

I think I see what you're talking about. Our fix did address the error level log messages as well as these messages being repeated on the diagnostic reporting interval, but we're still getting an initial warning message (or two) if started without an internet connection. That's still non-ideal when the SDK should be aware of the network unavailability, so we'll definitely see about addressing this. I believe I should be able to get a fix in with the next patch release that should be coming soon.

Thanks for letting us know,
@gwhelanLD

@mateusz-nawrot
Copy link

Hi @gwhelanLD , we are still observing a lot of Exceptions thrown on version 3.0.2. Do you have any updates on the fix?

LaunchDarklyReleaseBot added a commit that referenced this issue Aug 1, 2022
* Add support for TLS 1.2 on API 16+

* Add back final keyword

* Bumping the minSdkVersion from 15 to 16

* Circle CI 2.0

* Created new branch for multi-environment sdk feature

* Stub out new LDConfig and LDConfig.Builder code for multi-environment.

* Added overloaded init method in LDClient for creating secondary instances

* Added getForMobileKey methods

* Added LDClient init test for secondary environment, added exception to getForMobileKeys, added multi-environment support to setOffline and setOnlineStatus (seems naive, needs testing), and added exceptions to LDConfig setSecondaryMobileKeys

* Move primary instance into general instances map. Begin on methods effecting all instances.

* Removed incorrect LDClient test

* Fixed 1 failing test in LDClient, added multi-environment test file, fixed some linter issues

* Removed unnecessary ListenableFuture in LDClient init, changed identify method for multi-environment, not sure about SettableFuture null vs null for return type of Future<Void>, both type check and pass tests

* Added setOnlineStatus multi-environment changes

* Moved primaryEnvironmentName to LDConfig, simplifying by removing primaryKey separation everywhere but the builder. Add getRequestBuilderFor a specific environment. Add static method to LDClient to get all environment names so that environments can be iterated over. Add accessor to retrieve LDClient specific UserManager. Iterate over all environments in PollingUpdater. Add environment argument to UserManager constructor, removing singleton and creating replacing init with newInstance static method.

* Add back in constructor without environment to UserManager

* Specialize HttpFeatureFlagFetcher to the environment, looks like UserManager may not be able to do the same so removed the environment from the constructor.

* Added SharedPreferences migration strategy

* All tests pass, fixed migration strategy to conform to spec, fixed primaryInstance null when offline in init, fixed primaryEnvironmentName being added to secondaryMobileKeys

* Update StreamUpdateProcessor construct to take an environment for the authorization header key.

* Fix issue with LDConfig mobileKeys hashmap creation.

* Combine futures so LDClient init future waits on all online instances of LDClient.

* Propagate IOException on closing instances to caller.

* Merge futures for identify call.

* Some changes from code review.

* Removed static from instanceId and now old SharedPreferences will only cleared once all environments have a copy in LDClient

* Fixed instanceId

* Updates from PR review.

* Added version and flagVersion, if available

* refactor(LDClient, LDConfig): changes for PR

* refactor(LDClient): changed isInternetConnected behavior for PR

* refactor(LDClient): removed async getForMobileKeys and wait seconds version, replaced with method that returns requested instance

* Bugfix/timber cleanup (#92)

Relates to #60

Cleaned up timber logging messages to use string formatting rather than concatenation. Log messages should remain the same as before.
Also replaced Log with Timber in the example app.

* Fix crash when example app is backgrounded twice.

* Add security provider update mechanism using Google Play Services to
attempt a provider update when TLSv1.2 is not available.

* Shared Preferences Fix for Multi Environment (#94)

* fix(SharedPreferences): added more SharedPreferences first time migration and differentiated SharedPreferences by mobile key

* fix(UserLocalSharePreference.java): added missing mobileKey additions to getSharedPreferences, cleaned up debugging code

* Fix edge cases in how multi-environment handles connection changes.

* fix(UserManagerTest.java): incorrect number of arguments to UserManager instantiation in unit test

* Remove line of testing code accidentally left in and refactor shared
preferences migration to make future migrations easier.

* Final fixes to store migration. Should be fairly future proof.

* Fix issue with primitive variation calls always returning null if fallback is null.

* Remove CircleCI V1 config file. (#97)

* Remove getting/comparing versions as floats (#99)

To prevent floating point errors in flag version comparisons.

* Include values in unknown summary events and compare values for (#100)

equality when creating new summary counters.

* simplify flag property deserialization

* rm debugging

* misc cleanup

* rm debugging

* add eval reason data model classes

* misc fixes

* serialize reason

* add ability to receive evaluation reasons from LD

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* add methods to get value with explanation; refactor existing variation methods

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

Co-authored-by: Farhan Khan <farhan.khan@robotsandpencils.com>
Co-authored-by: Arun Bhalla <arun@launchdarkly.com>
Co-authored-by: nejifresh <nejifresh@gmail.com>
Co-authored-by: torchhound <unknownmasayoshi@gmail.com>
Co-authored-by: Gavin Whelan <gavwhela@gmail.com>
Co-authored-by: torchhound <jcieslik@umail.iu.edu>
Co-authored-by: jamesthacker <Nametaker40@live.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: torchhound <jcieslik@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Aug 17, 2022
* Add support for TLS 1.2 on API 16+

* Add back final keyword

* Bumping the minSdkVersion from 15 to 16

* Circle CI 2.0

* Created new branch for multi-environment sdk feature

* Stub out new LDConfig and LDConfig.Builder code for multi-environment.

* Added overloaded init method in LDClient for creating secondary instances

* Added getForMobileKey methods

* Added LDClient init test for secondary environment, added exception to getForMobileKeys, added multi-environment support to setOffline and setOnlineStatus (seems naive, needs testing), and added exceptions to LDConfig setSecondaryMobileKeys

* Move primary instance into general instances map. Begin on methods effecting all instances.

* Removed incorrect LDClient test

* Fixed 1 failing test in LDClient, added multi-environment test file, fixed some linter issues

* Removed unnecessary ListenableFuture in LDClient init, changed identify method for multi-environment, not sure about SettableFuture null vs null for return type of Future<Void>, both type check and pass tests

* Added setOnlineStatus multi-environment changes

* Moved primaryEnvironmentName to LDConfig, simplifying by removing primaryKey separation everywhere but the builder. Add getRequestBuilderFor a specific environment. Add static method to LDClient to get all environment names so that environments can be iterated over. Add accessor to retrieve LDClient specific UserManager. Iterate over all environments in PollingUpdater. Add environment argument to UserManager constructor, removing singleton and creating replacing init with newInstance static method.

* Add back in constructor without environment to UserManager

* Specialize HttpFeatureFlagFetcher to the environment, looks like UserManager may not be able to do the same so removed the environment from the constructor.

* Added SharedPreferences migration strategy

* All tests pass, fixed migration strategy to conform to spec, fixed primaryInstance null when offline in init, fixed primaryEnvironmentName being added to secondaryMobileKeys

* Update StreamUpdateProcessor construct to take an environment for the authorization header key.

* Fix issue with LDConfig mobileKeys hashmap creation.

* Combine futures so LDClient init future waits on all online instances of LDClient.

* Propagate IOException on closing instances to caller.

* Merge futures for identify call.

* Some changes from code review.

* Removed static from instanceId and now old SharedPreferences will only cleared once all environments have a copy in LDClient

* Fixed instanceId

* Updates from PR review.

* Added version and flagVersion, if available

* refactor(LDClient, LDConfig): changes for PR

* refactor(LDClient): changed isInternetConnected behavior for PR

* refactor(LDClient): removed async getForMobileKeys and wait seconds version, replaced with method that returns requested instance

* Bugfix/timber cleanup (#92)

Relates to #60

Cleaned up timber logging messages to use string formatting rather than concatenation. Log messages should remain the same as before.
Also replaced Log with Timber in the example app.

* Fix crash when example app is backgrounded twice.

* Add security provider update mechanism using Google Play Services to
attempt a provider update when TLSv1.2 is not available.

* Shared Preferences Fix for Multi Environment (#94)

* fix(SharedPreferences): added more SharedPreferences first time migration and differentiated SharedPreferences by mobile key

* fix(UserLocalSharePreference.java): added missing mobileKey additions to getSharedPreferences, cleaned up debugging code

* Fix edge cases in how multi-environment handles connection changes.

* fix(UserManagerTest.java): incorrect number of arguments to UserManager instantiation in unit test

* Remove line of testing code accidentally left in and refactor shared
preferences migration to make future migrations easier.

* Final fixes to store migration. Should be fairly future proof.

* Fix issue with primitive variation calls always returning null if fallback is null.

* Remove CircleCI V1 config file. (#97)

* Remove getting/comparing versions as floats (#99)

To prevent floating point errors in flag version comparisons.

* Include values in unknown summary events and compare values for (#100)

equality when creating new summary counters.

* simplify flag property deserialization

* rm debugging

* misc cleanup

* rm debugging

* add eval reason data model classes

* misc fixes

* serialize reason

* add ability to receive evaluation reasons from LD

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* add methods to get value with explanation; refactor existing variation methods

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

Co-authored-by: Farhan Khan <farhan.khan@robotsandpencils.com>
Co-authored-by: Arun Bhalla <arun@launchdarkly.com>
Co-authored-by: nejifresh <nejifresh@gmail.com>
Co-authored-by: torchhound <unknownmasayoshi@gmail.com>
Co-authored-by: Gavin Whelan <gavwhela@gmail.com>
Co-authored-by: torchhound <jcieslik@umail.iu.edu>
Co-authored-by: jamesthacker <Nametaker40@live.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: torchhound <jcieslik@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Aug 23, 2022
* Removed unnecessary ListenableFuture in LDClient init, changed identify method for multi-environment, not sure about SettableFuture null vs null for return type of Future<Void>, both type check and pass tests

* Added setOnlineStatus multi-environment changes

* Moved primaryEnvironmentName to LDConfig, simplifying by removing primaryKey separation everywhere but the builder. Add getRequestBuilderFor a specific environment. Add static method to LDClient to get all environment names so that environments can be iterated over. Add accessor to retrieve LDClient specific UserManager. Iterate over all environments in PollingUpdater. Add environment argument to UserManager constructor, removing singleton and creating replacing init with newInstance static method.

* Add back in constructor without environment to UserManager

* Specialize HttpFeatureFlagFetcher to the environment, looks like UserManager may not be able to do the same so removed the environment from the constructor.

* Added SharedPreferences migration strategy

* All tests pass, fixed migration strategy to conform to spec, fixed primaryInstance null when offline in init, fixed primaryEnvironmentName being added to secondaryMobileKeys

* Update StreamUpdateProcessor construct to take an environment for the authorization header key.

* Fix issue with LDConfig mobileKeys hashmap creation.

* Combine futures so LDClient init future waits on all online instances of LDClient.

* Propagate IOException on closing instances to caller.

* Merge futures for identify call.

* Some changes from code review.

* Removed static from instanceId and now old SharedPreferences will only cleared once all environments have a copy in LDClient

* Fixed instanceId

* Updates from PR review.

* Added version and flagVersion, if available

* refactor(LDClient, LDConfig): changes for PR

* refactor(LDClient): changed isInternetConnected behavior for PR

* refactor(LDClient): removed async getForMobileKeys and wait seconds version, replaced with method that returns requested instance

* Bugfix/timber cleanup (#92)

Relates to #60

Cleaned up timber logging messages to use string formatting rather than concatenation. Log messages should remain the same as before.
Also replaced Log with Timber in the example app.

* Fix crash when example app is backgrounded twice.

* Add security provider update mechanism using Google Play Services to
attempt a provider update when TLSv1.2 is not available.

* Shared Preferences Fix for Multi Environment (#94)

* fix(SharedPreferences): added more SharedPreferences first time migration and differentiated SharedPreferences by mobile key

* fix(UserLocalSharePreference.java): added missing mobileKey additions to getSharedPreferences, cleaned up debugging code

* Fix edge cases in how multi-environment handles connection changes.

* fix(UserManagerTest.java): incorrect number of arguments to UserManager instantiation in unit test

* Remove line of testing code accidentally left in and refactor shared
preferences migration to make future migrations easier.

* Final fixes to store migration. Should be fairly future proof.

* Fix issue with primitive variation calls always returning null if fallback is null.

* Remove CircleCI V1 config file. (#97)

* Remove getting/comparing versions as floats (#99)

To prevent floating point errors in flag version comparisons.

* Include values in unknown summary events and compare values for (#100)

equality when creating new summary counters.

* simplify flag property deserialization

* rm debugging

* misc cleanup

* rm debugging

* add eval reason data model classes

* misc fixes

* serialize reason

* add ability to receive evaluation reasons from LD

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* add methods to get value with explanation; refactor existing variation methods

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

Co-authored-by: torchhound <unknownmasayoshi@gmail.com>
Co-authored-by: Gavin Whelan <gavwhela@gmail.com>
Co-authored-by: torchhound <jcieslik@umail.iu.edu>
Co-authored-by: Arun Bhalla <arun@launchdarkly.com>
Co-authored-by: jamesthacker <Nametaker40@live.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: torchhound <jcieslik@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Aug 23, 2022
* Moved primaryEnvironmentName to LDConfig, simplifying by removing primaryKey separation everywhere but the builder. Add getRequestBuilderFor a specific environment. Add static method to LDClient to get all environment names so that environments can be iterated over. Add accessor to retrieve LDClient specific UserManager. Iterate over all environments in PollingUpdater. Add environment argument to UserManager constructor, removing singleton and creating replacing init with newInstance static method.

* Add back in constructor without environment to UserManager

* Specialize HttpFeatureFlagFetcher to the environment, looks like UserManager may not be able to do the same so removed the environment from the constructor.

* Added SharedPreferences migration strategy

* All tests pass, fixed migration strategy to conform to spec, fixed primaryInstance null when offline in init, fixed primaryEnvironmentName being added to secondaryMobileKeys

* Update StreamUpdateProcessor construct to take an environment for the authorization header key.

* Fix issue with LDConfig mobileKeys hashmap creation.

* Combine futures so LDClient init future waits on all online instances of LDClient.

* Propagate IOException on closing instances to caller.

* Merge futures for identify call.

* Some changes from code review.

* Removed static from instanceId and now old SharedPreferences will only cleared once all environments have a copy in LDClient

* Fixed instanceId

* Updates from PR review.

* Added version and flagVersion, if available

* refactor(LDClient, LDConfig): changes for PR

* refactor(LDClient): changed isInternetConnected behavior for PR

* refactor(LDClient): removed async getForMobileKeys and wait seconds version, replaced with method that returns requested instance

* Bugfix/timber cleanup (#92)

Relates to #60

Cleaned up timber logging messages to use string formatting rather than concatenation. Log messages should remain the same as before.
Also replaced Log with Timber in the example app.

* Fix crash when example app is backgrounded twice.

* Add security provider update mechanism using Google Play Services to
attempt a provider update when TLSv1.2 is not available.

* Shared Preferences Fix for Multi Environment (#94)

* fix(SharedPreferences): added more SharedPreferences first time migration and differentiated SharedPreferences by mobile key

* fix(UserLocalSharePreference.java): added missing mobileKey additions to getSharedPreferences, cleaned up debugging code

* Fix edge cases in how multi-environment handles connection changes.

* fix(UserManagerTest.java): incorrect number of arguments to UserManager instantiation in unit test

* Remove line of testing code accidentally left in and refactor shared
preferences migration to make future migrations easier.

* Final fixes to store migration. Should be fairly future proof.

* Fix issue with primitive variation calls always returning null if fallback is null.

* Remove CircleCI V1 config file. (#97)

* Remove getting/comparing versions as floats (#99)

To prevent floating point errors in flag version comparisons.

* Include values in unknown summary events and compare values for (#100)

equality when creating new summary counters.

* simplify flag property deserialization

* rm debugging

* misc cleanup

* rm debugging

* add eval reason data model classes

* misc fixes

* serialize reason

* add ability to receive evaluation reasons from LD

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* add methods to get value with explanation; refactor existing variation methods

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

Co-authored-by: Gavin Whelan <gavwhela@gmail.com>
Co-authored-by: torchhound <jcieslik@umail.iu.edu>
Co-authored-by: torchhound <unknownmasayoshi@gmail.com>
Co-authored-by: Arun Bhalla <arun@launchdarkly.com>
Co-authored-by: jamesthacker <Nametaker40@live.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: torchhound <jcieslik@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Sep 28, 2022
* Combine futures so LDClient init future waits on all online instances of LDClient.

* Propagate IOException on closing instances to caller.

* Merge futures for identify call.

* Some changes from code review.

* Removed static from instanceId and now old SharedPreferences will only cleared once all environments have a copy in LDClient

* Fixed instanceId

* Updates from PR review.

* Added version and flagVersion, if available

* refactor(LDClient, LDConfig): changes for PR

* refactor(LDClient): changed isInternetConnected behavior for PR

* refactor(LDClient): removed async getForMobileKeys and wait seconds version, replaced with method that returns requested instance

* Bugfix/timber cleanup (#92)

Relates to #60

Cleaned up timber logging messages to use string formatting rather than concatenation. Log messages should remain the same as before.
Also replaced Log with Timber in the example app.

* Fix crash when example app is backgrounded twice.

* Add security provider update mechanism using Google Play Services to
attempt a provider update when TLSv1.2 is not available.

* Shared Preferences Fix for Multi Environment (#94)

* fix(SharedPreferences): added more SharedPreferences first time migration and differentiated SharedPreferences by mobile key

* fix(UserLocalSharePreference.java): added missing mobileKey additions to getSharedPreferences, cleaned up debugging code

* Fix edge cases in how multi-environment handles connection changes.

* fix(UserManagerTest.java): incorrect number of arguments to UserManager instantiation in unit test

* Remove line of testing code accidentally left in and refactor shared
preferences migration to make future migrations easier.

* Final fixes to store migration. Should be fairly future proof.

* Fix issue with primitive variation calls always returning null if fallback is null.

* Remove CircleCI V1 config file. (#97)

* Remove getting/comparing versions as floats (#99)

To prevent floating point errors in flag version comparisons.

* Include values in unknown summary events and compare values for (#100)

equality when creating new summary counters.

* simplify flag property deserialization

* rm debugging

* misc cleanup

* rm debugging

* add eval reason data model classes

* misc fixes

* serialize reason

* add ability to receive evaluation reasons from LD

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* add methods to get value with explanation; refactor existing variation methods

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

Co-authored-by: Gavin Whelan <gavwhela@gmail.com>
Co-authored-by: torchhound <jcieslik@umail.iu.edu>
Co-authored-by: torchhound <unknownmasayoshi@gmail.com>
Co-authored-by: Arun Bhalla <arun@launchdarkly.com>
Co-authored-by: jamesthacker <Nametaker40@live.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: torchhound <jcieslik@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Oct 27, 2022
* Some changes from code review.

* Removed static from instanceId and now old SharedPreferences will only cleared once all environments have a copy in LDClient

* Fixed instanceId

* Updates from PR review.

* Added version and flagVersion, if available

* refactor(LDClient, LDConfig): changes for PR

* refactor(LDClient): changed isInternetConnected behavior for PR

* refactor(LDClient): removed async getForMobileKeys and wait seconds version, replaced with method that returns requested instance

* Bugfix/timber cleanup (#92)

Relates to #60

Cleaned up timber logging messages to use string formatting rather than concatenation. Log messages should remain the same as before.
Also replaced Log with Timber in the example app.

* Fix crash when example app is backgrounded twice.

* Add security provider update mechanism using Google Play Services to
attempt a provider update when TLSv1.2 is not available.

* Shared Preferences Fix for Multi Environment (#94)

* fix(SharedPreferences): added more SharedPreferences first time migration and differentiated SharedPreferences by mobile key

* fix(UserLocalSharePreference.java): added missing mobileKey additions to getSharedPreferences, cleaned up debugging code

* Fix edge cases in how multi-environment handles connection changes.

* fix(UserManagerTest.java): incorrect number of arguments to UserManager instantiation in unit test

* Remove line of testing code accidentally left in and refactor shared
preferences migration to make future migrations easier.

* Final fixes to store migration. Should be fairly future proof.

* Fix issue with primitive variation calls always returning null if fallback is null.

* Remove CircleCI V1 config file. (#97)

* Remove getting/comparing versions as floats (#99)

To prevent floating point errors in flag version comparisons.

* Include values in unknown summary events and compare values for (#100)

equality when creating new summary counters.

* simplify flag property deserialization

* rm debugging

* misc cleanup

* rm debugging

* add eval reason data model classes

* misc fixes

* serialize reason

* add ability to receive evaluation reasons from LD

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* add methods to get value with explanation; refactor existing variation methods

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

Co-authored-by: Gavin Whelan <gavwhela@gmail.com>
Co-authored-by: torchhound <jcieslik@umail.iu.edu>
Co-authored-by: torchhound <unknownmasayoshi@gmail.com>
Co-authored-by: Arun Bhalla <arun@launchdarkly.com>
Co-authored-by: jamesthacker <Nametaker40@live.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: torchhound <jcieslik@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Nov 17, 2022
* Fixed instanceId

* Updates from PR review.

* Added version and flagVersion, if available

* refactor(LDClient, LDConfig): changes for PR

* refactor(LDClient): changed isInternetConnected behavior for PR

* refactor(LDClient): removed async getForMobileKeys and wait seconds version, replaced with method that returns requested instance

* Bugfix/timber cleanup (#92)

Relates to #60

Cleaned up timber logging messages to use string formatting rather than concatenation. Log messages should remain the same as before.
Also replaced Log with Timber in the example app.

* Fix crash when example app is backgrounded twice.

* Add security provider update mechanism using Google Play Services to
attempt a provider update when TLSv1.2 is not available.

* Shared Preferences Fix for Multi Environment (#94)

* fix(SharedPreferences): added more SharedPreferences first time migration and differentiated SharedPreferences by mobile key

* fix(UserLocalSharePreference.java): added missing mobileKey additions to getSharedPreferences, cleaned up debugging code

* Fix edge cases in how multi-environment handles connection changes.

* fix(UserManagerTest.java): incorrect number of arguments to UserManager instantiation in unit test

* Remove line of testing code accidentally left in and refactor shared
preferences migration to make future migrations easier.

* Final fixes to store migration. Should be fairly future proof.

* Fix issue with primitive variation calls always returning null if fallback is null.

* Remove CircleCI V1 config file. (#97)

* Remove getting/comparing versions as floats (#99)

To prevent floating point errors in flag version comparisons.

* Include values in unknown summary events and compare values for (#100)

equality when creating new summary counters.

* simplify flag property deserialization

* rm debugging

* misc cleanup

* rm debugging

* add eval reason data model classes

* misc fixes

* serialize reason

* add ability to receive evaluation reasons from LD

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* add methods to get value with explanation; refactor existing variation methods

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

Co-authored-by: torchhound <unknownmasayoshi@gmail.com>
Co-authored-by: Gavin Whelan <gavwhela@gmail.com>
Co-authored-by: Arun Bhalla <arun@launchdarkly.com>
Co-authored-by: jamesthacker <Nametaker40@live.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: torchhound <jcieslik@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Dec 2, 2022
* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Dec 21, 2022
* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Dec 23, 2022
* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Jan 7, 2023
* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Jan 7, 2023
* (U2C 1) remove alias events (#238)

* (U2C 2) remove inlineUsersInEvents (#239)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* use fully-qualified context key in flag store (doesn't include migration)

* suppress contract tests for inline users in events

* rm unused plugin

* update more user references to contexts

* use LDContext in API and evaluations; disable events for now

* update some more references to "users"

* add contract test support for context type

* fix test

* adopt new event processor

* rm redundant class

* update snapshot version

* fix tiny inconsistency in build.gradle

* set request paths for event sender

* fix private attributes configuration

* make test expectation correspond to the endpoint we're using now

* fix HTTP cache configuration

* fix test

* remove debug output

* misc fixes

* add config option for generating anonymous keys

* test should be testing trackData

* fix anonymous key logic

* add storage abstraction and use it in ContextDecorator

* rm inapplicable comment

* update evaluation endpoint paths

* refactor more components to use storage abstraction

* misc fixes

* debugging

* debugging

* debugging

* substitute simple in-memory persistence in contract tests

* rm debugging, move test fixture

* comment

* create PersistentDataStoreWrapper component to encapsulate storage schema rules

* misc cleanup, comments

* ensure test log tag name isn't too long

* rm unused

* rm unused

* spacing

* major refactoring of context/flag manager components and ConnectivityManager

* rm duplicate test

* revert unnecessary change

* rm redundant helper

* clearer handling of exceptions in Gson deserialization

* improve test logging: add full test name to log line, force enable debug

* misc fixes

* more cleanup of JSON parsing logic

* create module for shared test code

* tolerate missing keys in flag data

* rm redundant class

* rm unused

* create PlatformState abstraction

* misc cleanup, factor various properties out into ClientState

* rm tests that can't possibly work in any supported API version

* fix tests, move network listener to ConnectivityManager

* comments

* fix error logging

* discard pre-v4 SDK data, migrate anon user key if possible

* clean up leftover polling alarms

* simplify by moving triggerPoll logic inside ConnectivityManager

* use regular worker threads for polling instead of AlarmManager

* simplify further by moving Debounce usage into ConnectivityManager

* config streamlining: ServiceEndpoints

* move LDConfigTest to unit tests and fix warning message

* update okhttp-eventsource version + streaming timeout fix

* update contract tests

* rm obsolete manifest entry

* update ProGuard rules file

* javadoc fix

* fix endpoint config in contract tests

* add temporary test suppressions

* create ClientContext object as a standard way to pass configuration to components

* fix javadoc

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* fix merge

* fix tests

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* fix example code

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* revise streaming/polling components to use a pluggable data source abstraction

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* misc cleanup + comments

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* add overloads for using LDUser instead of LDContext

* update Proguard rules file

* fix @SInCE

* fix test

* (4.0) add test data source (#282)

* use latest package versions

* if SDK starts in the background, do an initial poll

* add "use streaming even in background" option (4.x)

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

* prepare 3.5.1 release (#205)

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>

* update obsolete credential paths

* Releasing version 3.5.1

Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Jan 11, 2023
* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

* add ApplicationInfo a.k.a. tags (3.x) (#289)

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Jan 12, 2023
* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* use fully-qualified context key in flag store (doesn't include migration)

* suppress contract tests for inline users in events

* rm unused plugin

* update more user references to contexts

* use LDContext in API and evaluations; disable events for now

* update some more references to "users"

* add contract test support for context type

* fix test

* adopt new event processor

* rm redundant class

* update snapshot version

* fix tiny inconsistency in build.gradle

* set request paths for event sender

* fix private attributes configuration

* make test expectation correspond to the endpoint we're using now

* fix HTTP cache configuration

* fix test

* remove debug output

* misc fixes

* add config option for generating anonymous keys

* test should be testing trackData

* fix anonymous key logic

* add storage abstraction and use it in ContextDecorator

* rm inapplicable comment

* update evaluation endpoint paths

* refactor more components to use storage abstraction

* misc fixes

* debugging

* debugging

* debugging

* substitute simple in-memory persistence in contract tests

* rm debugging, move test fixture

* comment

* create PersistentDataStoreWrapper component to encapsulate storage schema rules

* misc cleanup, comments

* ensure test log tag name isn't too long

* rm unused

* rm unused

* spacing

* major refactoring of context/flag manager components and ConnectivityManager

* rm duplicate test

* revert unnecessary change

* rm redundant helper

* clearer handling of exceptions in Gson deserialization

* improve test logging: add full test name to log line, force enable debug

* misc fixes

* more cleanup of JSON parsing logic

* create module for shared test code

* tolerate missing keys in flag data

* rm redundant class

* rm unused

* create PlatformState abstraction

* misc cleanup, factor various properties out into ClientState

* rm tests that can't possibly work in any supported API version

* fix tests, move network listener to ConnectivityManager

* comments

* fix error logging

* discard pre-v4 SDK data, migrate anon user key if possible

* clean up leftover polling alarms

* simplify by moving triggerPoll logic inside ConnectivityManager

* use regular worker threads for polling instead of AlarmManager

* simplify further by moving Debounce usage into ConnectivityManager

* config streamlining: ServiceEndpoints

* move LDConfigTest to unit tests and fix warning message

* update okhttp-eventsource version + streaming timeout fix

* update contract tests

* rm obsolete manifest entry

* update ProGuard rules file

* javadoc fix

* fix endpoint config in contract tests

* add temporary test suppressions

* create ClientContext object as a standard way to pass configuration to components

* fix javadoc

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* fix merge

* fix tests

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* fix example code

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* revise streaming/polling components to use a pluggable data source abstraction

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* misc cleanup + comments

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* add overloads for using LDUser instead of LDContext

* update Proguard rules file

* fix @SInCE

* fix test

* (4.0) add test data source (#282)

* use latest package versions

* if SDK starts in the background, do an initial poll

* add "use streaming even in background" option (4.x)

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

* prepare 3.5.1 release (#205)

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>

* update obsolete credential paths

* Releasing version 3.5.1

* add ApplicationInfo a.k.a. tags (3.x) (#289)

* prepare 3.6.0 release (#207)

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

* add ApplicationInfo a.k.a. tags (3.x) (#289)

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>

* Releasing version 3.6.0

* add ApplicationInfo a.k.a. tags (4.x) (#290)

Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
LaunchDarklyReleaseBot added a commit that referenced this issue Mar 15, 2023
* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* use fully-qualified context key in flag store (doesn't include migration)

* suppress contract tests for inline users in events

* rm unused plugin

* update more user references to contexts

* use LDContext in API and evaluations; disable events for now

* update some more references to "users"

* add contract test support for context type

* fix test

* adopt new event processor

* rm redundant class

* update snapshot version

* fix tiny inconsistency in build.gradle

* set request paths for event sender

* fix private attributes configuration

* make test expectation correspond to the endpoint we're using now

* fix HTTP cache configuration

* fix test

* remove debug output

* misc fixes

* add config option for generating anonymous keys

* test should be testing trackData

* fix anonymous key logic

* add storage abstraction and use it in ContextDecorator

* rm inapplicable comment

* update evaluation endpoint paths

* refactor more components to use storage abstraction

* misc fixes

* debugging

* debugging

* debugging

* substitute simple in-memory persistence in contract tests

* rm debugging, move test fixture

* comment

* create PersistentDataStoreWrapper component to encapsulate storage schema rules

* misc cleanup, comments

* ensure test log tag name isn't too long

* rm unused

* rm unused

* spacing

* major refactoring of context/flag manager components and ConnectivityManager

* rm duplicate test

* revert unnecessary change

* rm redundant helper

* clearer handling of exceptions in Gson deserialization

* improve test logging: add full test name to log line, force enable debug

* misc fixes

* more cleanup of JSON parsing logic

* create module for shared test code

* tolerate missing keys in flag data

* rm redundant class

* rm unused

* create PlatformState abstraction

* misc cleanup, factor various properties out into ClientState

* rm tests that can't possibly work in any supported API version

* fix tests, move network listener to ConnectivityManager

* comments

* fix error logging

* discard pre-v4 SDK data, migrate anon user key if possible

* clean up leftover polling alarms

* simplify by moving triggerPoll logic inside ConnectivityManager

* use regular worker threads for polling instead of AlarmManager

* simplify further by moving Debounce usage into ConnectivityManager

* config streamlining: ServiceEndpoints

* move LDConfigTest to unit tests and fix warning message

* update okhttp-eventsource version + streaming timeout fix

* update contract tests

* rm obsolete manifest entry

* update ProGuard rules file

* javadoc fix

* fix endpoint config in contract tests

* add temporary test suppressions

* create ClientContext object as a standard way to pass configuration to components

* fix javadoc

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* fix merge

* fix tests

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* fix example code

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* revise streaming/polling components to use a pluggable data source abstraction

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* misc cleanup + comments

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* add overloads for using LDUser instead of LDContext

* update Proguard rules file

* fix @SInCE

* fix test

* (4.0) add test data source (#282)

* use latest package versions

* if SDK starts in the background, do an initial poll

* add "use streaming even in background" option (4.x)

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

* prepare 3.5.1 release (#205)

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>

* update obsolete credential paths

* Releasing version 3.5.1

* add ApplicationInfo a.k.a. tags (3.x) (#289)

* prepare 3.6.0 release (#207)

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

* re-fix previous fix for connection keep-alive

* add ApplicationInfo a.k.a. tags (3.x) (#289)

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>

* Releasing version 3.6.0

* add ApplicationInfo a.k.a. tags (4.x) (#290)

* Added missing callback

* Adding missing call to register/unregister in unit test found in review.

---------

Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: Todd Anderson <tanderson@launchdarkly.com>
Co-authored-by: tanderson-ld <127344469+tanderson-ld@users.noreply.github.com>
@jonathanshim
Copy link

Hi, any update on this? It still happens a lot on version 4.2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants