Skip to content

fix: Configuration store minor fixes#91

Merged
felipecsl merged 1 commit intomainfrom
felipecsl--moar-cleanup
Aug 23, 2024
Merged

fix: Configuration store minor fixes#91
felipecsl merged 1 commit intomainfrom
felipecsl--moar-cleanup

Conversation

@felipecsl
Copy link
Contributor

Description

  • Replace AsyncTask (deprecated) with Executors.newSingleThreadExecutor()
  • Use proper synchronization lock
  • Use try-with-resources to make sure BufferedWriter is closed

@felipecsl felipecsl requested review from aarsilv and petzel August 23, 2024 21:09
Copy link
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

The updated core library is much better about interface type (vs concrete) declaration as well

@felipecsl felipecsl merged commit e826df4 into main Aug 23, 2024
@felipecsl felipecsl deleted the felipecsl--moar-cleanup branch August 23, 2024 22:41
hbordersTwitch pushed a commit to hbordersTwitch/android-sdk that referenced this pull request Sep 3, 2025
leoromanovsky added a commit that referenced this pull request Feb 2, 2026
Replace Integer.toHexString() with a pre-computed hex character lookup
table for byte-to-hex conversion. This avoids creating intermediate
String objects for each byte, reducing allocations.

Mirrors optimization from iOS SDK PR #91/#93.
leoromanovsky added a commit that referenced this pull request Feb 3, 2026
* feat: add obfuscation utilities and precomputed DTOs

Add the foundational data structures and utilities for the precomputed
client feature:

- ObfuscationUtils: MD5 hashing for flag key obfuscation
- PrecomputedFlag: DTO for precomputed flag assignments
- PrecomputedBandit: DTO for precomputed bandit assignments
- PrecomputedConfigurationResponse: Wire protocol response parsing
- BanditResult: Result container for bandit action lookups
- MissingSubjectKeyException: Validation exception

Includes comprehensive unit tests for serialization round-trips and
MD5 hash consistency.

* perf: optimize MD5 hex conversion with lookup table

Replace Integer.toHexString() with a pre-computed hex character lookup
table for byte-to-hex conversion. This avoids creating intermediate
String objects for each byte, reducing allocations.

Mirrors optimization from iOS SDK PR #91/#93.

* perf: add md5HexPrefix for efficient partial hash

Add md5HexPrefix() method that only converts the bytes needed for a
given prefix length, avoiding unnecessary work when only a prefix is
required (e.g., cache file naming uses first 8 chars).

Includes unrolled loop for the common 4-byte (8 hex char) case to
help compiler optimization, following iOS SDK PR #93 approach.
leoromanovsky added a commit that referenced this pull request Feb 3, 2026
* feat: add obfuscation utilities and precomputed DTOs

Add the foundational data structures and utilities for the precomputed
client feature:

- ObfuscationUtils: MD5 hashing for flag key obfuscation
- PrecomputedFlag: DTO for precomputed flag assignments
- PrecomputedBandit: DTO for precomputed bandit assignments
- PrecomputedConfigurationResponse: Wire protocol response parsing
- BanditResult: Result container for bandit action lookups
- MissingSubjectKeyException: Validation exception

Includes comprehensive unit tests for serialization round-trips and
MD5 hash consistency.

* perf: optimize MD5 hex conversion with lookup table

Replace Integer.toHexString() with a pre-computed hex character lookup
table for byte-to-hex conversion. This avoids creating intermediate
String objects for each byte, reducing allocations.

Mirrors optimization from iOS SDK PR #91/#93.

* perf: add md5HexPrefix for efficient partial hash

Add md5HexPrefix() method that only converts the bytes needed for a
given prefix length, avoiding unnecessary work when only a prefix is
required (e.g., cache file naming uses first 8 chars).

Includes unrolled loop for the common 4-byte (8 hex char) case to
help compiler optimization, following iOS SDK PR #93 approach.

* refactor: extract BaseCacheFile for reuse

Extract common file caching functionality from ConfigCacheFile into
a new BaseCacheFile base class. This enables reuse for the upcoming
precomputed configuration cache without code duplication.

- Add BaseCacheFile with common read/write/delete operations
- Refactor ConfigCacheFile to extend BaseCacheFile
- No functional changes to existing behavior

* feat: add precomputed configuration storage

Add the storage layer for precomputed flag configurations:

- PrecomputedCacheFile: Disk cache file extending BaseCacheFile
- PrecomputedConfigurationStore: In-memory + disk storage with
  async save/load operations and proper thread synchronization
- Updates in-memory config even if disk write fails for resilience

Also adds test data files to Makefile for integration testing.

Includes unit tests for cache operations and failure scenarios.

* style: apply spotless formatting

* fix: address PR #239 feedback

- Return null consistently in loadConfigFromCache for both file-not-found
  and read-error cases
- Use static EMPTY singleton in PrecomputedConfigurationResponse.empty()
- Use Collections.singletonMap() in getEnvironment() for memory efficiency
leoromanovsky added a commit that referenced this pull request Feb 4, 2026
* feat: add obfuscation utilities and precomputed DTOs

Add the foundational data structures and utilities for the precomputed
client feature:

- ObfuscationUtils: MD5 hashing for flag key obfuscation
- PrecomputedFlag: DTO for precomputed flag assignments
- PrecomputedBandit: DTO for precomputed bandit assignments
- PrecomputedConfigurationResponse: Wire protocol response parsing
- BanditResult: Result container for bandit action lookups
- MissingSubjectKeyException: Validation exception

Includes comprehensive unit tests for serialization round-trips and
MD5 hash consistency.

* perf: optimize MD5 hex conversion with lookup table

Replace Integer.toHexString() with a pre-computed hex character lookup
table for byte-to-hex conversion. This avoids creating intermediate
String objects for each byte, reducing allocations.

Mirrors optimization from iOS SDK PR #91/#93.

* perf: add md5HexPrefix for efficient partial hash

Add md5HexPrefix() method that only converts the bytes needed for a
given prefix length, avoiding unnecessary work when only a prefix is
required (e.g., cache file naming uses first 8 chars).

Includes unrolled loop for the common 4-byte (8 hex char) case to
help compiler optimization, following iOS SDK PR #93 approach.

* refactor: extract BaseCacheFile for reuse

Extract common file caching functionality from ConfigCacheFile into
a new BaseCacheFile base class. This enables reuse for the upcoming
precomputed configuration cache without code duplication.

- Add BaseCacheFile with common read/write/delete operations
- Refactor ConfigCacheFile to extend BaseCacheFile
- No functional changes to existing behavior

* feat: add precomputed configuration storage

Add the storage layer for precomputed flag configurations:

- PrecomputedCacheFile: Disk cache file extending BaseCacheFile
- PrecomputedConfigurationStore: In-memory + disk storage with
  async save/load operations and proper thread synchronization
- Updates in-memory config even if disk write fails for resilience

Also adds test data files to Makefile for integration testing.

Includes unit tests for cache operations and failure scenarios.

* style: apply spotless formatting

* fix: address PR #239 feedback

- Return null consistently in loadConfigFromCache for both file-not-found
  and read-error cases
- Use static EMPTY singleton in PrecomputedConfigurationResponse.empty()
- Use Collections.singletonMap() in getEnvironment() for memory efficiency

* feat: add EppoPrecomputedClient

Add the main precomputed client implementation with:

- Server-side precomputed flag assignments with instant lookups
- Support for all flag types: string, boolean, integer, numeric, JSON
- Bandit action support with attribute decoding
- Builder pattern with extensive configuration options
- Offline mode with initial configuration support
- Background polling with configurable interval and jitter
- Assignment and bandit logging with deduplication caches
- Graceful error handling mode

The client fetches precomputed assignments from the edge endpoint,
eliminating client-side flag evaluation overhead.

Includes comprehensive instrumented tests covering:
- All flag type assignments
- Assignment logging and deduplication
- Bandit actions
- Offline mode
- SDK test data integration

* perf: use md5HexPrefix for cache file naming

* fix: address PR review feedback for EppoPrecomputedClient

- Make polling fields volatile for thread safety
- Return user's default value on parse failure instead of hardcoded 0
- Extract magic string to NO_ACTION_CACHE_KEY constant
- Fix banditActions serialization to match JS SDK wire format
- Add comments for hash length and jitter calculation
- Rename misleading test to testNonGracefulModeCanBeConfigured

* feat: derive precomputed client base URL from SDK key

Extract environment prefix from SDK key to automatically construct
the correct edge endpoint URL (e.g., https://5qhpgd.fs-edge-assignment.eppo.cloud).
This removes the need for users to manually configure the base URL.

* chore: remove self-evident comments in UtilsTest

Address PR review feedback by removing redundant inline comments
that simply restated what the test assertions already conveyed.
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

Successfully merging this pull request may close these issues.

2 participants