[GitHub] [commons-beanutils] XenoAmess edited a comment on pull request #27: [BEANUTILS-539] use ConcurrentHashMap insteadof WeakFastHashMap

2020-05-31 Thread GitBox


XenoAmess edited a comment on pull request #27:
URL: https://github.com/apache/commons-beanutils/pull/27#issuecomment-636474232


   also here is some guy contributed a concurrent weak hash map too : 
https://issues.apache.org/jira/browse/HARMONY-6434?jql=text%20~%20%22concurrent%20weak%20hash%20map%22
   
it also fails test 
MemoryLeakTestCase.testLocaleConvertUtilsBean_converters_memoryLeak.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-beanutils] XenoAmess edited a comment on pull request #27: [BEANUTILS-539] use ConcurrentHashMap insteadof WeakFastHashMap

2020-05-31 Thread GitBox


XenoAmess edited a comment on pull request #27:
URL: https://github.com/apache/commons-beanutils/pull/27#issuecomment-636470709


   > IIRC I think someone contributed a concurrent weak hash map either in this 
component or in commons-collections, there should be a JIRA ticket... AFK ATM...
   
   well `org.apache.commons.logging.impl.WeakHashtable` 's javadoc seems it be 
a good replacement of WeakFastHashMap here.
   
   but it fails test 
`MemoryLeakTestCase.testLocaleConvertUtilsBean_converters_memoryLeak`.
   I will try tracking it.
   
   `--`
   
   yes you are right, there be a jira ticket for a ConcurrentWeakHashMap, but 
nobody resolved it yet.
   https://issues.apache.org/jira/browse/COLLECTIONS-700



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-beanutils] XenoAmess edited a comment on pull request #27: [BEANUTILS-539] use ConcurrentHashMap insteadof WeakFastHashMap

2020-05-31 Thread GitBox


XenoAmess edited a comment on pull request #27:
URL: https://github.com/apache/commons-beanutils/pull/27#issuecomment-636465013


   > If your app does not need synchronization, you can use the map in "fast" 
mode.
   
   @garydgregory 
   Thanks. usually we need synchronization, and even when I need weak reference 
I will never clone the whole map everytime putting a single key-value pair.
   I really doubt why we shall do it this way.
   ```
   (from WeakFastHashMap.java)
   @Override
   public V put(final K key, final V value) {
   if (fast) {
   synchronized (this) {
   final Map temp = cloneMap(map);
   final V result = temp.put(key, value);
   map = temp;
   return result;
   }
   }
   synchronized (map) {
   return map.put(key, value);
   }
   }
   ```
   Any suggestions?
   Should we make a counter and add 1 every time we put a key-value pair, and 
clone it only when the counter exceed some point?



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-beanutils] XenoAmess edited a comment on pull request #27: [BEANUTILS-539] use ConcurrentHashMap insteadof WeakFastHashMap

2020-05-31 Thread GitBox


XenoAmess edited a comment on pull request #27:
URL: https://github.com/apache/commons-beanutils/pull/27#issuecomment-636465013


   > If your app does not need synchronization, you can use the map in "fast" 
mode.
   
   @garydgregory 
   Thanks. usually we need synchronization, and even when I need weak reference 
I will never clone the whole map everytime putting a single key-value pair.
   I really doubt why we shall do it this way.
   ```
   @Override
   public V put(final K key, final V value) {
   if (fast) {
   synchronized (this) {
   final Map temp = cloneMap(map);
   final V result = temp.put(key, value);
   map = temp;
   return result;
   }
   }
   synchronized (map) {
   return map.put(key, value);
   }
   }
   ```
   Any suggestions?
   Should we make a counter and add 1 every time we put a key-value pair, and 
clone it only when the counter exceed some point?



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org