Made the SelectorManager use the CaS state machine for both locking and controlling
the mode of handling changes.
Replaced the concurrent change queue with a pair of array lists that are switched while the lock state is held
The HttpContent class has been reworked to store HttpField instances, we may be generated on
demand or instances of PreEncodedHttpField.
The encoding of HTTP2 fields has been generalized to handle both indexed and literal fields, selected
by header enum set.
Default servlet and response classes have been cleaned up in how they set response headers.
The state machine now simply tracks if the endpoint is selecting or has been selected.
The slight complexity is that any transition between these two states goes via a locked
state, where there is exclusive access to the interested ops and selection key.
It was possible that updateKey() was seeing a SELECTING state and
therefore attempt to call setKeyInterests(), while changeInterests()
was also seeing the SELECTING state, then moving to CHANGING so that
_interestOps was accessed concurrently.
Also made the update task to call updateKey() instead of calling
directly setKeyInterests(), in order to comply with the state
machine; this required to have onSelected() handle additional states
that are created by updateKey().
Finally, in updateKey() now setKeyInterests() is called before
updating the state to isolate the call into its own state.
Fixed IllegalStateException by handling NEED_UNWRAP for the CLOSED
state in fill().
The EOFException does not seem to be an issue with the client.
Also removed an unneeded catch block and an empty if statement.
+ HttpTester, a testing class, was used by jetty-servlets,
embedded-jetty-examples, and test-integration, all from
those testing scopes. Moved the HttpTester into the
pre-existing jetty-http "tests" classified artifact.
+ Adding more varieties of server side collection vs wrapper with error
handlers
+ Adding servlet version of tests to demonstrate behavior in servlet
context, when also using the mapped error handler
WebSocket and multiplexed protocols are always read interested.
It may happen that while the application is writing, the write
blocks, resulting in a call to changeInterests().
At the same time, the selector may detect data to read and call
onSelected(), so there is a possibility that onSelected() runs
concurrently with changeInterests().
The fix adds an additional state (PROCESSING) that isolates the
changes that onSelected() makes to _interestOps, spin-waiting if
changeInterests() is running concurrently.
Likewise, changeInterests() spin-waits until onSelected() is running
concurrently.
The race was happening when updateKey() lost the race with
changeInterests() to update the interests and subsequently the key.
In that case, the selector thread that called updateKey() was returning
while changeInterests() was executing the CHANGING state.
Since updateKey() lost the race, the actual key interests was still
(typically) OP_READ so the selector thread would select() and call
onSelected() while changeInterests() was still executing, causing the
IllegalStateException.