-
Notifications
You must be signed in to change notification settings - Fork 31
fix(datafile-parsing): Prevent SDK from initializing if the datafile … #205
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
Conversation
…version is higher than the max version supported.
Pull Request Test Coverage Report for Build 579
💛 - Coveralls |
thomaszurkan-optimizely
left a comment
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'm approving but I had one question/concern about locking us out of future datafile versions.
| "Please use a version 2 or 3 datafile with this SDK."); | ||
| } | ||
|
|
||
| if (Integer.parseInt(projectConfig.getVersion()) > Integer.parseInt(Version.V4.version)) { |
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.
is this necessary?
| } | ||
|
|
||
| /** | ||
| * @return a {@link ProjectConfig} instance given a json string datafile |
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.
nit. JSON
| if (datafile == null) { | ||
| throw new ConfigParseException("Unable to parse null datafile."); | ||
| } | ||
| if (datafile.length() == 0) { |
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.
Why not use isEmpty?
| "Please use a version 2 or 3 datafile with this SDK."); | ||
| } | ||
|
|
||
| if (Integer.parseInt(projectConfig.getVersion()) > Integer.parseInt(Version.V4.version)) { |
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 wouldn't rely on datafile version being integer.
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.
Rather just create a list of supported and unsupported datafile versions.
aliabbasrizvi
left a comment
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.
Please address comments before merging.
| import com.optimizely.ab.error.NoOpErrorHandler; | ||
| import com.optimizely.ab.error.RaiseExceptionErrorHandler; | ||
| import com.optimizely.ab.internal.ControlAttribute; | ||
| import com.optimizely.ab.config.parser.DefaultConfigParser; |
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.
nit. Alphabetize
| } | ||
|
|
||
| private static final List<String> supportedVersions = Arrays.asList( | ||
| Version.V2.version, |
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.
nit. Indentation seems off. I think we have 4 spaces going on.
| } | ||
|
|
||
| @Test | ||
| public void withInvalidNewerDatafile() throws Exception { |
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.
nit. We can just say withInvalidDatafile or better withUnsupportedDatafile
Introduces a
Builderclass for theProjectConfigentity and moves construction of it out of the mainOptimizelyclass.Adds a check to ensure that we cannot initialize the
ProjectConfigwith newer datafile versions.https://optimizely.atlassian.net/browse/OASIS-3464