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

Add support for reusing `GrowthBook` object #81

Open buterbread1996 opened 1 week ago

buterbread1996 commented 1 week ago

The current growthbook.sdk.java.GrowthBook implementation can't be used like bean in Spring, because it reuse a growthbook.sdk.java.FeatureEvaluator#featureEvalContext without clearing. So in the first call growthBook.isOn(featureKey) returns right value, but in the next calls it returns false value always, because all calls (expect the first one) are interpretered like "circular dependency". The featureEvalContext is reseted only by goOutFromCircularLoop method that is called only in one place - when the force rule is applied.

I don't know what logic did you want to implement, but current logic looks like some strange.

Bohdan-Kim commented 1 week ago

Hello @buterbread1996 ! Thanks for reporting this issue. We've changed the logic of entering into circular loop.

Could you please try issues/81 SNAPSHOT? https://jitpack.io/#growthbook/growthbook-sdk-java/issues~81-SNAPSHOT

vazarkevych commented 5 days ago

Hi, @buterbread1996. Did you try that SNAPSHOT?