-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(init): build invalid instance if datafile cannot be parsed. #209
Conversation
@VisibleForTesting | ||
void initialize() { | ||
void initialize(@Nonnull String datafile, @Nullable ProjectConfig projectConfig) { | ||
if (projectConfig == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step de-couples the "building" of the Optimizely instance from the "initialization", which is where we start populating state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should probably discuss this. As far as I know for threading purposes, you would not reuse these components but instead, initialize a new instance. This actually brings up an interesting point of Android datafile handler: Should the datafile handler reinitialize or have a shutdown mechanism?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will take this offline.
Pull Request Test Coverage Report for Build 602
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@VisibleForTesting | ||
void initialize() { | ||
void initialize(@Nonnull String datafile, @Nullable ProjectConfig projectConfig) { | ||
if (projectConfig == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should probably discuss this. As far as I know for threading purposes, you would not reuse these components but instead, initialize a new instance. This actually brings up an interesting point of Android datafile handler: Should the datafile handler reinitialize or have a shutdown mechanism?
Summary
Optimizely
instance with theisValid
property set tofalse
. When accessing any of the SDK APIs, we will first check if the instance is valid before proceeding. If not valid, we will return the sensible defaults for each API.ErrorHandler
so the developer can be notified of these kinds of failures.This does constitute a breaking API change since we will no longer be throwing
ConfigParseException
from theBuilder.build()
method. As such, this will be released in version 3 of the SDK.Missing
This PR is to get initial feedback and is therefore missing unit tests for the invalid state in feature variable APIs. Will add those once I get some feedback regarding this approach.