Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
0cbb2c9
Add ExecutorServiceBuilder and use it in SyncManagerImp
nmayorsplit Apr 20, 2023
9347536
[SDKS-6713] Add new executors builder
nmayorsplit Apr 21, 2023
acd8edf
[SDKS-6713] Use builSinglethreadScheduledExecutor
nmayorsplit Apr 24, 2023
17b17e8
[SDKS-6713] Update EventSourceClientImp to check if payload is null
nmayorsplit Apr 24, 2023
cd92f8e
[SDKS-6713] PRs suggestions
nmayorsplit Apr 25, 2023
955f2dd
[SDKS-6713] PRs suggestions
nmayorsplit Apr 25, 2023
6801efe
Update client version
nmayorsplit Apr 25, 2023
225d59c
[SDKS-6713] Pr suggestions
nmayorsplit Apr 26, 2023
9ee74fe
[SDKS-6713] Pr suggestions
nmayorsplit Apr 26, 2023
0e889ef
[SDKS-6713] PR suggestions
nmayorsplit Apr 26, 2023
6599800
[SDKS-6713] Check String null or empty
nmayorsplit Apr 26, 2023
3eb10a1
Update java-client version
nmayorsplit May 4, 2023
b3ad83a
Update yaml default treatment
nmayorsplit May 5, 2023
3a7892e
[SDKS-6713] Add change log for virtual thread
nmayorsplit May 5, 2023
ea7bd72
Add java 20 in ci matrix
nmayorsplit May 5, 2023
810fb49
Update java version in matrix
nmayorsplit May 5, 2023
031f89b
Merge pull request #391 from splitio/SDKS-6713
nmayorsplit May 5, 2023
b04626e
[SDKS-6790] Update Yaml and Json to be default treatment control
nmayorsplit May 5, 2023
b8c1d7d
Merge branch 'development' into default-treatment
nmayorsplit May 5, 2023
bc7c0e9
[SDKS-6790] Updated changelog
nmayorsplit May 5, 2023
d34f215
Add LocalhostConstants
nmayorsplit May 5, 2023
8eb2f42
Merge pull request #393 from splitio/default-treatment
nmayorsplit May 8, 2023
df6d09f
[SDKS-6897] Update SplitClientImpl
nmayorsplit May 9, 2023
2f94bc8
[SDKS-6899] Update logs in InMemoryCacheImp
nmayorsplit May 9, 2023
c1b8b5a
[SDKS-6901] Update SplitNameValidator
nmayorsplit May 9, 2023
da0a0c6
Merge pull request #395 from splitio/SDKS-6899
nmayorsplit May 9, 2023
dd4ae12
[SDKS-6902] Update UniqueKeysTrackerImp
nmayorsplit May 9, 2023
8fc55ad
Merge branch 'dw' into SDKS-6901
nmayorsplit May 9, 2023
ff6a20c
Merge pull request #396 from splitio/SDKS-6901
nmayorsplit May 9, 2023
d23eb35
Merge branch 'dw' into SDKS-6897
nmayorsplit May 9, 2023
e1ad688
[SDKS-6897] Update SplitClient and SplitClientImpl
nmayorsplit May 9, 2023
522e0d5
[SDKS-6903] Update Evaluator and EvaluatorImp
nmayorsplit May 9, 2023
102a249
[SDKS-6897] Pr suggestion
nmayorsplit May 9, 2023
e72b643
Merge pull request #397 from splitio/SDKS-6902
nmayorsplit May 9, 2023
0bbeec6
Merge branch 'dw' into SDKS-6897
nmayorsplit May 9, 2023
af5cbc8
Merge pull request #394 from splitio/SDKS-6897
nmayorsplit May 9, 2023
82560e8
Merge pull request #398 from splitio/SDKS-6903
nmayorsplit May 9, 2023
945b88a
[SDKS-6937] Update ApiKeyCounter and HttpSegmentChangeFetcher
nmayorsplit May 9, 2023
cecf4f7
[SDKS-6938] Update SplitManager and SplitManagerImpl
nmayorsplit May 9, 2023
20f0a9e
Merge pull request #399 from splitio/SDKS-6937
nmayorsplit May 9, 2023
4f4918e
Merge pull request #400 from splitio/SDKS-6938
nmayorsplit May 9, 2023
1937166
[SDKS-6939] Update readme
nmayorsplit May 9, 2023
56ef7af
[SDKS-6939] Update readme
nmayorsplit May 10, 2023
846b1b1
Merge pull request #401 from splitio/SDKS-6939
nmayorsplit May 10, 2023
2ac301f
[SDKS-6960] Update FilterAdapter
nmayorsplit May 11, 2023
18e0aab
Merge pull request #402 from splitio/SDKS-6960
nmayorsplit May 11, 2023
e9e43c3
[SDKS-6961] Update Impression
nmayorsplit May 11, 2023
3dc1865
Merge pull request #403 from splitio/SDKS-6961
nmayorsplit May 11, 2023
b0adc3d
[SDKS-6965] Update ImpressionCounter
nmayorsplit May 11, 2023
5c1a7ba
[SDKS-6965] Update ImpressionCounter
nmayorsplit May 11, 2023
4265ddd
Merge pull request #404 from splitio/SDKS-6965
nmayorsplit May 11, 2023
0957ac6
[SDKS-6967] Update some localhost logs
nmayorsplit May 11, 2023
ddca9e4
[SDKS-6968] Update SplitManager interface
nmayorsplit May 11, 2023
db1d87b
Merge pull request #405 from splitio/SDKS-6967
nmayorsplit May 11, 2023
a56ee8a
Merge pull request #406 from splitio/SDKS-6968
nmayorsplit May 11, 2023
04d1dd0
Update some logs, comments and params
nmayorsplit May 11, 2023
edf2444
Merge pull request #407 from splitio/more-changes
nmayorsplit May 11, 2023
06295f3
Update readme
nmayorsplit May 11, 2023
e559c6b
Update changes and version to testing apps
nmayorsplit May 12, 2023
3dd4ee6
Update Impression
nmayorsplit May 12, 2023
a301bda
Update Impression counter
nmayorsplit May 12, 2023
85a50fe
Update client version
nmayorsplit May 12, 2023
6430759
revert internal change in Impression dto
mmelograno May 13, 2023
031a6a3
Update changelog
nmayorsplit May 15, 2023
8a27047
Update some pr suggestions and changelog
nmayorsplit May 16, 2023
05593e5
Change sdk_key to sdkKey
nmayorsplit May 16, 2023
6bc7705
Update client version to 4.7.2 for release
nmayorsplit May 16, 2023
5c67ae4
Merge pull request #408 from splitio/dw
nmayorsplit May 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
jdk:
- '8'
- '11'
- '19'
env:
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
Expand Down
22 changes: 13 additions & 9 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
4.7.2 (May 16, 2023)
- Updated default treatment to be control for yaml and json localhost.
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and javadoc comments.

4.7.1 (Apr 10, 2023)
- Added SHA for split and segment fetcher in localhost json.
- Added SHA for feature flag and segment fetcher in localhost json.
- Updated `org.yaml.snakeyaml` dependence to 2.0 for fixing a vulnerability.
- Fixed Redis integration, changing []dtos.Key to dtos.Key
- Fixed destroy for consumer mode.
Expand Down Expand Up @@ -53,7 +57,7 @@

4.4.0 (Jan 11, 2022)
- Added support for Redis to keep consistency across multiple SDK instances.
- Added logic to fetch multiple splits at once on GetTreatments/GetTreatmentsWithChanges.
- Added logic to fetch multiple feature flags at once on GetTreatments/GetTreatmentsWithChanges.

4.3.0 (Oct 19, 2021)
- Added support for the SDK to run with a custom implementation of it's internal storage modules, enabling customers to implement this caching in any storage technology of choice and connect it to the SDK instance itself which will use it instead of the in-memory structures.
Expand All @@ -67,7 +71,7 @@
4.2.0 (Jun 7, 2021)
- Updated SDK telemetry storage, metrics and updater to be more effective and send less often.
- Improved the synchronization flow to be more reliable in the event of an edge case generating delay in cache purge propagation, keeping the SDK cache properly synced.
- Fixed issue where the SDK was validating no Split had over 50 conditions (legacy code).
- Fixed issue where the SDK was validating no Feature flag had over 50 conditions (legacy code).
- Bumped guava version to 30.

4.1.6 (Apr 15, 2021)
Expand All @@ -80,7 +84,7 @@
- Updated Internal cache structure refactor.
- Updated Streaming revamp with several bugfixes and improved log messages.
- Added Cache-Control header for on-demand requests to sdk-server.
- Updated Localhost Client revamp & bugfix for missing splits.
- Updated Localhost Client revamp & bugfix for missing feature flags.

4.1.3 (Dec 2, 2020)
- Fix Issue when closing SSE Connection
Expand Down Expand Up @@ -111,7 +115,7 @@
- Added Impression observer.

3.3.3 (Apr 7, 2020)
- Fix issue regarding special characters come from split/segments fetchers.
- Fix issue regarding special characters come from feature flags/segments fetchers.

3.3.2 (Jan 24, 2020)
- Shade com.google.guava as well
Expand All @@ -130,7 +134,7 @@
- allow to push impressions more often than one every 30 seconds and events flush rate is now customizable

3.2.2
- log warn and not error when Split doesn't exist in the environment
- log warn and not error when Feature flag doesn't exist in the environment

3.2.1 (May 29, 2019)
- Fix issue with events not forwarding the value when sending properties as well.
Expand All @@ -147,7 +151,7 @@
- Support Yaml files for localhost mode

3.0.9 (Mar 21, 2019)
- Validate split names on getTreatment and manager calls
- Validate feature flag names on getTreatment and manager calls
- Validate traffic type name when calling track
- Check for multiple factories instantiated

Expand Down Expand Up @@ -201,7 +205,7 @@

2.1.0 (July 19th, 2017)
- Add support for new boolean and regular expression matchers
- Support for Dependency matcher: 'in split "xxx" treatments ["xxx","yyy"]'
- Support for Dependency matcher: 'in feature flag "xxx" treatments ["xxx","yyy"]'

2.0.4 (June 2nd, 2017)
- Support to destroy all clients and background processes before shutdown via splitFactory.destroy() or splitClient.destroy()
Expand Down Expand Up @@ -260,7 +264,7 @@

1.0.7
- Implement Factory pattern and expose Split manager
- Stop parsing a Split when there are more than 50 conditions to prevent DDOS.
- Stop parsing a Feature flag when there are more than 50 conditions to prevent DDOS.

1.0.6
- Replaced Jersey with HttpComponents
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
![Build Status](https://github.com/splitio/java-client/actions/workflows/ci-cd.yml/badge.svg?branch=master)

## Overview
This SDK is designed to work with Split, the platform for controlled rollouts, serving features to your users via the Split feature flag to manage your complete customer experience.
This SDK is designed to work with Split, the platform for controlled rollouts, serving features to your users via feature flags to manage your complete customer experience.

[![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)

Expand All @@ -22,19 +22,19 @@ public class App {
SplitClientConfig config = SplitClientConfig.builder()
.setBlockUntilReadyTimeout(10000)
.build();
SplitFactory splitFactory = SplitFactoryBuilder.build("SDK_API_KEY", config);
SplitFactory splitFactory = SplitFactoryBuilder.build("YOUR_SDK_KEY", config);
SplitClient client = splitFactory.client();
try {
client.blockUntilReady();
} catch (TimeoutException | InterruptedException e) {
// log & handle
}

String treatment = client.getTreatment("CUSTOMER_ID", "SPLIT_NAME");
String treatment = client.getTreatment("CUSTOMER_ID", "FEATURE_FLAG_NAME");
if (treatment.equals("on")) {
// Feature is enabled for this user!
// Feature flag is enabled for this user!
} else if (treatment.equals("off")) {
// Feature is disabled for this user!
// Feature flag is disabled for this user!
} else {
// Unable to perform evaluation.
}
Expand All @@ -61,7 +61,8 @@ To learn more about Split, contact hello@split.io, or get started with feature f
Split has built and maintains SDKs for:

* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
Expand All @@ -70,6 +71,10 @@ Split has built and maintains SDKs for:
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
* Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)

For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).

Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.split.client</groupId>
<artifactId>java-client-parent</artifactId>
<version>4.7.1</version>
<version>4.7.2</version>
</parent>
<artifactId>java-client</artifactId>
<packaging>jar</packaging>
Expand Down
28 changes: 14 additions & 14 deletions client/src/main/java/io/split/client/ApiKeyCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,45 @@ private static class ApyKeyCounterHolder
private static final ApiKeyCounter INSTANCE = new ApiKeyCounter();
}

public void add(String apiKey) {
public void add(String sdkKey) {
String message;
if (USED_API_KEYS.contains(apiKey)) {
message = String.format("factory instantiation: You already have %s with this API Key. " +
if (USED_API_KEYS.contains(sdkKey)) {
message = String.format("factory instantiation: You already have %s with this SDK Key. " +
"We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing " +
"it throughout your application.",
USED_API_KEYS.count(apiKey) == 1 ? "1 factory" : String.format("%s factories", USED_API_KEYS.count(apiKey)));
USED_API_KEYS.count(sdkKey) == 1 ? "1 factory" : String.format("%s factories", USED_API_KEYS.count(sdkKey)));
_log.warn(message);
} else if (!USED_API_KEYS.isEmpty()) {
message = "factory instantiation: You already have an instance of the Split factory. " +
"Make sure you definitely want this additional instance. We recommend keeping only one instance of " +
"the factory at all times (Singleton pattern) and reusing it throughout your application.“";
_log.warn(message);
}
USED_API_KEYS.add(apiKey);
USED_API_KEYS.add(sdkKey);
}

public void remove(String apiKey) {
USED_API_KEYS.remove(apiKey);
public void remove(String sdkKey) {
USED_API_KEYS.remove(sdkKey);
}

/**
* Just for test
* @param apiKey
* @param sdkKey
* @return
*/
@VisibleForTesting
boolean isApiKeyPresent(String apiKey) {
return USED_API_KEYS.contains(apiKey);
boolean isApiKeyPresent(String sdkKey) {
return USED_API_KEYS.contains(sdkKey);
}

/**
* Just for test
* @param apiKey
* @param sdkKey
* @return
*/
@VisibleForTesting
int getCount(String apiKey) {
return USED_API_KEYS.count(apiKey);
int getCount(String sdkKey) {
return USED_API_KEYS.count(sdkKey);
}

public Map<String, Long> getFactoryInstances() {
Expand All @@ -79,4 +79,4 @@ public Map<String, Long> getFactoryInstances() {
public void clearApiKeys() {
USED_API_KEYS.clear();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public SegmentChange fetch(String segmentName, long since, FetchOptions options)
_telemetryRuntimeProducer.recordSyncError(ResourceEnum.SEGMENT_SYNC, statusCode);
_log.error(String.format("Response status was: %s. Reason: %s", statusCode , response.getReasonPhrase()));
if (statusCode == HttpStatus.SC_FORBIDDEN) {
_log.error("factory instantiation: you passed a browser type api_key, " +
"please grab an api key from the Split console that is of type sdk");
_log.error("factory instantiation: you passed a client side type sdkKey, " +
"please grab an sdk key from the Split user interface that is of type server side");
}
throw new IllegalStateException(String.format("Could not retrieve segment changes for %s, since %s; http return code %s", segmentName, since, statusCode));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public SplitChange fetch(long since, FetchOptions options) {
return processSplitChange(splitChange, since);
} catch (FileNotFoundException f){
_log.warn(String.format("There was no file named %s found. " +
"We created a split client that returns default treatments for all features for all of your users. " +
"If you wish to return a specific treatment for a feature, enter the name of that feature name and " +
"We created a split client that returns default treatments for all feature flags for all of your users. " +
"If you wish to return a specific treatment for a feature flag, enter the name of that feature flag name and " +
"treatment name separated by whitespace in %s; one pair per line. Empty lines or lines starting with '#' are considered comments",
_file.getPath(), _file.getPath()), f);
throw new IllegalStateException("Problem fetching splitChanges: " + f.getMessage(), f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.split.client.dtos.Split;
import io.split.client.dtos.SplitChange;
import io.split.client.dtos.Status;
import io.split.client.utils.LocalhostConstants;
import io.split.client.utils.LocalhostSanitizer;
import io.split.engine.common.FetchOptions;
import io.split.engine.experiments.SplitChangeFetcher;
Expand Down Expand Up @@ -62,9 +63,9 @@ public SplitChange fetch(long since, FetchOptions options) {
}
split.status = Status.ACTIVE;
split.defaultTreatment = featureTreatment[1];
split.trafficTypeName = "user";
split.trafficAllocation = 100;
split.trafficAllocationSeed = 1;
split.trafficTypeName = LocalhostConstants.USER;
split.trafficAllocation = LocalhostConstants.SIZE_100;
split.trafficAllocationSeed = LocalhostConstants.SIZE_1;

Condition condition;
if (featureTreatment.length == 2) {
Expand All @@ -84,8 +85,8 @@ public SplitChange fetch(long since, FetchOptions options) {
return splitChange;
} catch (FileNotFoundException f) {
_log.warn("There was no file named " + _splitFile.getPath() + " found. " +
"We created a split client that returns default treatments for all features for all of your users. " +
"If you wish to return a specific treatment for a feature, enter the name of that feature name and " +
"We created a split client that returns default treatments for all feature flags for all of your users. " +
"If you wish to return a specific treatment for a feature flag, enter the name of that feature flag name and " +
"treatment name separated by whitespace in " + _splitFile.getPath() +
"; one pair per line. Empty lines or lines starting with '#' are considered comments", f);
throw new IllegalStateException("Problem fetching splitChanges: " + f.getMessage(), f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public void blockUntilReady() throws TimeoutException, InterruptedException {
}

@Override
public SplitView split(String featureName) {
if (!_splitToTreatmentsMap.containsKey(featureName)) {
public SplitView split(String featureFlagName) {
if (!_splitToTreatmentsMap.containsKey(featureFlagName)) {
return null;
}

return toSplitView(featureName, _splitToTreatmentsMap.get(featureName));
return toSplitView(featureFlagName, _splitToTreatmentsMap.get(featureFlagName));
}

void updateFeatureToTreatmentMap(Map<SplitAndKey, LocalhostSplit> featureToTreatmentMap) {
Expand All @@ -91,9 +91,9 @@ void updateFeatureToTreatmentMap(Map<SplitAndKey, LocalhostSplit> featureToTreat
}


private SplitView toSplitView(String featureName, Set<String> treatments) {
private SplitView toSplitView(String featureFlagName, Set<String> treatments) {
SplitView view = new SplitView();
view.name = featureName;
view.name = featureFlagName;
view.killed = false;
view.trafficType = null;
view.changeNumber = 0;
Expand Down
Loading