* Fixed `ProxyWriter.chunks` locking.
* Made `writeProxyResponseContent()` protected so it can be overridden to flush the response content.
* Added test case.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Fixed the case where a GOAWAY followed by a TCP FIN was causing a race between closing the `EndPoint` and running the failure `Runnable` task.
The TCP FIN after the GOAWAY causes the streams to be failed on the server;
in turn, failing the streams generates failure `Runnable` tasks that are submitted to the HTTP/2 execution strategy;
however, the streams were destroyed before the failure `Runnable` tasks actually ran, so the `EndPoint` was closed;
closing the `EndPoint` would close the `HTTP2Connection`, which in turn would stop the execution strategy;
this lead to the fact that the failure `Runnable` tasks were never run.
Now, the failure `Runnable` tasks are invoked via `ThreadPool.executeImmediately()` rather than being submitted to the execution strategy.
This ensures that they would be run and not queued, even in case of lack of threads, so that they could unblock blocked reads or writes, freeing up blocked threads.
Additionally, improved `HTTP2Stream.onFailure()` to destroy the stream only after the failure tasks have completed.
Smaller other fixes to improve the code.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Deprecated MultiPartFormData.Parser.parse() with 2 Promises, a leftover from previous experiments.
* Added @deprecated javadoc tag to deprecated methods, indicating what to use instead.
* Updated documentation to use non-deprecated APIs.
* Updated source code to use non-deprecated APIs.
* Updated class javadocs with usage examples that were outdated.
* Made Blocker.Promise extends Promise.Invocable, so it can be use to block while using asynchronous APIs.
* Added missing methods that perform asynchronous operation using a Promise rather than CompletableFuture.
* Added servlet-to-handler examples for form fields and multipart.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
For #12214 restore ee9 and ee10 thread starvation tests
* Deprecated ContentSourceCompletableFuture and added protection to method to match invocation type
* more demand invocables with invocation type
* Deprecated the CF APIs and replaced with explicit getXxx onXxx methods
* replace FutureCallback and FuturePromise usages with Blocker.* instead
* Converted new API on FormFields to use Promise
* Modified SerializedInvoker to take into account the task InvocationType.
* Added ThreadStarvationTest for all transports, to check that also HTTP/2 and HTTP/3 do not starve in case of non-blocking reads.
* Improved Core ThreadStarvationTest
* Fixed AsyncServletLongPollTest in ee9 and ee10 to match the current behavior in case of close.
* Removed Invocable.InvocableCompletableFuture
* Fixed SerializedInvoker.
* Improved ThreadStarvationTest.
* refined more DemandTask implementations
* Added InvocableType.runWithoutBlocking (name is WIP)
* replace Thread.sleep() with awaitility
---------
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: gregw <gregw@webtide.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
* Introduced "maxResponseHeadersSize" parameter to AbstractProxyServlet.
* Introduced HttpGenerator.maxResponseHeadersSize and added checks to not exceed it.
* Fixed HttpParser to generate a 400 in case HttpParser.maxHeaderBytes are exceeded for a response.
* HTTP2Flusher now resets streams in case of failures.
* Removed cases in HTTP2Session where a GOAWAY frame was generated with lastStreamId=0.
GOAWAY.lastStreamId=0 means that not a single request was processed by the server, which was obviously incorrect.
* Written tests for both ProxyHandler and ProxyServlet about max response headers size exceeded.
* Simplified server-side response header allocation for HTTP/1.1.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Fixed invocation of AsyncListener.onError(), now called even if the response is already committed, in both EE9 and EE10.
* Reworked EE9 HttpChannel state machine in case of failures to be like EE10's.
In particular, calling abort now is a state change, rather than a failure of the Handler callback.
In this way, the handle() loop continues, enters case TERMINATED, and the callback is completed in onCompleted().
* Fixed EE9 handling of idle timeout in HttpChannel.onRequest(), that was missing.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Fix#12356 Do not send keep-alive when not persistent
---------
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
* Issue #11092 - Allow MetaInfConfiguration parsing of java.class.path to support globs
* Work with unwrapped URIs for uriPredicate (and test assertion)
This reverts/modified parts of commit 115ee1cf39.
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
---------
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
A call to `sweep()`, although protected by the lock for concurrent calls to `reserve()`, may be concurrent with `remove(Entry)`.
`remove(Entry)` in turn calls `entries.remove(Object)`, so that the concurrent iteration in `sweep()` over `entries` fails with an `ArrayIndexOutOfBoundsException`.
Now using the bulk `entries.removeIf(Predicate)` method in `sweep()`, so that sweeping is atomic with respect to `entries.remove(Object)`.
Fixed other occurrences of manual iteration over CopyOnWriteArrayList that may be concurrent with removals.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Fixed HttpReceiverOverHTTP2.read() to return a failed chunk if the stream has been reset.
This closes the window where a RST_STREAM frame may be received, drain the DATA frames in HTTP2Stream, and the application reading exactly at that point.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>