You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2022/10/19 11:59:21 UTC

[plc4x] branch develop updated: fix(plc4j/spi): PLC4X-344 Handle concurrent access to transaction worklog.

This is an automated email from the ASF dual-hosted git repository.

ldywicki pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new cd5df7e5b fix(plc4j/spi): PLC4X-344 Handle concurrent access to transaction worklog.
cd5df7e5b is described below

commit cd5df7e5b43c6725d4e427181c85bb4b4d68699a
Author: Łukasz Dywicki <lu...@code-house.org>
AuthorDate: Wed Oct 19 13:58:55 2022 +0200

    fix(plc4j/spi): PLC4X-344 Handle concurrent access to transaction worklog.
    
    Signed-off-by: Łukasz Dywicki <lu...@code-house.org>
---
 .../plc4x/java/spi/transaction/RequestTransactionManager.java  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java
index 554c032cc..bdb307d13 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java
@@ -101,10 +101,12 @@ public class RequestTransactionManager {
 
     private void processWorklog() {
         while (runningRequests.size() < getNumberOfConcurrentRequests() && !workLog.isEmpty()) {
-            RequestTransaction next = workLog.remove();
-            this.runningRequests.add(next);
-            Future<?> completionFuture = executor.submit(next.operation);
-            next.setCompletionFuture(completionFuture);
+            RequestTransaction next = workLog.poll();
+            if (next != null) {
+                this.runningRequests.add(next);
+                Future<?> completionFuture = executor.submit(next.operation);
+                next.setCompletionFuture(completionFuture);
+            }
         }
     }