* Remove usage of HandlerList and reduce usage of Handler.Collection
"The best part is no part" - Elon Musk!
The overwhelming usage of `HandlerList` and `Handler.Collection` was for adding the `DefaultHandler` after the main handler. This PR adds a getter/setter for a `DefaultHandler` on the server, so we no longer need to always create a `Handler.Collection` structure. This has allowed the deprecated `HandlerList` and `HandlerWrapper` classes to be removed.
In implementing this PR, several problems were found in the calculation of `InvocationType`, not least that it was assumed that an empty `Handler.Collection` was `BLOCKING`. When this issue was fixed, any dynamic addition of contexts (deployer or SPI server) failed as the `InvocationType` changed. So this PR also introduces the `isDynamic()` attribute of all `Handler.Container`s. A dynamic container will always return `BLOCKING` from `getInvocationType()`, as there is always a race with a new handler being added. A non-dynamic container will return a real `InvocationType`, calculated from its children, but it's mutator methods will ISE if contained handlers are changed.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Jan Bartel <janb@webtide.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
* Introduce GracefulShutdownHandler and test
+ started with removing `@Disabled` from `GracefulStopTest.java`
+ GracefulShutdownHandler based on Callback manipulation
* Issue #9173 - Make wrapping of ServletApiResponse easier
* Fixing checkstyle and missing licenses
* Improved HttpCookie with javadoc and attribute handling
* Wrong value of RequestDispatcher.FORWARD_CONTEXT_PATH on root context
* Fixes#9119 - uses proper context path that
satisfies the root context rules of the servlet
spec
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Add documentation in "Standard Modules" section for the jmx module
* Add documentation in "Standard Modules" section for the ee8,9,10-webapp modules
* Use shorter markup tags to transclude documentation from .mod files
* Extract EE version strings into variables
* Replace literal usages of EE version numbers with custom attribute
* Use convention 'eeN' instead of 'eex' in filenames
* Update metadata tag for deploy module documentation
* Update deploy module documentation to discuss EE platform-specific deploy modules
* Add documentation for the resources module
* Add resources module into section table of contents
* Use jetty-home instead of JETTY_HOME as documentation attribute
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
* Remove @Disabled from ConnectorTimeoutTests
* Remove @Disabled from SlowClientsTest
* Remove @Disabled from SslConnectionFactoryTest
* Remove @Disabled from DetectorConnectionTest
* Disabling quiche from checkstyle
* Removing ConnectorTimeoutTest BlockingTimeout tests
+ The concept of HttpConfiguration.blockingTimeout
has been removed, these tests are no longer relevant
* Fixes#9183 - ConnectHandler may close the connection instead of sending 200 OK.
Delaying the call to UpstreamConnection.fillInterested() until the 200 OK response has been sent.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
+ Removed the array optimized look ahead
+ version lookahead now done with getInt
+ improved test harness to check lf and crlf endings
+ added HTTP as int optimization
+ fixed bug in near miss of field cache
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Greg Wilkins <gregw@webtide.com>
* util: Add support for GraalVM Native-Image resource:-URIs and Paths
GraalVM Native-Image makes its classpath resources accessible through an
opaque resource: URL scheme.
Add support for this scheme in URIUtil and PathResource.
Automatically create the NativeImageResourceFileSystem when necessary.
Also add a workaround where converting such Native-Image Paths back to
URI would yield the wrong URI (potentially a bug in GraalVM).
https://github.com/eclipse/jetty.project/issues/9116https://github.com/oracle/graal/issues/5720
* URIUtil: Suppress CodeQL false positive error about path injection
Github CodeQL code scanning reports a high-severity error "Uncontrolled
data used in path expression", because a path depends on a user-provided
value.
This is a false positive.
Suppress the error by annotating a corresponding @SuppressWarnings tag.
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* URIUtil: Removed unused code
KNOWN_SCHEMES isn't used anywhere.
* PathResource: Selectively enable resource: for GraalVM Native Image
In regular HotSpot VMs, the resource: scheme may be registered by other
clients. However, in GraalVM Native Image, this is used for classpath
resources.
This resource scheme needs to be enabled by default for Native Image
environments so we can support code that is unaware of GraalVM
internals, such as:
URL resourceURL = MyClass.class.getResource("some/resource");
Resource resource = ResourceFactory.root().newResource(resourceURL);
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* PathResourceFactory: Ignore certain RuntimeExceptions upon init
Ignore FileSystemAlreadyExistsException, ProviderNotFoundException, etc.
that may be thrown upon calling FileSystems.newFileSystem.
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* PathResource: Work-around false positive CodeQL warning
CodeQL prevents amending the call to Paths.get.
Work-around this by using a separate constructor. The additional benefit
is that URIUtil.correctResourceURI won't need to correct the URI twice.
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* PathResource: Fix "isAlias" issue with resource: URIs
Fix two more places where Native Image resource: URIs need to be
changed.
Without this change, Resource#isAlias() would return true for such URIs,
and a warning like "BaseResource resource:/some/package/ is aliased to
resource:file:///resources!/some/package/" would be logged.
* Move GraalVM Native-Image code to NativeImagePathResource/-Factory
Keep the GraalVM Native-Image code contained in custom subclasses.
We still enable the "resource:" URL scheme by default if a GraalVM
Native-Image environment is detected via System property. This allows us
to transparently support calls like
ResourceFactory.root().newResource(MyClass.class.getResorce("webapp"))
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* Refactor Graal native-image resource: handling
Detect the resource: scheme by checking the scheme of a well-known
resource instead of looking at a system property.
Rename NativeImagePathResource* to GraalIssue5720PathResource* and make
these classes package-private.
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* Only use GraalIssue5720PathResourceFactory when truly needed
Previously, we were always enabling this resource factory for GraalVM
native-image environments.
We now check if that's actually necessary.
We fall back to MountedPathResourceFactory or PathResourceFactory,
depending on whether the URL contains "!/" or not.
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
+ `Server` now has setter/getter for a temp directory, which can be null
+ `Context` now has a getter for a temp directory, which is never null
+ Server root Context temp directory is either whatever is set, else a work directory, else java.io.tmpdir
+ WebInfConfiguration will still create a temp directory name, but defers to ContextHandler for creation/persistence of the temp directory
+ temp directory (and BASE) removed from the deployer, as it is now the server temp directory.
Previously, we were always enabling this resource factory for GraalVM
native-image environments.
We now check if that's actually necessary.
We fall back to MountedPathResourceFactory or PathResourceFactory,
depending on whether the URL contains "!/" or not.
`Retainable`s that return false from `canRetain()` now are noops if `retain()` is called, which allows for a simpler calling convention.
`AsyncContent` has also been reworked to allocate less and be clearer in its use of `canRetain()`.
* Fixes#8993 - Retainability of special Chunks
* Restored Jetty 11's AsyncContentProducer and related classes in jetty-ee9-nested module (src and test).
* Introduced Retainable.canRetain().
* Removed Chunk.isTerminal() and replaced it with alternative method calls.
* Clarified AsyncContent.write() in case of Chunk.Error.
* Removed AsyncContent.write(Chunk, Callback) because it was making the API confusing.
For example, AsyncContent.close() clashing with write(EOF, NOOP), or
AsyncContent.fail(x) clashing with write(Chunk.Error, NOOP), etc.
* Improved usage of Chunk.from(..., Retainable).
* Improved usage of Chunk.slice().
* Using from() in MultiPart, rather than duplicating code.
* Fixed MultiPart.Parser.Listener.onPartContent() javadocs.
* Renamed non-retaining Chunk.from() to Chunk.asChunk().
* Removed Chunk.slice() methods, inlining them where necessary.
* Carefully reviewed all usages of read()-like methods that return a Retainable instance to make sure it is released.
* Updated HTTP/2 and HTTP/3 usages of Stream.Data to follow the correct retain/release semantic.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>