With issue #9166, ByteBufferPool was removed and replaced by
RetainableByteBufferPool. Since ByteBufferPool was used by
AbstractConnector, this change broke backwards compatibility with
third-party connectors such as junixsocket-jetty.
Since there's no longer any other ByteBufferPool, rename the
RetainableByteBufferPool interface, and thereby not only reinstate
compatibility with existing third-party libraries but also save a few
keystrokes.
https://github.com/eclipse/jetty.project/issues/9284
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* Added a core Session abstraction
Sessions were already a core mechanism, but there was no API for them.
There is now a new Session interface that is available via the Request API. It is intended only for users of sessions.
The previous concrete class Session has been renamed to ManagedSession and it is used by classes that extend AbstractSessionManager.
* Fixed tests
* Use static method
* Updates from review
* Updates from review
Improved javadoc
used util Attributes interface.
* 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>
+ `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.
* 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>
Alternative Handler architecture.
All Handlers are Processors, which now return a boolean to indicate the request has been accepted.
The request/response/callback are no longer modal, so there is no race with the boolean return.
Optimized PathMappings.
Avoid iterations if only ServletPathSpec instances
Avoid tests for empty mappings.
Better reset implementation
Improve suffix matching
Improve exact matching
Renamed HttpStream.getNanoTimeStamp() to getNanoTime().
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
* Extracted some non controversial cleanups from another mega PR:
+ TypeUtil class shortname used more often and includes trailing digits
+ Fixed direct stopping/starting of a nested ContextHandler
+ Fixed null path handling in nested context
+ more tests for all of the above
* Extracted some non controversial cleanups from another mega PR:
Fixed nested doStart and doStop
* Extracted some non controversial cleanups from another mega PR:
Fixed DistributionTests
* Cleanup ContextHandler
Extracted some of the goodness from #8793:
+ Clear enter/exit scope methods rather than opaque suppliers and Runnables
+ Removed overloading of "Context" class name to avoid accidental usage of wrong type.
+ Less holding onto request/response as fields
* Cleanup ContextHandler
fixed test with no server
* Updates from review.
Recycle ServletChannel
Cleanup caching comments and impl
Don't recycle after completion notification
Delay setting callback until ServletHandler.handle called
Check that the retrieved ServletChannel is for the same context.
Some classes had the second S capitalized, some did not, so now stylesheel -> styleSheet.
CSS has 2 "S" for "S"tyle"S"heet.
Also, the DOM API and the Swing API have "StyleSheet".
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
revert to using computeIfAbsent on CachingHttpContentFactory
make direct buffers configurable on CachingHttpContentFactory
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
+ Removal of __CHARSET
+ Removal of unused methods
+ Using new switch/case concepts
+ cleanup of URIUtil constants
+ cleanup of URIUtil methods
+ collapse separate methods
+ simplify encodePath()
* Javadoc updates
* equalsIgnoreEncoding cleanup (no longer used by Resource layer)
* Resource `resolve()` and `newResource()` return null on resources that do not exist
* Introduce `Resources` utility methods and use them
* Updating javadoc
* simplify the PathResource.resolveTargetPath code
* changes to how PathResource handles aliases
* fix usages of Resource.getTargetUri()
* fixes for FileSystemResourceTest
* update javadoc for Resource.getTargetURI()
* rename getTargetURI to getCanonicalURI
* let resolveCanonicalPath return null if resource does not exist
* add test in PathResourceTest for broken symlinks
* some changes from review + optimization for exists()
* restore name to getTargetUri in Resource
* fix some tests related to PathResource changes
* revert changes to PathResource equals and hashcode
* also compare URI in PathResource
* checkAlias to resolveAlias
* PathResource cleanup
+ Adding comments about class fields.
+ Removing normalization from
input/output/comparison flows.
+ Collapsing `resolveTargetPath`
into `resolveAlias` to react
accordingly to the exceptions
that can flow out of Path.toRealPath().
+ Failure on Path.toRealPath() is never
an alias, as the resource cannot ever
be served anyway.
+ More comments in `resolveAlias()`
+ Failed / Bad / Nonexistent / Inaccessible
resources are not aliases to anything.
* Renames of targetPath/targetUri
`targetPath` to `realPath`
`targetURI` to `realURI`
* Cleanup alias/aliasResolved booleans
* More testcase cleanup around not-exist
* Don't resolve alias on Error during toRealPath
* Add test to check how Alias check behaves if non-existent resource exists later
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
* Made WebSocket over HTTP/2 work.
Re-enabled tests, and restored HTTP2StreamEndPoint,
as well as implemented getTunnelSupport() for HTTP/2.
Removed from HttpStream methods for upgrade that are
not necessary anymore.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Cherry-pick of Improvements to PathSpec.
* From commit: 5b4d1dd1c6
* Fixing ConstraintSecurityHandler usage of PathMappings
* Fixing bad INCLUDE logic from cherry-pick in ServletHandler.doScope()
* Cleanup of non ServletPathSpec behaviors in ServletPathMapping class
* Skip optional group name/info lookup if regex fails.
* Prevent NPE on static servletPathMappings
* Update WebSocketMappings to use new PathMappings.getMatched(String)
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Delay Resource alias calculation until it's requested.
* Rename .getAlias() to .getTargetURI()
* PathResource resolveTargetAliasPath to resolveTargetPath
* Produce XHTML output with tests that validate the XHTML.
* Adding ResourceListingTest and ensuring ResourceListing output is well formed.
* Introduce non-directory entry in ResourceListing test for ResourceCollection
* Restored interim responses functionality (100 Continue, 102 Processing, 103 Early Hints) for core, ee9 and ee10.
Added ProcessingProtocolHandler and EarlyHintsProtocolHandler for the client.
Re-enabled all tests for interim responses for all protocols.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Properly implemented request and response trailers for all the transports, both client and server.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Remove Resource.getWeakETag in favor of new EtagUtils
* Protect bad usages of CachingContentFactory
* Working precompressed content for ResourceService
* Fixing DefaultServlet handling of ResourceService.writeHttpError() overrides
* Protect NPE in CachingContentFactory.isValid()
* Complete callback in DefaultServlet.writeHttpError
* Addressing review comments
* Testing for whole content
* Improve MemoryResource handling of name/filename
* EtagUtils handling of Resource
* Better protection of bad Resource impls in EtagUtils
* Update CachingContentFactory
+ Using Resource.lastModified were possible
+ CachingHttpContent has better Resource
protection, and uses Etag from delegate
+ CachingHttpContent uses delegate where
possible.
+ Store Etag HttpField in CachingHttpContent
and allow override in constructor
* Simpler CachingHttpContent.isValid()
* Better handling of PrecompressedHttpContent
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #8474 - Resource.list and Resource.getFileName work
* Correcting signature of Resource.list and use it
* Introduce Resource.getFileName and use it
* Adding URIUtil.addPath() test to show file+str behavior
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* ee8 demos to use ee9 demos resources
* add jetty-ee8-demo-jaas-webapp
* add jetty-ee8-demo-jndi-webapp jetty-ee8-demo-mock-resources
* uhm jetty-ee8-demo-jetty-webapp have some issues
* fix jetty-ee8-demo-jetty-webapp
* fix some jetty-ee9-demo-embedded and add back jetty-ee8-demo-proxy-webapp
* demo-embedded need to have jetty-ee9-demo-jsp-webapp built first
* fixing more demos modules. Activate dist test for demo modules and all env
Signed-off-by: Olivier Lamy <oliver.lamy@gmail.com>
* Immutable ResourceCollection with mount management.
* Internal List<Resource> is now immutable so that .getResources() cannot be modified.
* Improved Resource.toJarFileUri implementation that keeps the deep archive references
* Introducing Resource.mountCollection() methods
+ ResourceCollection is now a private class
+ Resource.mountCollection() returns a Mount
+ Places that use this technique are now putting the Mount in the context's beans for the context to close those mounts.
* Cleanup names/comments in FileSystemResourceTest
* Adding missing test of attempting to create a Resource from a URI `jar:file:foo.jar!/` while not mounted.
* Reworked ResourceCollection behaviors based on feedback.
+ Eliminated all Resource.mountCollection() methods except the Collection<URI> one.
* Eliminated Resource.mountIfNeeded(Resource)
* Eliminated Resource.fromList implementations
* Introduced @gregw Resource.of() implementations
* Introduced Resource.split() to honor old split logic from Jetty 9/10/11, with glob support, but now it only converts to List<URI>
* Remove IOException from Mount.root() method
* ResourceCollection now flattens and uniques any nested ResourceCollection entries it encounters
* Expanded ResourceCollectionTest to cover more code paths
* Add ResourceTest for new split() method
* Fixing testcase to use a directory that exists on setExtraClasspath
* Increase reliability of WebAppContextTests
* Updates for working with webapp.extraClasspath
* Introduced Resource.unwrapContainer to help in servlet cases where the raw JAR path should be represented in a ServletContext attribute.
* Made FileSystemPool.containerUri just use new Resource.unwrapContainer
* webapp MetaData updated to use URIs references to Libs (not File objects)
* jetty-ee#-maven-plugin use URIs for its classpath tracking to aid in mounting issues later
* webapp extraClasspath supports raw JAR references as well as glob now, supported by Resource.split(String)
Somehow the URIUtil class had switched over the meaning of normal and canonical. This PR renames them to correct this:
* canonical paths are always normal
* Always canonicalize paths passed from the application
* Switch the URIUtil names for canonical and normal
Made Chunk implement Retainable, and protocol implementations
to link the RetainableByteBuffer all the way to the Chunk.
Extended Retainable to have both a retain() and a release() methods.
Removed HTTP/2's ISession and IStream, now just using HTTP2Session and HTTP2Stream.
Removed *.Adapter classes in favor of interfaces with default methods.
Javadoc additions and clarifications.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Re-enabled jetty-ee9-proxy and jetty-ee10-proxy modules.
Introduced TunnelSupport to abstract out the tunnelling capabilities.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Made ResourceService use a generic request so it can be used as handler or from servlets. This is only a temporary solution.
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Co-authored-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
+ fixed ee9-demo-async-rest
+ CachedContentFactory now needs to ignore `UnsupportedOperationException`
I don't think this is a great fix, as throwing an exception in a normal path is not optimal.
* remove Resource.getFile() and replace its usages with Resource.getPath()
* remove all public PathResource ctors + add non-leaky FS mounting mechanism + interpret string as Path when not a schemed URI
* rename Resource.getResource to Resource.resolve, specifying that the subpath is URI-path-interpreted
* remove useless API methods + deprecate all path-related API
* make subpaths beginning with / resolved as relative to the given uri
* introduce filesystem pooling and generalize resource resolving code
* remove URLResource
* remove unneeded factory method
* both file: and jrt: should not be pooled
* move deprecated impls from PathResource down to Resource + fix some tests
* handle Resource's pointing to non-existent jar files
* Force Resource URIs to end with "/" when the resource is a directory
* Produce warning if attempting to release a mounted filesystem uri that doesn't exist in the pool.
Co-authored-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>
Deploy webapps for different environments from the same webapps directory.
The maximal environment known to the AppProviders is used as the default environment.
An explicit environment can be set in a properties file for an application, which is also used for property substitution in any context xml file.
Introduced a new io.Content class, with Content.Source, Content.Sink and Content.Chunk.
Updated the server-side to use io.Content instead of the previous server-side Content class.
Updated the client-side to use io.Content with a little specialization necessary for clients only.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>