Skip to main content
The Confidence Java SDK provides ultra-low latency feature flag evaluation for Java applications using the Confidence Resolver—a Rust-based resolver that runs natively.

Features

  • Local evaluation: Flag rules evaluate on your infrastructure in microseconds
  • OpenFeature compatible: Standard feature flag API through OpenFeature provider
  • Background sync: Flag rules and logging sync with Confidence in the background
  • High reliability: No network dependency at evaluation time

Installation

<dependency>
  <groupId>com.spotify.confidence</groupId>
  <artifactId>openfeature-provider-local</artifactId>
  <version>0.11.2</version>
</dependency>

Quickstart

import com.spotify.confidence.OpenFeatureLocalResolveProvider;
import dev.openfeature.sdk.OpenFeatureAPI;
import dev.openfeature.sdk.Client;
import dev.openfeature.sdk.MutableContext;

public class App {
    public static void main(String[] args) {
        // Initialize the Confidence provider
        OpenFeatureLocalResolveProvider provider =
            new OpenFeatureLocalResolveProvider("your-client-secret");

        // Register with OpenFeature
        OpenFeatureAPI.getInstance().setProviderAndWait(provider);
        Client client = OpenFeatureAPI.getInstance().getClient();

        // Evaluate a flag
        MutableContext ctx = new MutableContext("user-123");
        ctx.add("country", "US");

        Boolean value = client.getBooleanValue("my-feature-flag.enabled", false, ctx);
        System.out.println("Flag value: " + value);
    }
}

Resources