RFR: 8287318: ConcurrentModificationException in sun.net.httpserver.ServerImpl$Dispatcher [v2]
Jaikiran Pai
jpai at openjdk.java.net
Tue May 31 15:14:22 UTC 2022
> Can I please get a review of this change which addresses the issue noted in https://bugs.openjdk.java.net/browse/JDK-8287318?
>
> The `ServerImpl` has a `Dispatcher` thread which uses a `Selector` to select keys of interested. The selected keys is then iterated over and each key is removed through the iterator. This is fine as long as the selector isn't then used to invoke select operation(s) while the iterator is still in use. Doing so leads to the underlying Set being potentially modified with updates to the selected keys. As a result any subsequent use of the iterator will lead to `ConcurrentModificationException` as seen in the linked issue.
>
> The commit here fixes that by creating a copy of the selected keys and iterating over it so that any subsequent select operation on the selector won't have impact on the Set that is being iterated upon.
>
> No new tests have been added given the intermittent nature of this issue. Existing tier1, tier2 and tier3 tests passed without any related failures, after this change.
Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
Use Collection.toArray(...) instead of creating a copy of the collection
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/8898/files
- new: https://git.openjdk.java.net/jdk/pull/8898/files/ee963c3a..2287844e
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=8898&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=8898&range=00-01
Stats: 3 lines in 1 file changed: 0 ins; 2 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/8898.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/8898/head:pull/8898
PR: https://git.openjdk.java.net/jdk/pull/8898
More information about the net-dev
mailing list