[
https://issues.apache.org/jira/browse/GEODE-8195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17145806#comment-17145806
]
ASF GitHub Bot commented on GEODE-8195:
---------------------------------------
bschuchardt opened a new pull request #5306:
URL: https://github.com/apache/geode/pull/5306
…tenerImpl
I've replaced the "for" loop using an implicit Iterator with one using an
explicit Iterator so that its safe "remove()" method can be used. The
Iterator method is stated as being the only safe way to modify the
collection while iterating over its contents.
I've also modified a test to validate the fix. The test forces a
failure to send two messages to an address. The failures are then
handled in the code that was throwing the
ConcurrentModificationException and, since there are two failures,
it causes two removals to be performedon the failedMessages collection.
Thank you for submitting a contribution to Apache Geode.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced in
the commit message?
- [ ] Has your PR been rebased against the latest commit within the target
branch (typically `develop`)?
- [ ] Is your initial contribution a single, squashed commit?
- [ ] Does `gradlew build` run cleanly?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
### Note:
Please ensure that once the PR is submitted, check Concourse for build
issues and
submit an update to your PR as soon as possible. If you need help, please
send an
email to [email protected].
----------------------------------------------------------------
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:
[email protected]
> ConcurrentModificationException from
> LocatorMembershipListenerImpl$DistributeLocatorsRunnable.run
> -------------------------------------------------------------------------------------------------
>
> Key: GEODE-8195
> URL: https://issues.apache.org/jira/browse/GEODE-8195
> Project: Geode
> Issue Type: Bug
> Components: membership
> Reporter: Bill Burcham
> Assignee: Bruce J Schuchardt
> Priority: Major
>
> this WAN code in
> {{LocatorMembershipListenerImpl$DistributeLocatorsRunnable.run}}:
> {code}
> Set<LocatorJoinMessage> joinMessages = entry.getValue();
> for (LocatorJoinMessage locatorJoinMessage : joinMessages) {
> if (retryMessage(targetLocator, locatorJoinMessage, attempt)) {
> joinMessages.remove(locatorJoinMessage);
> } else {
> {code}
> modifies the {{joinMessages}} set as it is iterating over the set, resulting
> in a {{ConcurrentModificationException}}.
> This bug will cause (inter-site) notification of locators (of the presence of
> a new locator) to fail early if retry is necessary. If we have to retry
> notifying any locator, and we succeed, we’ll throw the
> {{ConcurrentModificationException}} and stop trying to notify any of the
> other locators. See the _Discovery For Multi-Site Systems_ section of the
> [Overview of Multi-Site
> Caching|https://geode.apache.org/docs/guide/14/topologies_and_comm/topology_concepts/multisite_overview.html]
> documentation for an overview of the locator's role in WAN.
> Here is a scratch file that illustrates the issue, throwing
> {{ConcurrentModificationException}}:
> {code}
> import java.util.HashSet;
> import java.util.Set;
> class Scratch {
> public static void main(String[] args) {
> final Set<String> joinMessages = new HashSet<>();
> joinMessages.add("one");
> joinMessages.add("two");
> for( final String entry:joinMessages ) {
> if (entry.equals("one"))
> joinMessages.remove(entry);
> }
> }
> }
> {code}
> From looking at the Geode code, {{joinMessages}} is not used outside the loop
> so there is no need to modify it at all—I think we can simply remove this
> line:
> {code}
> joinMessages.remove(locatorJoinMessage);
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)