Skip to content

Commit

Permalink
Bump version.jetty from 9.4.21.v20190926 to 9.4.22.v20191022
Browse files Browse the repository at this point in the history
Bumps `version.jetty` from 9.4.21.v20190926 to 9.4.22.v20191022.

Updates `jetty-servlets` from 9.4.21.v20190926 to 9.4.22.v20191022
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](jetty/jetty.project@jetty-9.4.21.v20190926...jetty-9.4.22.v20191022)

Updates `jetty-server` from 9.4.21.v20190926 to 9.4.22.v20191022
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](jetty/jetty.project@jetty-9.4.21.v20190926...jetty-9.4.22.v20191022)

Updates `websocket-api` from 9.4.21.v20190926 to 9.4.22.v20191022

Updates `websocket-common` from 9.4.21.v20190926 to 9.4.22.v20191022

Updates `websocket-client` from 9.4.21.v20190926 to 9.4.22.v20191022

Updates `websocket-server` from 9.4.21.v20190926 to 9.4.22.v20191022

Updates `websocket-servlet` from 9.4.21.v20190926 to 9.4.22.v20191022

Update JettyWebTestContainerFactory to work around jetty breaking
change: eclipse-ee4j/jersey#4302

Signed-off-by: dependabot-preview[bot] <[email protected]>
  • Loading branch information
dependabot-preview[bot] authored and josephlbarnett committed Oct 24, 2019
1 parent bb6333c commit 2584b7f
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 28 deletions.
41 changes: 19 additions & 22 deletions parent-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<version.jaxrs>2.1.6</version.jaxrs>
<version.jersey>2.29.1</version.jersey>
<version.jetbrains.annotations>13.0</version.jetbrains.annotations>
<version.jetty>9.4.21.v20190926</version.jetty>
<version.jetty>9.4.22.v20191022</version.jetty>
<version.jooq>3.11.12</version.jooq>
<version.jsr305>3.0.2</version.jsr305>
<version.kotlin>1.3.50</version.kotlin>
Expand Down Expand Up @@ -444,6 +444,10 @@
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>aopalliance-repackaged</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>jakarta.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -503,6 +507,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>${version.jersey}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>jakarta.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-servlet</artifactId>
Expand Down Expand Up @@ -589,8 +604,10 @@
<!-- jetty -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<artifactId>jetty-bom</artifactId>
<version>${version.jetty}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand All @@ -603,26 +620,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-api</artifactId>
<version>${version.jetty}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-common</artifactId>
<version>${version.jetty}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>${version.jetty}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${version.jetty}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-servlet</artifactId>
Expand Down
18 changes: 17 additions & 1 deletion testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-servlet</artifactId>
<artifactId>jersey-container-jetty-http</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
Expand All @@ -69,6 +73,18 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
package com.trib3.testing.server

import org.eclipse.jetty.server.Connector
import org.eclipse.jetty.server.HttpConfiguration
import org.eclipse.jetty.server.HttpConnectionFactory
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.server.ServerConnector
import org.eclipse.jetty.servlet.ServletHolder
import org.eclipse.jetty.util.thread.QueuedThreadPool
import org.eclipse.jetty.webapp.Configuration
import org.eclipse.jetty.webapp.WebAppContext
import org.eclipse.jetty.webapp.WebXmlConfiguration
import org.glassfish.jersey.client.ClientConfig
import org.glassfish.jersey.jetty.servlet.JettyWebContainerFactory
import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder
import org.glassfish.jersey.jetty.internal.LocalizationMessages
import org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler
import org.glassfish.jersey.server.spi.Container
import org.glassfish.jersey.servlet.ServletContainer
import org.glassfish.jersey.test.DeploymentContext
import org.glassfish.jersey.test.spi.TestContainer
import org.glassfish.jersey.test.spi.TestContainerFactory
import org.glassfish.jersey.uri.UriComponent
import java.net.URI
import javax.servlet.Servlet
import javax.ws.rs.core.UriBuilder

/**
Expand All @@ -16,12 +30,23 @@ import javax.ws.rs.core.UriBuilder
* Equivalent of GrizzlyWebTestContainerFactory, but using jetty instead of grizzly.
*/
class JettyWebTestContainerFactory : TestContainerFactory {

// Same as JettyHttpContainerFactory#JettyConnectorThreadPool, but with newThread as public
private class JettyConnectorThreadPool : QueuedThreadPool() {
private val threadFactory = ThreadFactoryBuilder()
.setNameFormat("jetty-http-server-%d")
.setUncaughtExceptionHandler(JerseyProcessingUncaughtExceptionHandler())
.build()

override fun newThread(runnable: Runnable): Thread {
return threadFactory.newThread(runnable)
}
}

private class JettyWebTestContainer(private var uri: URI, context: DeploymentContext) : TestContainer {
val server = JettyWebContainerFactory.create(
val server = create(
UriBuilder.fromUri(uri).path(context.contextPath).build(),
ServletContainer(context.resourceConfig),
null,
null
ServletContainer(context.resourceConfig)
)

override fun getClientConfig(): ClientConfig? {
Expand All @@ -40,6 +65,45 @@ class JettyWebTestContainerFactory : TestContainerFactory {
override fun getBaseUri(): URI {
return uri
}

// simplified version of JettyWebContainerFactory#create
private fun create(
uri: URI,
servlet: Servlet
): Server {
requireNotNull(uri.path) { "The URI path, of the URI $uri, must be non-null" }
require(uri.path.isNotEmpty()) { "The URI path, of the URI $uri, must be present" }
require(uri.path[0] == '/') { "The URI path, of the URI $uri. must start with a '/'" }

val path = String.format("/%s", UriComponent.decodePath(uri.path, true)[1].toString())
val context = WebAppContext()
context.displayName = "JettyContext"
context.contextPath = path
context.configurations = arrayOf<Configuration>(WebXmlConfiguration())
val holder = ServletHolder(servlet)
context.addServlet(holder, "/*")

val server = createServer(uri)
server.handler = context
server.start()
return server
}

// simplified version of JettyHttpContainerFactory#createServer
private fun createServer(
uri: URI
): Server {
require("http".equals(uri.scheme)) { LocalizationMessages.WRONG_SCHEME_WHEN_USING_HTTP() }
val defaultPort = Container.DEFAULT_HTTP_PORT
val port = if (uri.port == -1) defaultPort else uri.port

val server = Server(JettyConnectorThreadPool())
val config = HttpConfiguration()
val http = ServerConnector(server, HttpConnectionFactory(config))
http.port = port
server.connectors = arrayOf<Connector>(http)
return server
}
}

override fun create(baseUri: URI, deploymentContext: DeploymentContext): TestContainer {
Expand Down

0 comments on commit 2584b7f

Please sign in to comment.