Skip to content

Commit 9c68b57

Browse files
committed
fix
1 parent 19d7478 commit 9c68b57

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

core/src/main/java/com/styra/opa/wasm/OpaPolicy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public OpaPolicy data(JsonNode data) {
9393
}
9494

9595
public OpaPolicy input(String input) {
96+
if (this.dataAddr == -1) {
97+
// to keep the ordering: data - input - evaluate
98+
data("");
99+
}
100+
96101
var inputLen = input.getBytes().length;
97102
var delta = this.dataHeapPtr + inputLen - (wasm.memory().pages() * Memory.PAGE_SIZE);
98103
if (delta > 0) {

core/src/test/java/com/styra/opa/wasm/OpaTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public void highLevelAPI() throws Exception {
9898
@Test
9999
public void issue69() throws Exception {
100100
var policy = OpaPolicy.builder().withPolicy(issue69WasmFile).build();
101-
policy.data("");
102101

103102
policy.input("{\"method\":\"GET\"}");
104103
Assertions.assertTrue(Utils.getResult(policy.evaluate()).asBoolean());

0 commit comments

Comments
 (0)