From f5e84c0785b826d33368c2297e744df2b1cd99fc Mon Sep 17 00:00:00 2001 From: Ilkka Kaakkola Date: Mon, 28 Nov 2022 14:19:20 +0200 Subject: [PATCH] fix: correctly compare equality of Double and Long --- .../engine/data/inmemory/util/QueryUtil.java | 8 +++--- .../MemoryExecutionDataManagerTest.java | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/flowable-inmemory-data/src/main/java/org/flowable/engine/data/inmemory/util/QueryUtil.java b/modules/flowable-inmemory-data/src/main/java/org/flowable/engine/data/inmemory/util/QueryUtil.java index 1caeee17150..f8af6b73461 100644 --- a/modules/flowable-inmemory-data/src/main/java/org/flowable/engine/data/inmemory/util/QueryUtil.java +++ b/modules/flowable-inmemory-data/src/main/java/org/flowable/engine/data/inmemory/util/QueryUtil.java @@ -302,7 +302,7 @@ private static boolean matchLongVariable(QueryOperator op, Long requested, Long if (actual == null) { return false; } - return requested == actual; + return actual.equals(requested); case EXISTS: return actual != null; case GREATER_THAN: @@ -333,7 +333,7 @@ private static boolean matchLongVariable(QueryOperator op, Long requested, Long if (actual == null) { return true; } - return requested != actual; + return !actual.equals(requested); case NOT_EXISTS: return actual == null; default: @@ -348,7 +348,7 @@ private static boolean matchDoubleVariable(QueryOperator op, Double requested, D if (actual == null) { return false; } - return requested == actual; + return actual.equals(requested); case EXISTS: return actual != null; case GREATER_THAN: @@ -379,7 +379,7 @@ private static boolean matchDoubleVariable(QueryOperator op, Double requested, D if (actual == null) { return true; } - return requested != actual; + return !actual.equals(requested); case NOT_EXISTS: return actual == null; default: diff --git a/modules/flowable-inmemory-data/src/test/java/org/flowable/engine/data/inmemory/execution/MemoryExecutionDataManagerTest.java b/modules/flowable-inmemory-data/src/test/java/org/flowable/engine/data/inmemory/execution/MemoryExecutionDataManagerTest.java index c00f798629f..d79ab036365 100644 --- a/modules/flowable-inmemory-data/src/test/java/org/flowable/engine/data/inmemory/execution/MemoryExecutionDataManagerTest.java +++ b/modules/flowable-inmemory-data/src/test/java/org/flowable/engine/data/inmemory/execution/MemoryExecutionDataManagerTest.java @@ -199,6 +199,31 @@ public void testOrQueryExecution() throws InterruptedException { processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true); processEngine.close(); } + } + + @Test + public void testQueryExecutionVariableNumericValues() { + Deployment deployment = processEngine.getRepositoryService().createDeployment() + .addClasspathResource("org/flowable/engine/test/inmemory/triggerableExecution.bpmn20.xml").deploy(); + + try { + processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 100, "test-variable-2", 100.1)); + processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 100, "test-variable-2", 100.1)); + processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 200, "test-variable-2", 200.1)); + processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 200, "test-variable-2", 200.1)); + processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 300, "test-variable-2", 300.1)); + + assertThat(query().variableValueEquals("test-variable-1", 100).list()).hasSize(2); + assertThat(query().variableValueEquals("test-variable-1", 200).list()).hasSize(2); + assertThat(query().variableValueLessThanOrEqual("test-variable-1", 200).list()).hasSize(4); + + assertThat(query().variableValueEquals("test-variable-2", 100.1).list()).hasSize(2); + assertThat(query().variableValueEquals("test-variable-2", 200.1).list()).hasSize(2); + assertThat(query().variableValueLessThanOrEqual("test-variable-2", 200.1).list()).hasSize(4); + } finally { + processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true); + processEngine.close(); + } }