Skip to content

Commit 4f2c023

Browse files
authored
feat: switch to io.github.gzsombor json logic lib (#1786)
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
1 parent d549d7b commit 4f2c023

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

providers/flagd/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<io.grpc.version>1.79.0</io.grpc.version>
2020
<!-- caution - updating this will break compatibility with older protobuf-java versions -->
2121
<protobuf-java.min.version>3.25.6</protobuf-java.min.version>
22-
<com.vmlens.version>1.2.27</com.vmlens.version>
22+
<com.vmlens.version>1.2.28</com.vmlens.version>
2323
<!-- Transitive flagd-core version -->
2424
<flagd-core.version>[1.0.0,2.0.0)</flagd-core.version>
2525
</properties>
@@ -239,6 +239,10 @@
239239
<include>**/*CTest.java</include>
240240
</includes>
241241
<failIfNoTests>true</failIfNoTests>
242+
<environmentVariables>
243+
<!-- disable JsonLogic compilation to reduce VMLens interleaving combinations -->
244+
<FLAGD_DISABLE_TARGETING_COMPILATION>true</FLAGD_DISABLE_TARGETING_COMPILATION>
245+
</environmentVariables>
242246
</configuration>
243247
</execution>
244248
</executions>

tools/flagd-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
</dependency>
4848

4949
<dependency>
50-
<groupId>io.github.jamsesso</groupId>
50+
<groupId>io.github.gzsombor</groupId>
5151
<artifactId>json-logic-java</artifactId>
52-
<version>1.1.0</version>
52+
<version>1.1.3</version>
5353
</dependency>
5454

5555
<!-- Override gson usage of json-logic-java-->

tools/flagd-core/src/main/java/dev/openfeature/contrib/tools/flagd/core/targeting/Operator.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,26 @@ public class Operator {
1919
static final String TARGET_KEY = "targetingKey";
2020
static final String TIME_STAMP = "timestamp";
2121

22+
static final String DISABLE_TARGETING_COMPILATION_ENV_VAR_NAME = "FLAGD_DISABLE_TARGETING_COMPILATION";
23+
2224
private final JsonLogic jsonLogicHandler;
2325

2426
/**
2527
* Construct a targeting operator.
28+
* Compiles targeting rules into native Java methods by default, unless the
29+
* FLAGD_DISABLE_TARGETING_COMPILATION environment variable is set.
2630
*/
2731
public Operator() {
28-
jsonLogicHandler = new JsonLogic();
32+
this(!Boolean.parseBoolean(System.getenv(DISABLE_TARGETING_COMPILATION_ENV_VAR_NAME)));
33+
}
34+
35+
/**
36+
* Construct a targeting operator.
37+
*
38+
* @param compileExpressions whether to compile JsonLogic expressions for better performance
39+
*/
40+
public Operator(boolean compileExpressions) {
41+
jsonLogicHandler = new JsonLogic(compileExpressions);
2942
jsonLogicHandler.addOperation(new Fractional());
3043
jsonLogicHandler.addOperation(new SemVer());
3144
jsonLogicHandler.addOperation(new StringComp(StringComp.Type.STARTS_WITH));

0 commit comments

Comments
 (0)