From 0cced24f6a4374c041d99a8bb082f4b7e626d717 Mon Sep 17 00:00:00 2001 From: Marc Zimmermann Date: Mon, 11 Oct 2021 14:35:20 +0200 Subject: [PATCH] solve concurrency issue in WriteDocsToDatabase writeQueue.poll gives null when empty (which is possible without snychronizing the method call). This leads to a crash in writeData --- .../ratschlab/deidentifier/workflows/WriteDocsToDatabase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deidentifier-pipeline/src/main/java/org/ratschlab/deidentifier/workflows/WriteDocsToDatabase.java b/deidentifier-pipeline/src/main/java/org/ratschlab/deidentifier/workflows/WriteDocsToDatabase.java index ede8271..208bc19 100644 --- a/deidentifier-pipeline/src/main/java/org/ratschlab/deidentifier/workflows/WriteDocsToDatabase.java +++ b/deidentifier-pipeline/src/main/java/org/ratschlab/deidentifier/workflows/WriteDocsToDatabase.java @@ -51,7 +51,7 @@ public void doneHook() { } } - private void flushQueue() throws SQLException { + private synchronized void flushQueue() throws SQLException { List>> lst = new ArrayList<>(); while (!writeQueue.isEmpty()) {