This repository has been archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 779
Scheduler: fix ConcurrentModificationException #3511
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fixes eclipse-archived#3504 Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
amitjoy
reviewed
May 24, 2017
futures.get(aRunnable).remove(toDelete); | ||
} | ||
synchronized (futures) { | ||
for (Runnable aRunnable : futures.keySet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entrySet()
in map is faster than keySet()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True for HashMap. However,
for (Entry<Runnable, ArrayList<Future<?>>> entry : futures.entrySet()) {
futures.get(entry.getKey()).removeIf(future -> future == runnable);
}
is also less readable. Therefore I thought I leave it as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - readability is as important as efficiency. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...at least for small collections like this 😄
maggu2810
approved these changes
May 26, 2017
cdjackson
added a commit
to cdjackson/smarthome
that referenced
this pull request
Jun 3, 2017
* master: (335 commits) Voice: send feedback to an item when listening for a command (eclipse-archived#3451) Scheduler: fix ConcurrentModificationException (eclipse-archived#3511) [Scheduler] Dropped usage of SimpleDateFormat for trace logging (eclipse-archived#3508) Use % sign as default for dimmer items (eclipse-archived#3525) updated ThingHandler javadoc added regression tests ensure thingUdpated cannot be called in parallel with initialize moving handler intiialization back to the caller thread use decicated locks instead of syncrhonization by object add PaperUI setup to IDE setup tasks, adopt documentation (eclipse-archived#3515) Bug fix: things not showing on control page (eclipse-archived#3517) remove "Type" postfix in item events, fixes 3282. (eclipse-archived#3494) use toFullString when creating GroupItemStateChangeEvent (eclipse-archived#3409) Made item’s state text consistent + refactored code (eclipse-archived#3466) Refactored CoreItemFactory: (eclipse-archived#3507) Add CoreItemFactoryTest, in addition to eclipse-archived#3507 (eclipse-archived#3509) fix ConcurrentModificationException in AbstractWatchServiceTest (eclipse-archived#3499) BasicUI: Treat Switch on NumberItem not as ON/OFF Switch (eclipse-archived#3493) An Interface method should not allow for throwing a generic Exception (eclipse-archived#3467) Fix eclipse-archived#2902 for Basic UI (eclipse-archived#3496) ... # Conflicts: # bundles/io/org.eclipse.smarthome.io.transport.dbus/.classpath # bundles/io/org.eclipse.smarthome.io.transport.dbus/META-INF/MANIFEST.MF # extensions/binding/pom.xml
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
... by expanding the synchronized block to include the outer loop.
And while being at it anyway I also vaporized the removal logic to a single line.
fixes #3504
Signed-off-by: Simon Kaufmann simon.kfm@googlemail.com