Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-4225-jpms_transitivity

This commit is contained in:
Lachlan Roberts 2019-12-27 19:27:59 +11:00
commit c98897315c
705 changed files with 694 additions and 222 deletions

View File

@ -183,12 +183,12 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-client</artifactId>
<artifactId>websocket-jetty-client</artifactId>
<version>${project.version}</version>
</dependency>
<!-- http/2 support -->

View File

@ -113,7 +113,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

View File

@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@ -62,7 +62,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@ -136,7 +136,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-client</artifactId>
<artifactId>websocket-jetty-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

View File

@ -341,37 +341,37 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-client</artifactId>
<artifactId>websocket-javax-client</artifactId>
<version>10.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<artifactId>websocket-javax-server</artifactId>
<version>10.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-common</artifactId>
<artifactId>websocket-javax-common</artifactId>
<version>10.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-api</artifactId>
<artifactId>websocket-jetty-api</artifactId>
<version>10.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-client</artifactId>
<artifactId>websocket-jetty-client</artifactId>
<version>10.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-common</artifactId>
<artifactId>websocket-jetty-common</artifactId>
<version>10.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>10.0.0-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -123,10 +123,16 @@ public abstract class HttpConnection implements IConnection
protected void normalizeRequest(Request request)
{
final HttpVersion version = request.getVersion();
final HttpFields headers = request.getHeaders();
final ContentProvider content = request.getContent();
final ProxyConfiguration.Proxy proxy = destination.getProxy();
boolean normalized = ((HttpRequest)request).normalized();
if (LOG.isDebugEnabled())
LOG.debug("Normalizing {} {}", !normalized, request);
if (normalized)
return;
HttpVersion version = request.getVersion();
HttpFields headers = request.getHeaders();
ContentProvider content = request.getContent();
ProxyConfiguration.Proxy proxy = destination.getProxy();
// Make sure the path is there
String path = request.getPath();

View File

@ -311,10 +311,10 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
}
}
public boolean process(final Connection connection)
public boolean process(Connection connection)
{
HttpClient client = getHttpClient();
final HttpExchange exchange = getHttpExchanges().poll();
HttpExchange exchange = getHttpExchanges().poll();
if (LOG.isDebugEnabled())
LOG.debug("Processing exchange {} on {} of {}", exchange, connection, this);
if (exchange == null)
@ -331,7 +331,7 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
}
else
{
final Request request = exchange.getRequest();
Request request = exchange.getRequest();
Throwable cause = request.getAbortCause();
if (cause != null)
{
@ -347,21 +347,30 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
}
else
{
SendFailure result = ((IConnection)connection).send(exchange);
SendFailure result = send((IConnection)connection, exchange);
if (result != null)
{
if (LOG.isDebugEnabled())
LOG.debug("Send failed {} for {}", result, exchange);
if (result.retry)
{
// Resend this exchange, likely on another connection,
// and return false to avoid to re-enter this method.
send(exchange);
else
request.abort(result.failure);
return false;
}
request.abort(result.failure);
}
}
return getHttpExchanges().peek() != null;
}
}
protected SendFailure send(IConnection connection, HttpExchange exchange)
{
return connection.send(exchange);
}
@Override
public void newConnection(Promise<Connection> promise)
{

View File

@ -90,6 +90,7 @@ public class HttpRequest implements Request
private Supplier<HttpFields> trailers;
private String upgradeProtocol;
private Object tag;
private boolean normalized;
protected HttpRequest(HttpClient client, HttpConversation conversation, URI uri)
{
@ -822,6 +823,23 @@ public class HttpRequest implements Request
return aborted.get();
}
/**
* <p>Marks this request as <em>normalized</em>.</p>
* <p>A request is normalized by setting things that applications give
* for granted such as defaulting the method to {@code GET}, adding the
* {@code Host} header, adding the cookies, adding {@code Authorization}
* headers, etc.</p>
*
* @return whether this request was already normalized
* @see HttpConnection#normalizeRequest(Request)
*/
boolean normalized()
{
boolean result = normalized;
normalized = true;
return result;
}
private String buildQuery()
{
StringBuilder result = new StringBuilder();

View File

@ -32,6 +32,10 @@ public class SendFailure
@Override
public String toString()
{
return String.format("%s[failure=%s,retry=%b]", super.toString(), failure, retry);
return String.format("%s@%x[failure=%s,retry=%b]",
getClass().getSimpleName(),
hashCode(),
failure,
retry);
}
}

View File

@ -146,12 +146,17 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements IConne
public boolean onIdleExpired()
{
long idleTimeout = getEndPoint().getIdleTimeout();
boolean close = delegate.onIdleTimeout(idleTimeout);
boolean close = onIdleTimeout(idleTimeout);
if (close)
close(new TimeoutException("Idle timeout " + idleTimeout + " ms"));
return false;
}
protected boolean onIdleTimeout(long idleTimeout)
{
return delegate.onIdleTimeout(idleTimeout);
}
@Override
public void onFillable()
{

View File

@ -0,0 +1,171 @@
//
// ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.client;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.client.http.HttpConnectionOverHTTP;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpClientIdleTimeoutTest
{
private Server server;
private ServerConnector connector;
private HttpClient client;
private void start(Handler handler) throws Exception
{
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server");
server = new Server(serverThreads);
connector = new ServerConnector(server, 1, 1);
server.addConnector(connector);
server.setHandler(handler);
server.start();
}
@AfterEach
public void dispose() throws Exception
{
if (server != null)
server.stop();
if (client != null)
client.stop();
}
@Test
public void testRequestIsRetriedWhenSentDuringIdleTimeout() throws Exception
{
start(new EmptyServerHandler()
{
@Override
protected void service(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
{
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
{
// Send a cookie in the first response.
response.addCookie(new Cookie("name", "value"));
}
else
{
// Verify that there is only one cookie, i.e.
// that the request has not been normalized twice.
assertEquals(1, cookies.length);
}
}
});
CountDownLatch idleTimeoutLatch = new CountDownLatch(1);
CountDownLatch requestLatch = new CountDownLatch(1);
CountDownLatch retryLatch = new CountDownLatch(1);
QueuedThreadPool clientThreads = new QueuedThreadPool();
clientThreads.setName("client");
client = new HttpClient(new HttpClientTransportOverHTTP(1)
{
@Override
public HttpDestination newHttpDestination(Origin origin)
{
return new DuplexHttpDestination(getHttpClient(), origin)
{
@Override
protected SendFailure send(IConnection connection, HttpExchange exchange)
{
SendFailure result = super.send(connection, exchange);
if (result != null && result.retry)
retryLatch.countDown();
return result;
}
};
}
@Override
protected HttpConnectionOverHTTP newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise)
{
return new HttpConnectionOverHTTP(endPoint, destination, promise)
{
@Override
protected boolean onIdleTimeout(long idleTimeout)
{
boolean result = super.onIdleTimeout(idleTimeout);
if (result)
idleTimeoutLatch.countDown();
assertTrue(await(requestLatch));
return result;
}
};
}
});
client.setExecutor(clientThreads);
client.start();
long idleTimeout = 1000;
client.setIdleTimeout(idleTimeout);
// Create one connection.
ContentResponse response = client.newRequest("localhost", connector.getLocalPort()).send();
assertEquals(response.getStatus(), HttpStatus.OK_200);
assertTrue(idleTimeoutLatch.await(2 * idleTimeout, TimeUnit.MILLISECONDS));
// Send a request exactly while the connection is idle timing out.
CountDownLatch responseLatch = new CountDownLatch(1);
client.newRequest("localhost", connector.getLocalPort()).send(result ->
{
assertTrue(result.isSucceeded());
assertEquals(HttpStatus.OK_200, result.getResponse().getStatus());
responseLatch.countDown();
});
assertTrue(retryLatch.await(5, TimeUnit.SECONDS));
requestLatch.countDown();
assertTrue(responseLatch.await(5, TimeUnit.SECONDS));
}
private boolean await(CountDownLatch latch)
{
try
{
return latch.await(15, TimeUnit.SECONDS);
}
catch (InterruptedException x)
{
throw new RuntimeException(x);
}
}
}

View File

@ -189,8 +189,8 @@ Note: order presented here is how they would appear on the classpath.
32: 1.2 | ${jetty.home}/lib/annotations/javax.annotation-api-1.2.jar
33: {VERSION} | ${jetty.home}/lib/jetty-deploy-{VERSION}.jar
34: 1.0 | ${jetty.home}/lib/websocket/javax.websocket-api-1.0.jar
35: {VERSION} | ${jetty.home}/lib/websocket/javax-websocket-client-{VERSION}.jar
36: {VERSION} | ${jetty.home}/lib/websocket/javax-websocket-server-{VERSION}.jar
35: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-client-{VERSION}.jar
36: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-server-{VERSION}.jar
37: {VERSION} | ${jetty.home}/lib/websocket/websocket-api-{VERSION}.jar
38: {VERSION} | ${jetty.home}/lib/websocket/websocket-client-{VERSION}.jar
39: {VERSION} | ${jetty.home}/lib/websocket/websocket-common-{VERSION}.jar

View File

@ -98,8 +98,8 @@ Note: order presented here is how they would appear on the classpath.
32: 1.2 | ${jetty.home}/lib/annotations/javax.annotation-api-1.2.jar
33: {VERSION} | ${jetty.home}/lib/jetty-deploy-{VERSION}.jar
34: 1.0 | ${jetty.home}/lib/websocket/javax.websocket-api-1.0.jar
35: {VERSION} | ${jetty.home}/lib/websocket/javax-websocket-client-{VERSION}.jar
36: {VERSION} | ${jetty.home}/lib/websocket/javax-websocket-server-{VERSION}.jar
35: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-client-{VERSION}.jar
36: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-server-{VERSION}.jar
37: {VERSION} | ${jetty.home}/lib/websocket/websocket-api-{VERSION}.jar
38: {VERSION} | ${jetty.home}/lib/websocket/websocket-client-{VERSION}.jar
39: {VERSION} | ${jetty.home}/lib/websocket/websocket-common-{VERSION}.jar

View File

@ -21,12 +21,12 @@
These pages are works in progress that have not been moved to their respective sections yet.
include::jetty-websocket-api.adoc[]
include::jetty-websocket-api-events.adoc[]
include::jetty-websocket-api-session.adoc[]
include::jetty-websocket-api-send-message.adoc[]
include::jetty-websocket-api-annotations.adoc[]
include::jetty-websocket-api-listener.adoc[]
include::jetty-websocket-api-adapter.adoc[]
include::jetty-websocket-server-api.adoc[]
include::jetty-websocket-client-api.adoc[]
include::websocket-jetty-api.adoc[]
include::websocket-jetty-api-events.adoc[]
include::websocket-jetty-api-session.adoc[]
include::websocket-jetty-api-send-message.adoc[]
include::websocket-jetty-api-annotations.adoc[]
include::websocket-jetty-api-listener.adoc[]
include::websocket-jetty-api-adapter.adoc[]
include::websocket-jetty-server-api.adoc[]
include::websocket-jetty-client-api.adoc[]

View File

@ -16,14 +16,14 @@
// ========================================================================
//
[[jetty-websocket-api-adapter]]
[[websocket-jetty-api-adapter]]
=== Using the WebSocketAdapter
A basic adapter for managing the Session object on the WebSocketListener.
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/adapters/AdapterEchoSocket.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/adapters/AdapterEchoSocket.java[]
----
This is a convenience class to make using the WebSocketListener easier, and provides some useful methods to check the state of the Session.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
[[jetty-websocket-api-annotations]]
[[websocket-jetty-api-annotations]]
=== Using WebSocket Annotations
The most basic form of WebSocket is a marked up POJO with annotations
@ -24,7 +24,7 @@ provided by the Jetty WebSocket API.
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/adapters/AnnotatedEchoSocket.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/adapters/AnnotatedEchoSocket.java[]
----
The above example is a simple WebSocket echo endpoint that will echo back any TEXT messages it receives.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
[[jetty-websocket-api-events]]
[[websocket-jetty-api-events]]
=== WebSocket Events
Every WebSocket can receive various events:

View File

@ -16,14 +16,14 @@
// ========================================================================
//
[[jetty-websocket-api-listener]]
[[websocket-jetty-api-listener]]
=== Using WebSocketListener
The basic form of a WebSocket using the link:{JDURL}/org/eclipse/jetty/websocket/api/WebSocketListener.html[`org.eclipse.jetty.websocket.api.WebSocketListener`] for incoming events.
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/adapters/ListenerEchoSocket.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/endpoints/adapters/ListenerEchoSocket.java[]
----
This is by far the most basic and best performing (speed and memory wise) WebSocket implementation you can create.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
[[jetty-websocket-api-send-message]]
[[websocket-jetty-api-send-message]]
=== Send Messages to Remote Endpoint
The most important feature of the Session is access to the link:{JDURL}/org/eclipse/jetty/websocket/api/RemoteEndpoint.html[`org.eclipse.jetty.websocket.api.RemoteEndpoint`] needed to send messages.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
[[jetty-websocket-api-session]]
[[websocket-jetty-api-session]]
=== WebSocket Session
The link:{JDURL}/org/eclipse/jetty/websocket/api/Session.html[Session] object can be used to:

View File

@ -16,7 +16,7 @@
// ========================================================================
//
[[jetty-websocket-api]]
[[websocket-jetty-api]]
=== Jetty WebSocket API Usage
Jetty provides its own more powerful WebSocket API, with a common core API for both server and client use of WebSockets.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
[[jetty-websocket-client-api]]
[[websocket-jetty-client-api]]
=== Jetty WebSocket Client API
Jetty also provides a Jetty WebSocket Client Library to write make talking to WebSocket servers easier.
@ -38,14 +38,14 @@ To use the WebSocketClient you will need to hook up a WebSocket object instance
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-client/src/test/java/examples/SimpleEchoClient.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-client/src/test/java/examples/SimpleEchoClient.java[]
----
The above example connects to a remote WebSocket server and hands off a SimpleEchoSocket to perform the logic on the websocket once connected, waiting for the socket to register that it has closed.
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-client/src/test/java/examples/SimpleEchoSocket.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-client/src/test/java/examples/SimpleEchoSocket.java[]
----
When the SimpleEchoSocket connects, it sends 2 Text messages and then closes the socket.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
[[jetty-websocket-server-api]]
[[websocket-jetty-server-api]]
=== Jetty WebSocket Server API
Jetty provides the ability to wire up WebSocket endpoints to Servlet Path Specs via the use of a `JettyWebSocketServlet` bridge servlet.
@ -31,7 +31,7 @@ To wire up your WebSocket to a specific path via the `JettyWebSocketServlet`, yo
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/examples/MyEchoServlet.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/examples/MyEchoServlet.java[]
----
This example will create a Servlet mapped via the http://docs.oracle.com/javaee/6/api/javax/servlet/annotation/WebServlet.html[@WebServlet] annotation to the Servlet path spec of `"/echo"` (or you can do this manually in the `WEB-INF/web.xml` of your web application) which will create MyEchoSocket instances when encountering HTTP Upgrade requests.
@ -57,7 +57,7 @@ If you have a more complicated creation scenario, you might want to provide your
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/examples/MyAdvancedEchoCreator.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/examples/MyAdvancedEchoCreator.java[]
----
Here we show a `JettyWebSocketCreator` that will utilize the http://tools.ietf.org/html/rfc6455#section-1.9[WebSocket subprotocol] information from request to determine what WebSocket type should be
@ -65,7 +65,7 @@ created.
[source, java, subs="{sub-order}"]
----
include::{SRCDIR}/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/examples/MyAdvancedEchoServlet.java[]
include::{SRCDIR}/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/examples/MyAdvancedEchoServlet.java[]
----
When you want a custom `JettyWebSocketCreator`, use link:{JDURL}/org/eclipse/jetty/websocket/servlet/JettyWebSocketServletFactory.html#setCreator(org.eclipse.jetty.websocket.servlet.JettyWebSocketCreator)[`JettyWebSocketServletFactory.setCreator(JettyWebSocketCreator creator)`] and the `JettyWebSocketServletFactory` will use your creator for all incoming Upgrade requests on this servlet.

View File

@ -71,7 +71,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

View File

@ -58,7 +58,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

View File

@ -636,12 +636,12 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -218,12 +218,12 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -280,25 +280,25 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-api</artifactId>
<artifactId>websocket-jetty-api</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-common</artifactId>
<artifactId>websocket-jetty-common</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-client</artifactId>
<artifactId>websocket-jetty-client</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-client</artifactId>
<artifactId>websocket-javax-client</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
@ -310,7 +310,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
@ -321,7 +321,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>

View File

@ -107,9 +107,9 @@ public class TestJettyOSGiBootWithJavaxWebSocket
@Test
public void testWebsocket() throws Exception
{
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.common");
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.client");
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.websocket.server");
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.common");
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.client");
startBundle(bundleContext, "org.eclipse.jetty.websocket.javax.server");
startBundle(bundleContext, "org.eclipse.jetty.tests.webapp");
if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG))

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -148,15 +147,15 @@ public class TestOSGiUtil
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-plus").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-annotations").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("jetty-websocket-api").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("jetty-websocket-common").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-api").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-common").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-servlet").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("jetty-websocket-server").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("jetty-websocket-client").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-server").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-client").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("javax-websocket-common").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("javax-websocket-client").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("javax-websocket-server").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-javax-common").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-javax-client").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-javax-server").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-javax-websocket-api").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("jetty-osgi-boot").versionAsInProject().start());
return res;

View File

@ -113,7 +113,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId>
<artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -58,6 +58,8 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
protected SessionTableSchema _sessionTableSchema;
protected boolean _schemaProvided;
private static final ByteArrayInputStream EMPTY = new ByteArrayInputStream(new byte[0]);
/**
* SessionTableSchema
*/
@ -707,17 +709,23 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
statement.setLong(10, data.getExpiry());
statement.setLong(11, data.getMaxInactiveMs());
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos))
if(!data.getAllAttributes().isEmpty())
{
SessionData.serializeAttributes(data, oos);
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
statement.setBinaryStream(12, bais, bytes.length);//attribute map as blob
statement.executeUpdate();
if (LOG.isDebugEnabled())
LOG.debug("Inserted session " + data);
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos))
{
SessionData.serializeAttributes( data, oos );
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
statement.setBinaryStream( 12, bais, bytes.length );//attribute map as blob
}
}
else
{
statement.setBinaryStream( 12, EMPTY, 0);
}
statement.executeUpdate();
if ( LOG.isDebugEnabled() ) LOG.debug( "Inserted session " + data );
}
}
}
@ -737,20 +745,26 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
statement.setLong(5, data.getExpiry());
statement.setLong(6, data.getMaxInactiveMs());
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos))
if(!data.getAllAttributes().isEmpty())
{
SessionData.serializeAttributes(data, oos);
byte[] bytes = baos.toByteArray();
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes))
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos))
{
statement.setBinaryStream(7, bais, bytes.length);//attribute map as blob
statement.executeUpdate();
if (LOG.isDebugEnabled())
LOG.debug("Updated session " + data);
SessionData.serializeAttributes(data, oos);
byte[] bytes = baos.toByteArray();
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes))
{
statement.setBinaryStream( 7, bais, bytes.length );//attribute map as blob
}
}
}
else
{
statement.setBinaryStream( 7, EMPTY, 0);
}
statement.executeUpdate();
if ( LOG.isDebugEnabled() ) LOG.debug( "Updated session " + data );
}
}
}

View File

@ -156,7 +156,7 @@ public class SessionData implements Serializable
LOG.info("Legacy serialization detected for {}", data.getId());
//legacy serialization was used, we have just deserialized the
//entire attribute map
data._attributes = new ConcurrentHashMap<String, Object>();
data._attributes = new ConcurrentHashMap<>();
data.putAllAttributes((Map<String, Object>)o);
}
}

View File

@ -17,16 +17,16 @@
<module>websocket-core</module>
<module>websocket-servlet</module>
<!-- Jetty WebSocket Implementation -->
<module>jetty-websocket-api</module>
<module>jetty-websocket-common</module>
<module>jetty-websocket-client</module>
<module>jetty-websocket-server</module>
<module>jetty-websocket-tests</module>
<module>websocket-jetty-api</module>
<module>websocket-jetty-common</module>
<module>websocket-jetty-client</module>
<module>websocket-jetty-server</module>
<module>websocket-jetty-tests</module>
<!-- Javax WebSocket Implementation -->
<module>javax-websocket-common</module>
<module>javax-websocket-client</module>
<module>javax-websocket-server</module>
<module>javax-websocket-tests</module>
<module>websocket-javax-common</module>
<module>websocket-javax-client</module>
<module>websocket-javax-server</module>
<module>websocket-javax-tests</module>
</modules>
<build>

View File

@ -69,7 +69,7 @@
<rules>
<bannedDependencies>
<includes>
<include>org.eclipse.jetty.websocket:jetty-websocket-api</include>
<include>org.eclipse.jetty.websocket:websocket-jetty-api</include>
<include>javax.websocket</include>
</includes>
</bannedDependencies>

View File

@ -29,6 +29,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Utf8Appendable;
import org.eclipse.jetty.util.component.Dumpable;
@ -76,6 +77,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
private long maxTextMessageSize = WebSocketConstants.DEFAULT_MAX_TEXT_MESSAGE_SIZE;
private Duration idleTimeout = WebSocketConstants.DEFAULT_IDLE_TIMEOUT;
private Duration writeTimeout = WebSocketConstants.DEFAULT_WRITE_TIMEOUT;
private final ContextHandler contextHandler;
public WebSocketCoreSession(FrameHandler handler, Behavior behavior, Negotiated negotiated)
{
@ -83,9 +85,28 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
this.behavior = behavior;
this.negotiated = negotiated;
this.demanding = handler.isDemanding();
if (behavior == Behavior.SERVER)
{
ContextHandler.Context context = ContextHandler.getCurrentContext();
this.contextHandler = (context != null) ? context.getContextHandler() : null;
}
else
{
this.contextHandler = null;
}
negotiated.getExtensions().initialize(new IncomingAdaptor(), new OutgoingAdaptor(), this);
}
private void handle(Runnable runnable)
{
if (contextHandler != null)
contextHandler.handle(runnable);
else
runnable.run();
}
/**
* @return True if the sessions handling is demanding.
*/
@ -152,7 +173,6 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
throw new ProtocolException("Frame has non-transmittable status code");
}
}
}
}
@ -325,7 +345,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
{
try
{
handler.onClosed(closeStatus, callback);
handle(() -> handler.onClosed(closeStatus, callback));
}
catch (Throwable e)
{
@ -337,7 +357,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
Throwable cause = closeStatus.getCause();
try
{
handler.onError(cause, errorCallback);
handle(() -> handler.onError(cause, errorCallback));
}
catch (Throwable e)
{
@ -351,7 +371,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
{
try
{
handler.onClosed(closeStatus, callback);
handle(() -> handler.onClosed(closeStatus, callback));
}
catch (Throwable e)
{
@ -454,7 +474,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
try
{
// Open connection and handler
handler.onOpen(this, openCallback);
handle(() -> handler.onOpen(this, openCallback));
}
catch (Throwable t)
{
@ -664,7 +684,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
// Handle inbound frame
if (frame.getOpCode() != OpCode.CLOSE)
{
handler.onFrame(frame, callback);
handle(() -> handler.onFrame(frame, callback));
return;
}

View File

@ -7,17 +7,17 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>javax-websocket-client</artifactId>
<name>Jetty :: Websocket :: javax.websocket :: Client Implementation</name>
<artifactId>websocket-javax-client</artifactId>
<name>Jetty :: Websocket :: javax.websocket :: Client</name>
<properties>
<bundle-symbolic-name>${project.groupId}.javax.websocket.client</bundle-symbolic-name>
<bundle-symbolic-name>${project.groupId}.javax.client</bundle-symbolic-name>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-common</artifactId>
<artifactId>websocket-javax-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -7,11 +7,11 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>javax-websocket-common</artifactId>
<name>Jetty :: Websocket :: javax.websocket :: Common Impl</name>
<artifactId>websocket-javax-common</artifactId>
<name>Jetty :: Websocket :: javax.websocket :: Common</name>
<properties>
<bundle-symbolic-name>${project.groupId}.javax.websocket.common</bundle-symbolic-name>
<bundle-symbolic-name>${project.groupId}.javax.common</bundle-symbolic-name>
</properties>
<build>

View File

@ -292,6 +292,11 @@ public class JavaxWebSocketSession implements javax.websocket.Session
return frameHandler;
}
public void abort()
{
coreSession.abort();
}
/**
* {@inheritDoc}
*

Some files were not shown because too many files have changed in this diff Show More