You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by GitBox <gi...@apache.org> on 2022/10/01 11:11:43 UTC

[GitHub] [aries-rsa] ponziani opened a new pull request, #43: fix ConcurrentModificationException in ServiceExportsRepository

ponziani opened a new pull request, #43:
URL: https://github.com/apache/aries-rsa/pull/43

   When using Aries RSA we regularly experience a ConcurrentModificationException in ServiceExportsRepository. This PR contains a very simple and straightforward fix for that.


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@aries.apache.org

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


[GitHub] [aries-rsa] timothyjward commented on pull request #43: fix ConcurrentModificationException in ServiceExportsRepository

Posted by GitBox <gi...@apache.org>.
timothyjward commented on PR #43:
URL: https://github.com/apache/aries-rsa/pull/43#issuecomment-1264367675

   Looking at the map access there is some very inconsistent synchronisation here. I’m not sure that this fix will actually eliminate the issue. 


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@aries.apache.org

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


Re: [PR] fix ConcurrentModificationException in ServiceExportsRepository [aries-rsa]

Posted by "amichair (via GitHub)" <gi...@apache.org>.
amichair commented on PR #43:
URL: https://github.com/apache/aries-rsa/pull/43#issuecomment-2134837600

   I've opened and fixed https://issues.apache.org/jira/browse/ARIES-2130 based on this PR.
   
   Note that the link and quote above about LinkedHashMap specifically refer to access-ordered linked hash maps, in which a get operation can modify it. However, the default for LinkedHashMap when using the no-args constructor, as in our case, is to use insertion order rather than access order, so there shouldn't be any modifications caused by the get operations afaik.
   
   As for replacing keySet iteration followed by get with a single values iteration, I applied that as well though it has nothing to do with concurrency, just for readability and performance. In general, one should iterate over the keySet when only keys are needed, iterate over values when only values are needed, and iterate over entrySet when both are needed as a pair.
   
   Finally, for the concurrency fix, there are a couple of methods that were accessing the exportsMap (and the lists within it that also need to be accessed concurrently) that weren't synchronized, so I added it as in your fix, which I think should solve the problem. However, the commit above also synchronized two of the ExportRegistrationHolder methods that have nothing to do with this map, and without a stack trace or additional info or explanation it's hard to tell if there was indeed another problem encountered there or this was just added 'just in case' but it is unclear why. I'm reluctant to add them since unnecessary synchronization can also lead to deadlocks, so they should be used with caution. If you have additional info on this please open a separate issue with the details.


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@aries.apache.org

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


[GitHub] [aries-rsa] ponziani commented on pull request #43: fix ConcurrentModificationException in ServiceExportsRepository

Posted by GitBox <gi...@apache.org>.
ponziani commented on PR #43:
URL: https://github.com/apache/aries-rsa/pull/43#issuecomment-1264396030

   Hi Tim,
   
   Thanks for your quick response. I'm absolutely no expert on the matter, but from reading [this SO answer](https://stackoverflow.com/a/16180833/4937772) I learnt that the current code (using exportsMap.get(sref) in a for-loop) is asking for a ConcurrentModificationException.
   
   > In access-ordered linked hash maps, merely querying the map with get is a structural modification.
   
   Maybe other improvements are possible as well, but for us this little improvement managed to get rid of the stacktrace.


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@aries.apache.org

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


[GitHub] [aries-rsa] ponziani commented on pull request #43: fix ConcurrentModificationException in ServiceExportsRepository

Posted by "ponziani (via GitHub)" <gi...@apache.org>.
ponziani commented on PR #43:
URL: https://github.com/apache/aries-rsa/pull/43#issuecomment-1508211248

   Made a few extra improvements. All our issues are fixed now, the new code has been running for quite a while already.


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@aries.apache.org

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


Re: [PR] fix ConcurrentModificationException in ServiceExportsRepository [aries-rsa]

Posted by "amichair (via GitHub)" <gi...@apache.org>.
amichair closed pull request #43: fix ConcurrentModificationException in ServiceExportsRepository
URL: https://github.com/apache/aries-rsa/pull/43


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@aries.apache.org

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


Re: [PR] fix ConcurrentModificationException in ServiceExportsRepository [aries-rsa]

Posted by "ponziani (via GitHub)" <gi...@apache.org>.
ponziani commented on PR #43:
URL: https://github.com/apache/aries-rsa/pull/43#issuecomment-2138956025

   Thanks for the merge and the explanations!


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@aries.apache.org

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