growthbook / growthbook-sdk-java

The Java SDK for GrowthBook (JVM, Android)
https://docs.growthbook.io/lib/java
MIT License
7 stars 10 forks source link

Reduce Exceptions in the ConditionEvaluator #48

Closed nnusse closed 1 month ago

nnusse commented 2 months ago

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:

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

Bohdan-Kim commented 1 month ago

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 commented 1 month ago

It looks good