Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public <T> ProviderEvaluation<T> evaluate(
.build();
}

if (isEmpty(flag.allocations)) {
return error(defaultValue, ErrorCode.GENERAL, "Missing allocations for flag " + flag.key);
if (flag.allocations == null) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

dropping the guard here lets us fall through to the default return below.
Open to adding a short circuit instead if that makes it more readable here.

return error(defaultValue, ErrorCode.GENERAL, "Missing allocations for flag " + key);
}

final Date now = new Date();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.oneOf;
Expand Down Expand Up @@ -174,8 +175,8 @@ public void testNoAllocations() {

details = evaluator.evaluate(Integer.class, "empty-allocation", 23, ctx);
assertThat(details.getValue(), equalTo(23));
assertThat(details.getReason(), equalTo(ERROR.name()));
assertThat(details.getErrorCode(), equalTo(ErrorCode.GENERAL));
assertThat(details.getReason(), equalTo(DEFAULT.name()));
assertThat(details.getErrorCode(), nullValue());
}

private static Arguments[] flatteningTestCases() {
Expand Down
Loading