From 2d82d9803354f9306a9b31743a52a5f9c4ed58ca Mon Sep 17 00:00:00 2001 From: msohailhussain Date: Fri, 13 Nov 2020 12:17:26 -0800 Subject: [PATCH 1/5] feature enabled fix. --- .../java/com/optimizely/ab/Optimizely.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core-api/src/main/java/com/optimizely/ab/Optimizely.java b/core-api/src/main/java/com/optimizely/ab/Optimizely.java index f06af8082..666582d4f 100644 --- a/core-api/src/main/java/com/optimizely/ab/Optimizely.java +++ b/core-api/src/main/java/com/optimizely/ab/Optimizely.java @@ -425,15 +425,6 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig, if (featureDecision.decisionSource != null) { decisionSource = featureDecision.decisionSource; } - sendImpression( - projectConfig, - featureDecision.experiment, - userId, - copiedAttributes, - featureDecision.variation, - featureKey, - decisionSource.toString(), - featureEnabled); if (featureDecision.variation != null) { // This information is only necessary for feature tests. @@ -448,6 +439,15 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig, featureEnabled = true; } } + sendImpression( + projectConfig, + featureDecision.experiment, + userId, + copiedAttributes, + featureDecision.variation, + featureKey, + decisionSource.toString(), + featureEnabled); DecisionNotification decisionNotification = DecisionNotification.newFeatureDecisionNotificationBuilder() .withUserId(userId) From 2c055bd5773f6831fb5cfb1994a7290a65644554 Mon Sep 17 00:00:00 2001 From: Sohail Hussain Date: Fri, 13 Nov 2020 14:06:50 -0800 Subject: [PATCH 2/5] experiment can be null --- .../java/com/optimizely/ab/Optimizely.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/core-api/src/main/java/com/optimizely/ab/Optimizely.java b/core-api/src/main/java/com/optimizely/ab/Optimizely.java index f06af8082..8f70192d9 100644 --- a/core-api/src/main/java/com/optimizely/ab/Optimizely.java +++ b/core-api/src/main/java/com/optimizely/ab/Optimizely.java @@ -252,10 +252,10 @@ private void sendImpression(@Nonnull ProjectConfig projectConfig, * @param ruleType It can either be experiment in case impression event is sent from activate or it's feature-test or rollout */ private void sendImpression(@Nonnull ProjectConfig projectConfig, - @Nonnull Experiment experiment, + Experiment experiment, @Nonnull String userId, @Nonnull Map filteredAttributes, - @Nonnull Variation variation, + Variation variation, @Nonnull String flagKey, @Nonnull String ruleType, @Nonnull boolean enabled) { @@ -425,15 +425,6 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig, if (featureDecision.decisionSource != null) { decisionSource = featureDecision.decisionSource; } - sendImpression( - projectConfig, - featureDecision.experiment, - userId, - copiedAttributes, - featureDecision.variation, - featureKey, - decisionSource.toString(), - featureEnabled); if (featureDecision.variation != null) { // This information is only necessary for feature tests. @@ -449,6 +440,16 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig, } } + sendImpression( + projectConfig, + featureDecision.experiment, + userId, + copiedAttributes, + featureDecision.variation, + featureKey, + decisionSource.toString(), + featureEnabled); + DecisionNotification decisionNotification = DecisionNotification.newFeatureDecisionNotificationBuilder() .withUserId(userId) .withAttributes(copiedAttributes) From a63eb0fda24e2fcd6245f2e0716c894780b3b3b0 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Sat, 14 Nov 2020 05:55:37 +0500 Subject: [PATCH 3/5] removed code repetetion --- .../src/main/java/com/optimizely/ab/Optimizely.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/core-api/src/main/java/com/optimizely/ab/Optimizely.java b/core-api/src/main/java/com/optimizely/ab/Optimizely.java index a6354efae..6bb9b23b2 100644 --- a/core-api/src/main/java/com/optimizely/ab/Optimizely.java +++ b/core-api/src/main/java/com/optimizely/ab/Optimizely.java @@ -439,16 +439,6 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig, featureEnabled = true; } } - sendImpression( - projectConfig, - featureDecision.experiment, - userId, - copiedAttributes, - featureDecision.variation, - featureKey, - decisionSource.toString(), - featureEnabled); - sendImpression( projectConfig, featureDecision.experiment, From d2e14b4a9577b47f07026f884d75b7203bdbef8b Mon Sep 17 00:00:00 2001 From: "FOLIO3PK\\muhammadnoman" Date: Mon, 16 Nov 2020 23:35:37 +0500 Subject: [PATCH 4/5] Added Nonnull check --- core-api/src/main/java/com/optimizely/ab/Optimizely.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-api/src/main/java/com/optimizely/ab/Optimizely.java b/core-api/src/main/java/com/optimizely/ab/Optimizely.java index 6bb9b23b2..2e62cee90 100644 --- a/core-api/src/main/java/com/optimizely/ab/Optimizely.java +++ b/core-api/src/main/java/com/optimizely/ab/Optimizely.java @@ -252,10 +252,10 @@ private void sendImpression(@Nonnull ProjectConfig projectConfig, * @param ruleType It can either be experiment in case impression event is sent from activate or it's feature-test or rollout */ private void sendImpression(@Nonnull ProjectConfig projectConfig, - Experiment experiment, + @Nonnull Experiment experiment, @Nonnull String userId, @Nonnull Map filteredAttributes, - Variation variation, + @Nonnull Variation variation, @Nonnull String flagKey, @Nonnull String ruleType, @Nonnull boolean enabled) { From 64b0bac44a65132e389dc46943edd6c45e57116f Mon Sep 17 00:00:00 2001 From: "FOLIO3PK\\muhammadnoman" Date: Mon, 16 Nov 2020 23:52:52 +0500 Subject: [PATCH 5/5] Added annotation of nullable as experiment and variation can be null --- core-api/src/main/java/com/optimizely/ab/Optimizely.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-api/src/main/java/com/optimizely/ab/Optimizely.java b/core-api/src/main/java/com/optimizely/ab/Optimizely.java index 2e62cee90..2f63ef535 100644 --- a/core-api/src/main/java/com/optimizely/ab/Optimizely.java +++ b/core-api/src/main/java/com/optimizely/ab/Optimizely.java @@ -252,10 +252,10 @@ private void sendImpression(@Nonnull ProjectConfig projectConfig, * @param ruleType It can either be experiment in case impression event is sent from activate or it's feature-test or rollout */ private void sendImpression(@Nonnull ProjectConfig projectConfig, - @Nonnull Experiment experiment, + @Nullable Experiment experiment, @Nonnull String userId, @Nonnull Map filteredAttributes, - @Nonnull Variation variation, + @Nullable Variation variation, @Nonnull String flagKey, @Nonnull String ruleType, @Nonnull boolean enabled) {