You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/09/20 05:51:06 UTC

[isis] branch v2 updated: ISIS-1974: fixes PoWriter to access blocks thread-safe

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

ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/v2 by this push:
     new 8a84f64  ISIS-1974: fixes PoWriter to access blocks thread-safe
8a84f64 is described below

commit 8a84f64511392b75491163cd4008c2f633f92624
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Sep 20 07:50:57 2018 +0200

    ISIS-1974: fixes PoWriter to access blocks thread-safe
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1974
---
 .../isis/core/runtime/services/i18n/po/PoWriter.java   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/i18n/po/PoWriter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/i18n/po/PoWriter.java
index 6bc2d7a..efbf9c2 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/i18n/po/PoWriter.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/i18n/po/PoWriter.java
@@ -36,12 +36,12 @@ class PoWriter extends PoAbstract {
     public static Logger LOG = LoggerFactory.getLogger(PoWriter.class);
 
     private static class Block {
-        private final String msgId;
+        //private final String msgId;
         private final SortedSet<String> contexts = _Sets.newTreeSet();
         private String msgIdPlural;
 
-        private Block(final String msgId) {
-            this.msgId = msgId;
+        private Block(/*final String msgId*/) {
+            //this.msgId = msgId;
         }
     }
 
@@ -122,7 +122,9 @@ class PoWriter extends PoAbstract {
             return null;
         }
         final Block block = blockFor(msgId);
-        block.contexts.add(context);
+        synchronized(block) {
+            block.contexts.add(context);
+        }
 
         return msgId;
     }
@@ -134,8 +136,10 @@ class PoWriter extends PoAbstract {
             return null;
         }
         final Block block = blockFor(msgId);
-        block.contexts.add(context);
-        block.msgIdPlural = msgIdPlural;
+        synchronized(block) {
+            block.contexts.add(context);
+            block.msgIdPlural = msgIdPlural;    
+        }
 
         return null;
     }
@@ -143,7 +147,7 @@ class PoWriter extends PoAbstract {
     private synchronized Block blockFor(final String msgId) {
         Block block = blocksByMsgId.get(msgId);
         if(block == null) {
-            block = new Block(msgId);
+            block = new Block(/*msgId*/);
             blocksByMsgId.put(msgId, block);
         }
         return block;