Skip to content

Commit 772e7ab

Browse files
mnoman09mikeproeng37
authored andcommitted
Fix: null attribute check in decisionService and experimentUtils (#219)
1 parent 95a8057 commit 772e7ab

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

core-api/src/main/java/com/optimizely/ab/bucketing/DecisionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void saveVariation(@Nonnull Experiment experiment,
348348
String getBucketingId(@Nonnull String userId,
349349
@Nonnull Map<String, ?> filteredAttributes) {
350350
String bucketingId = userId;
351-
if (filteredAttributes.containsKey(ControlAttribute.BUCKETING_ATTRIBUTE.toString())) {
351+
if (filteredAttributes != null && filteredAttributes.containsKey(ControlAttribute.BUCKETING_ATTRIBUTE.toString())) {
352352
if (String.class.isInstance(filteredAttributes.get(ControlAttribute.BUCKETING_ATTRIBUTE.toString()))) {
353353
bucketingId = (String) filteredAttributes.get(ControlAttribute.BUCKETING_ATTRIBUTE.toString());
354354
logger.debug("BucketingId is valid: \"{}\"", bucketingId);

core-api/src/main/java/com/optimizely/ab/internal/ExperimentUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static boolean isUserInExperiment(@Nonnull ProjectConfig projectConfig,
6767
}
6868

6969
// if there are audiences, but no user attributes, the user is not in the experiment.
70-
if (attributes.isEmpty()) {
70+
if (attributes == null || attributes.isEmpty()) {
7171
return false;
7272
}
7373

0 commit comments

Comments
 (0)