Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.2.1 (October 6, 2025)
- Updated dependencies to fix vulnerabilities.
- Added support for the shutdown feature.

1.2.0 (September 3, 2025)
- Updated `io.split.client` dependency to 4.16.1
- Updated `dev.openfeature` dependency to 1.17.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This SDK is compatible with Java 11 and higher.
<dependency>
<groupId>io.split.openfeature</groupId>
<artifactId>split-openfeature-provider</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
</dependency>
```
### Configure it
Expand Down
33 changes: 17 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.split.openfeature</groupId>
<artifactId>split-openfeature-provider</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<name>split-openfeature-provider-java</name>
<description>Split OpenFeature Java Provider</description>
<url>www.split.io</url>
Expand Down Expand Up @@ -49,11 +49,6 @@
<artifactId>java-client</artifactId>
<version>4.18.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand All @@ -65,16 +60,6 @@
<artifactId>sdk</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.20.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
Expand All @@ -85,6 +70,22 @@
<artifactId>maven-clean-plugin</artifactId>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>12.1.6</version>
<configuration>
<nvdApiKey>41aa3456-48f3-466a-a8ea-db1e84caba36</nvdApiKey>
<failBuildOnCVSS>7</failBuildOnCVSS>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/split/openfeature/SplitProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ public Map<String, Object> transformContext(EvaluationContext context) {
return context.asObjectMap();
}

@Override
public void shutdown() {
client.destroy();
}

private SplitResult evaluateTreatment(String key, EvaluationContext evaluationContext) {
String id = evaluationContext.getTargetingKey();
if (id == null || id.isEmpty()) {
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/io/split/openfeature/utils/Serialization.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.split.openfeature.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;

import dev.openfeature.sdk.ErrorCode;
import dev.openfeature.sdk.exceptions.ParseError;

import java.util.Map;
import io.split.client.utils.Json;

public class Serialization {

Expand All @@ -15,10 +13,8 @@ private Serialization() {

public static Map<String, Object> stringToMap(final String obj) {
try {
return new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.readValue(obj, Map.class);
} catch (JsonProcessingException e) {
return Json.fromJson(obj, Map.class);
} catch (Exception e) {
throw new ParseError(ErrorCode.PARSE_ERROR.name());
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/test/java/io/split/openfeature/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
public class ClientTest {
OpenFeatureAPI openFeatureAPI;
Client client;
SplitClient splitClient;

@BeforeEach
public void init() {
openFeatureAPI = OpenFeatureAPI.getInstance();
try {
SplitClientConfig config = SplitClientConfig.builder().splitFile("src/test/resources/split.yaml").build();
SplitClient client = SplitFactoryBuilder.build("localhost", config).client();
openFeatureAPI.setProviderAndWait(new SplitProvider(client));
splitClient = SplitFactoryBuilder.build("localhost", config).client();
openFeatureAPI.setProviderAndWait(new SplitProvider(splitClient));
} catch (URISyntaxException | IOException e) {
System.out.println("Unexpected Exception occurred initializing Split Provider.");
}
Expand Down Expand Up @@ -267,6 +268,13 @@ public void getObjectFailTest() {
assertNull(details.getVariant());
}

@Test
public void destroySplitClientTest() {
assertEquals("32", splitClient.getTreatment("key","int_feature"));
openFeatureAPI.shutdown();
assertEquals("control", splitClient.getTreatment("key","int_feature"));
}

private Value mapToValue(Map<String, Value> map) {
return new Value(new MutableStructure(map));
}
Expand Down
15 changes: 11 additions & 4 deletions src/test/java/io/split/openfeature/SplitProviderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,23 +420,23 @@ public void evalStructureComplexTest() {
Instant instant = Instant.ofEpochMilli(1665698754828L);
Value treatment = mapToValue(Map.of(
"string", new Value("blah"),
"int", new Value(10),
"int", new Value(10D),
"double", new Value(100D),
"bool", new Value(true),
"struct", mapToValue(Map.of(
"foo", new Value("bar"),
"baz", new Value(10),
"baz", new Value(10D),
"innerMap", mapToValue(Map.of(
"aa", new Value("bb"))))),
"list", new Value(
List.of(
new Value(1),
new Value(1D),
new Value(true),
mapToValue(Map.of(
"cc", new Value("dd")
)),
mapToValue(Map.of(
"ee", new Value(1)
"ee", new Value(1D)
)))),
"dateTime", new Value(instant)
));
Expand Down Expand Up @@ -525,6 +525,13 @@ public void trackTrafficTypeErrorTest() {
verifyNoInteractions(mockSplitClient);
}

@Test
public void destroySplitClientTest() {
SplitProvider provider = new SplitProvider(mockSplitClient);
provider.shutdown();
verify(mockSplitClient).destroy();
}

private Value mapToValue(Map<String, Value> map) {
return new Value(new MutableStructure(map));
}
Expand Down
Loading