RFR [13] 8217976: test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java fails intermittently
Daniel Fuchs
daniel.fuchs at oracle.com
Tue Jan 29 12:31:07 UTC 2019
Hi Chris,
116 List<Connection> localList = List.copyOf(connections);
I think it is still possible for CME to happen during the copyOf
operation, even though it can reduce the window in which that might
happen.
The best would be to use CopyOnWriteArrayList instead
of synchronizedList(). Otherwise you'd still need to copy the list
within a synchronize(connections) { } block to prevent CME.
best regards,
-- daniel
On 29/01/2019 12:15, Chris Hegarty wrote:
> WebSocketProxyTest is a new test that was added recently. It fails once
> in every few hundred runs. The test uses a preexisting test-only proxy
> server. There is a race when closing the server; the close method
> iterates over all connections while another thread may be adding a new
> connection. The solution proposed here is to take a copy of the
> connection list and iterate over it, rather than the connection list
> itself. ( I also did a little clean up and added some consistency to
> proxy debug messages, since it was more difficult to reason about the
> test's behavior from its log than it should have been )
>
> http://cr.openjdk.java.net/~chegar/8217976/webrev.00/
>
> -Chris.
>
More information about the net-dev
mailing list