Skip to content
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

Reduce Exceptions in the ConditionEvaluator #48

Merged

Conversation

nnusse
Copy link
Contributor

@nnusse nnusse commented Apr 19, 2024

Hello,

this PR should reduce the amount of exceptions that the ConditionEvaluator would throw, if it receives incoming null values for the evaluation.
There are some sections in the code that are not able to handle that properly. I received already the following exceptions (in the form of stack traces on the stderr) in one of my applications:

  • java.lang.IllegalStateException: Not a JSON Primitive: null
  • java.lang.UnsupportedOperationException: JsonNull

The SDK is catching all exceptions and additionally prints the stacktrace to the standard error output channel. Unfortunately this can also harm consumers of this library, because some applications might require a specific format of messages that get printed to the error or normal output channels. From my point of view i think it is really worth it to work on the issue (#23), but i think as well, that it is always good to handle errors properly.

I also adjusted the test to let them fail, if exceptions will occur that are not expected to appear under a specific test condition. I'm not really happy with the changes that i had to introduce in the tests, but i couldn't come up with a better solution, unfortunately the SDK is catching every error which makes it hard to check if a specific error occurred.

I hope that you see value in this PR.

All the best,
Norman

@vazarkevych vazarkevych changed the base branch from main to release/0.9.3 May 14, 2024 08:39
@Bohdan-Kim
Copy link
Contributor

Hello @nnusse!
There was a merge conflict with release/0.93 branch.
The test ConditionEvaluatorTest#test_evaluateCondition_testCases() is failing after resolving merge conflict.

@Bohdan-Kim
Copy link
Contributor

It looks good

@vazarkevych vazarkevych merged commit b5a2402 into growthbook:release/0.9.3 May 22, 2024
vazarkevych added a commit that referenced this pull request May 27, 2024
* Changelog v0.5.1 v0.5.2 (#53)

Co-authored-by: Bohdan Akimenko <bohdan.akimenko@kevychsolutions.com>

* Reduce Exceptions in the ConditionEvaluator (#48)

* reduce amount of exceptions based on serialized null values and add break statements for most of the switch-cases.

* add new test cases and ensure that unexpected exceptions let the tests fail.

* trial commit

* undo trial commit

* Add attributeDataType checking for NULL.

* adjust test definition and evaluation implementation.

---------

Co-authored-by: Bohdan Akimenko <bohdan.akimenko@kevychsolutions.com>

* Issue #52 (#55)

* retryOnFailure argument was added

* if a flag is changed before the application reconnects, that change is not reflected.

---------

Co-authored-by: Bohdan Akimenko <bohdan.akimenko@kevychsolutions.com>

* Changelog v0.5.3 (#56)

Co-authored-by: Bohdan Akimenko <bohdan.akimenko@kevychsolutions.com>

* Changelogs v0.5.4 v0.6.0 were implemented (#59)

Co-authored-by: Bohdan Akimenko <bohdan.akimenko@kevychsolutions.com>

* Cyrillic symbols were removed

* Add check & unit tests in case the feature value is a collection impl (#46)

* Add check & unit tests in case the feature value is a collection implementation (set, list)

* Fixing errors after merge

* Fixing failing test raised by merge

---------

Co-authored-by: vu-linh <138560515+vu-linh@users.noreply.github.com>
Co-authored-by: Bohdan Akimenko <bohdan.akimenko@kevychsolutions.com>

* The SDK version was increased

---------

Co-authored-by: Bohdan Akimenko <bohdan.akimenko@kevychsolutions.com>
Co-authored-by: Norm <88192291+nnusse@users.noreply.github.com>
Co-authored-by: vulinh64 <35946488+vulinh64@users.noreply.github.com>
Co-authored-by: vu-linh <138560515+vu-linh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants