This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push:
new a3808d71e Fixed:
ExampleJupiterTests.shouldExpirePreviousStatusOnCreateExampleStatus fails
intermittently with a duplicate key on ExampleStatus (OFBIZ-13697)
a3808d71e is described below
commit a3808d71e9ee54b9e347ce7f7e60c2e3c205c093
Author: Mridul Pathak <[email protected]>
AuthorDate: Sun Oct 18 11:38:23 2026 +0530
Fixed: ExampleJupiterTests.shouldExpirePreviousStatusOnCreateExampleStatus
fails intermittently with a duplicate key on ExampleStatus (OFBIZ-13697)
The createExample ECA creates the first ExampleStatus row and the test then
immediately calls createExampleStatus again. Both rows take the current time as
statusDate, which is part of the ExampleStatus primary key, so when both calls
happen in the same millisecond the second insert fails with a duplicate key.
The test now waits until the clock has moved past the statusDate of the row
created by the ECA before the second call.
---
.../org/apache/ofbiz/example/test/ExampleJupiterTests.groovy | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git
a/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
b/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
index 676b0bb4f..d36cdcede 100644
---
a/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
+++
b/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
@@ -18,6 +18,9 @@
*/
package org.apache.ofbiz.example.test
+import java.sql.Timestamp
+
+import org.apache.ofbiz.base.util.UtilDateTime
import org.apache.ofbiz.entity.GenericValue
import org.apache.ofbiz.service.ServiceUtil
import org.apache.ofbiz.service.ServiceValidationException
@@ -132,6 +135,14 @@ class ExampleJupiterTests implements JupiterTestHelper {
assert afterCreate.size() == 1
assert afterCreate[0].statusEndDate == null
+ // statusDate is part of the ExampleStatus primary key and
createExampleStatus sets it to the current
+ // time, so wait for the clock to move past the ECA-created row's
statusDate, otherwise both rows can
+ // share the same millisecond and the second insert fails with a
duplicate key.
+ Timestamp firstStatusDate = afterCreate[0].statusDate
+ while (!UtilDateTime.nowTimestamp().after(firstStatusDate)) {
+ Thread.onSpinWait()
+ }
+
Map<String, Object> secondStatusResult =
dispatcher.runSync('createExampleStatus', [
exampleId: exampleId,
statusId: STATUS_DEFINED,