[ 
https://issues.apache.org/jira/browse/ARTEMIS-2095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16627602#comment-16627602
 ] 

ASF GitHub Bot commented on ARTEMIS-2095:
-----------------------------------------

Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2328#discussion_r220179880
  
    --- Diff: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/TypedProperties.java
 ---
    @@ -1056,4 +1107,26 @@ public static void setObjectProperty(final 
SimpleString key, final Object value,
              throw new ActiveMQPropertyConversionException(value.getClass() + 
" is not a valid property type");
           }
        }
    +
    +
    +
    +   private <T> T withWriteLock(Supplier<T> supplier) {
    +      long lock = this.writeLock();
    +      try {
    +         return supplier.get();
    +      } finally {
    +         this.unlockWrite(lock);
    +      }
    +   }
    +
    +   private <T> T withReadLock(Supplier<T> supplier) {
    --- End diff --
    
    Not only...other primitive suppliers overloads as well to avoid creating 
garbage for simple ops...And the other thing is that..a supplier is a quite 
elegant solution i admit, but sadly the JVM tends to not being able to drop the 
lambda allocation out...So I suggest a less elegant but more robust "old 
school" way to do the same (ie without lambdas).
    Sorry for being direct on it, but I'm writing while doing 10000 other 
things, didn't want to be rude :(



> TypedProperties thread safety
> -----------------------------
>
>                 Key: ARTEMIS-2095
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2095
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Michael Andre Pearce
>            Assignee: Michael Andre Pearce
>            Priority: Major
>
> Whilst TypedProperties is meant to have a single thread acting on it (and 
> this is the most typical interaction), there are occurrences where, it can be 
> acted on by other threads, when this occurs some concurrent modification 
> errors can occur.
> As such TypedProperties must be thread safe, but concurrency tuning should 
> factor in to be most performant for single thread.
>  
> e.g. 
> 2018-09-24 15:01:27,751 WARN 
> [org.apache.activemq.artemis.core.message.impl.CoreMessage] Error creating 
> String for message: : java.util.ConcurrentModificationException at 
> java.util.HashMap$HashIterator.nextNode(HashMap.java:1437) [rt.jar:1.8.0_102] 
> at java.util.HashMap$EntryIterator.next(HashMap.java:1471) [rt.jar:1.8.0_102] 
> at java.util.HashMap$EntryIterator.next(HashMap.java:1469) [rt.jar:1.8.0_102] 
> at 
> org.apache.activemq.artemis.utils.collections.TypedProperties.toString(TypedProperties.java:464)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to