https://www.growthbook.io/ logo
Join Slack
Powered by
# sdk-java
  • b

    brief-honey-45610

    09/21/2023, 4:03 AM
    set the channel topic: Ask questions here related to the Java SDK.
  • b

    brief-honey-45610

    09/21/2023, 4:03 AM
    set the channel description: Ask questions here related to the Java SDK.
  • r

    ripe-bear-58347

    10/27/2023, 2:00 PM
    Hey there. Sorry for being lazy, perhaps peeking into the source code is the best way to answer my questions, but still. I'm wondering about
    Tracking Callback
    and SDK's docs are not clarifying some points. What is the execution mode for the mentioned tracking callback? Is it being executed sequentially for the list of experiments, including blocking while waiting for the outcome, or it's kind of fire-and-forget semantics?
    r
    b
    • 3
    • 12
  • b

    brief-honey-45610

    01/10/2024, 4:48 PM
    Hi, how do we get the variant name (not variant id) from the Java/Kotlin SDK?
  • d

    dry-hairdresser-49475

    05/03/2024, 8:41 AM
    Hey, I was wondering when there is going to be a new java sdk release? The kotlin sdk seems to be updated more frequently?!
  • c

    cold-area-42494

    05/06/2024, 9:56 PM
    I think that java-sdk has a issue: java-sdk don't reconect if the growthbook proxy server restarts
  • f

    flaky-lion-33569

    06/25/2024, 9:12 PM
    Hi Team, i've raised a PR on growthbook-sdk-java to reduce some of the redundant JSON parsing for the backend use cases. https://github.com/growthbook/growthbook-sdk-java/pull/76/files
    r
    • 2
    • 1
  • r

    rapid-quill-56099

    07/30/2024, 9:27 PM
    Hi everyone, I'm looking at GB for a client who wants me to wrap up a CFML wrapper for it. The shortest path for this seems to be to wrap the Java SDK (as CF is a JVM language). We've written SDK wrappers for Unleash and LaunchDarkly in the past, but this is my first time looking at GB.
  • r

    rapid-quill-56099

    07/30/2024, 9:31 PM
    The first thing I noticed is LD, has an abstraction called 'datasources' that allow a pluggable datasoutce object to define the source of the data it uses. This is very useful for unit tests where I can have a local JSON file of settings there, but use the API datasource for production. GB has its
    GBFeaturesRepository
    class, but it's not really fleshed out to the same degree as • there is just one concrete implementation (based around HTTP request to an endpoint) • There is no repository implementation that can point to a local file • There is no interface I can implement to create my own implementations (My JVM language allows me to create classes that implement a Java interface, but I cannot directly extend a java class, so extending the GBFeaturesRepository class and overriding method is not an option)
    r
    • 2
    • 4
  • r

    rapid-quill-56099

    07/30/2024, 9:46 PM
    Next question-- I noticed some callback interfaces •
    ExperimentRunCallback
    •
    FeatureUsageCallback
    •
    TrackingCallback
    •
    FeatureRefreshCallback
    While none of these interface are annotated as
    @FunctionalInterface
    , the first 3 have a single abstract method, which means they could use a Lambda implementation as a SAM interface which is handy. The last interface has two methods however, so it wouldn't qualify as a SAM. Would you ever consider breaking out the
    onRefresh()
    and
    onError()
    behaviors to be a separate SAM interface. Or honestly, you could just just use the existing
    Consumer
    functional interface in the JDK really.
    c
    • 2
    • 1
  • r

    rapid-quill-56099

    07/30/2024, 10:24 PM
    Next question-- just want to make sure I'm clear on the purpose and usage of the main classes. The only class the docs (and Javadocs) really address the lifecycle of is the
    GBFeaturesRepository
    , which needs to be a singleton. As far as the •
    GBContext
    •
    GrowthBook
    classes go, I assumed the
    GrowthBook
    class at first would a singleton/client used for all threads on the app, but looking closer, it appears to accept a context, which is loaded with what appears to be a mix of app-wide data (enabled, features, qa mode,, etc) and user/request-specific data (attributes). If I'm understanding correctly that the attributes represent all the identifying tracking data for the current user on the site (id, email, url, custom attributes, etc) Is the expectation that a brand new
    GBContext
    instance AND
    GrowthBook
    instance would be created for each request coming in to a web app? Is there no singleton object representing the client that is re-used? In my experience writing a LaunchDarkly SDK, there are separate concepts of • the singleton client managing the features and configuration for the app • the transient representation of contexts (as they call them) containing specific user data A feature flag for LD is always evaluated by the singleton client in the context of a passed user/context object representing the current user. It would appear GB is wanting me to re-create the entire growthbook client with all its settings from scratch every time. Am I understanding this correctly?
    c
    • 2
    • 11
  • r

    rapid-quill-56099

    07/30/2024, 10:43 PM
    I'd also like to encourage the Java SDK developers to work on adding java docs to their source code. This class, for example, is one of the main classes for interacting with the SDK, and it basically has nothing in the way of method documentation. Other classes have some, but just a minimal sentence https://growthbook.github.io/growthbook-sdk-java/growthbook/sdk/java/GrowthBook.html
    • 1
    • 1
  • r

    rapid-quill-56099

    07/30/2024, 10:52 PM
    I see there is a feature of GB called "sticky buckets", and this portion of the docs on running experiments https://docs.growthbook.io/app/sticky-bucketing#1-ensure-you-are-using-a-compatible-sdk-version seems to imply that sticky buckets are only supported by the JavaScript and React SDKs. I see several classes and a package in the Java SDK javadocs which have references to sticky buckets, but the Java docs are pretty thin and the main docs on the Java SDK have no mentions of "sticky" in them at all https://docs.growthbook.io/lib/java Is this a supported feature of the Java SDK, and if so, where are the docs on how to use it? Looks like much of the source code for this was just committed last month.
    c
    • 2
    • 1
  • r

    rapid-quill-56099

    07/31/2024, 2:37 AM
    Getting some code working and it appears the Java SDK uses OkHttp which relies on the Kotlin standard library. That isn't really ideal to be needing to include Kotlin just to make HTTP requests. I'm already including one dynamic JVM language runtime for my app, I don't want to add a second transient one just to make HTTP calls, lol. Is OKHttp really providing something you can't get via the HTTP Client API that's been in the JDK for 6 years now? Or at least another HTTP API that's standalone. I know you have Java 8 in your compat list, but perhaps it's time to cut that loose.
    a
    c
    • 3
    • 24
  • s

    strong-mouse-55694

    07/31/2024, 1:53 PM
    @rapid-quill-56099 For reference, the Java SDK is externally maintained, last updated by @most-spoon-61816. Your feedback is good—it might be helpful to include as an issue.
    r
    m
    b
    • 4
    • 6
  • r

    rapid-quill-56099

    08/06/2024, 5:15 PM
    @strong-mouse-55694 @most-spoon-61816 Any chance of getting some responses to the messages in this channel and here https://growthbookusers.slack.com/archives/C01T6Q1SVFV/p1722439563025909 My client is losing faith that GrowthBook will be a viable option for them.
    r
    • 2
    • 3
  • a

    ancient-car-96302

    08/10/2024, 12:20 PM
    Hey #C05SUUN7BM5! Who uses GrowthBook Java SDK with Java 8, 9, 10 could you please paste "+" sign? We are thinking about updating
    sourceCompatibility
    version in our SDK. In nobody case the version can be updated.
    👍 1
    t
    • 2
    • 1
  • m

    millions-match-28781

    08/14/2024, 5:57 PM
    I have a question about the GBFeatureRepository class. It's meant to be created once, and then shared, but I don't see any concurrency protections on any of its fields. I'm wondering if I'm missing something. Areas I would have expected might have concurrency concerns: • featuresJson, since it's updated in a background thread • the cache expiration check, so that multiple threads don't refresh • refreshCallbacks stored using one of the concurrency safe list implementations instead of just ArrayList How should I understand how threads coexist with this class?
    r
    • 2
    • 14
  • r

    rapid-quill-56099

    09/09/2024, 6:05 PM
    @calm-dog-24239 Thanks for the replies, however you didn't really answer question 1. You just copied and pasted the docs which I have already read that explain what the features do conceptually. This does not address my questions concerning the architecture of the Java SDK and the difference between registering some callbacks on the growthBook context class and other callbacks on the Growthbook class which seems inconsistent.
    r
    • 2
    • 2
  • c

    calm-waitress-28774

    09/24/2024, 4:10 PM
    Hi! We've been having issues with a few recent Java SDK releases. Some past releases have just caused excessive new logging that we had to turn off, but this past patch release broke our client usage all over our codebase with a brand new error with zero code changes on our end:
    Copy code
    Unexpected error occurred: Not a JSON Object: null
    java.lang.IllegalStateException: Not a JSON Object: null
    	at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:165)
    Just curious if y'all have considered following semantic versioning, or at least maybe writing some release notes, so we can have a better idea of what's changing without digging through the raw version diffs?
    r
    c
    +2
    • 5
    • 8
  • b

    bland-crowd-96288

    09/29/2024, 9:56 AM
    Hi, I would like to know how to call an A/B experiment , such that feature flag changes its value for different user ids. My feature flag is boolean True by default. as per the documentation, I have implemented :
    Copy code
    1. final TrackingCallback trackingCallback = new TrackingCallback() {
    				@Override
    				public <ValueType> void onTrack(final Experiment<ValueType> experiment, final ExperimentResult<ValueType> experimentResult) {
    					System.out.println("Experiment Id: " + experiment.getKey());
    					System.out.println("Variation Id: " + experimentResult.getVariationId());
    				}};
    
    
    2. setting the GB Context (attributesStr has ids for eg. ("id":"123") : 	
    final GBContext context = GBContext.builder().featuresJson(featuresJson).trackingCallback(trackingCallback).attributesJson(attributesStr).build();
    I am running this experiment for a single user id, i have hard-coded it right now. value of feature flag is not changing as per the "Test feature rule" that we have in Growthbook. Please guide me here. Stuck here
  • f

    flaky-noon-11399

    10/14/2024, 11:54 AM
    Hey Team, a customer who is cloud hosting GrowthBook has mentioned that when using JSON as the feature type and the value is null it will skip the Forced Rule. They are experiencing this on latest
    com.github.growthbook:growthbook-sdk-java:0.9.91
    SDK. For example when they send
    app_version
    2.82.0 or greater, their first rule was skipped if value is
    null
    . This works with boolean or string value but does not work with JSON. Please can you investigate why the JSON data type on the Java SDK accepting null value for forced rules?
    c
    b
    • 3
    • 9
  • f

    flaky-noon-11399

    10/15/2024, 10:38 AM
    Hey Team, a customer is requesting if this artefact can be pushed to Maven Central?
    m
    c
    • 3
    • 6
  • f

    flaky-noon-11399

    11/12/2024, 9:48 AM
    Hey Team, a customer has asked if a new version of the Java SDK is on the roadmap?
    c
    f
    • 3
    • 6
  • f

    flaky-noon-11399

    02/10/2025, 4:36 PM
    Hi @most-spoon-61816, do you know when this will go live? An Enterprise customer is facing a blocker with the bug
    c
    • 2
    • 5
  • m

    most-spoon-61816

    02/10/2025, 4:41 PM
    Hi @flaky-noon-11399, @calm-dog-24239 and @ancient-car-96302 please team assist here asap
    thankyou 1
  • f

    flaky-noon-11399

    02/21/2025, 10:30 AM
    Hi @most-spoon-61816 @calm-dog-24239, hope you're well. Is there an ETA I can share with the customer on when this will be merged?
    c
    • 2
    • 21
  • f

    flaky-noon-11399

    05/28/2025, 3:48 PM
    Hi Team, one of our Enterprise customers has asked the following (see screenshot) what would be the recommended approach here? Are there any breaking changes or implementation updates with the upgrade?
    c
    • 2
    • 3