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>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId> <artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-client</artifactId> <artifactId>websocket-jetty-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<!-- http/2 support --> <!-- http/2 support -->

View File

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

View File

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

View File

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

View File

@ -123,10 +123,16 @@ public abstract class HttpConnection implements IConnection
protected void normalizeRequest(Request request) protected void normalizeRequest(Request request)
{ {
final HttpVersion version = request.getVersion(); boolean normalized = ((HttpRequest)request).normalized();
final HttpFields headers = request.getHeaders(); if (LOG.isDebugEnabled())
final ContentProvider content = request.getContent(); LOG.debug("Normalizing {} {}", !normalized, request);
final ProxyConfiguration.Proxy proxy = destination.getProxy(); 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 // Make sure the path is there
String path = request.getPath(); 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(); HttpClient client = getHttpClient();
final HttpExchange exchange = getHttpExchanges().poll(); HttpExchange exchange = getHttpExchanges().poll();
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Processing exchange {} on {} of {}", exchange, connection, this); LOG.debug("Processing exchange {} on {} of {}", exchange, connection, this);
if (exchange == null) if (exchange == null)
@ -331,7 +331,7 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
} }
else else
{ {
final Request request = exchange.getRequest(); Request request = exchange.getRequest();
Throwable cause = request.getAbortCause(); Throwable cause = request.getAbortCause();
if (cause != null) if (cause != null)
{ {
@ -347,21 +347,30 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
} }
else else
{ {
SendFailure result = ((IConnection)connection).send(exchange); SendFailure result = send((IConnection)connection, exchange);
if (result != null) if (result != null)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Send failed {} for {}", result, exchange); LOG.debug("Send failed {} for {}", result, exchange);
if (result.retry) if (result.retry)
{
// Resend this exchange, likely on another connection,
// and return false to avoid to re-enter this method.
send(exchange); send(exchange);
else return false;
request.abort(result.failure); }
request.abort(result.failure);
} }
} }
return getHttpExchanges().peek() != null; return getHttpExchanges().peek() != null;
} }
} }
protected SendFailure send(IConnection connection, HttpExchange exchange)
{
return connection.send(exchange);
}
@Override @Override
public void newConnection(Promise<Connection> promise) public void newConnection(Promise<Connection> promise)
{ {

View File

@ -90,6 +90,7 @@ public class HttpRequest implements Request
private Supplier<HttpFields> trailers; private Supplier<HttpFields> trailers;
private String upgradeProtocol; private String upgradeProtocol;
private Object tag; private Object tag;
private boolean normalized;
protected HttpRequest(HttpClient client, HttpConversation conversation, URI uri) protected HttpRequest(HttpClient client, HttpConversation conversation, URI uri)
{ {
@ -822,6 +823,23 @@ public class HttpRequest implements Request
return aborted.get(); 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() private String buildQuery()
{ {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();

View File

@ -32,6 +32,10 @@ public class SendFailure
@Override @Override
public String toString() 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() public boolean onIdleExpired()
{ {
long idleTimeout = getEndPoint().getIdleTimeout(); long idleTimeout = getEndPoint().getIdleTimeout();
boolean close = delegate.onIdleTimeout(idleTimeout); boolean close = onIdleTimeout(idleTimeout);
if (close) if (close)
close(new TimeoutException("Idle timeout " + idleTimeout + " ms")); close(new TimeoutException("Idle timeout " + idleTimeout + " ms"));
return false; return false;
} }
protected boolean onIdleTimeout(long idleTimeout)
{
return delegate.onIdleTimeout(idleTimeout);
}
@Override @Override
public void onFillable() 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 32: 1.2 | ${jetty.home}/lib/annotations/javax.annotation-api-1.2.jar
33: {VERSION} | ${jetty.home}/lib/jetty-deploy-{VERSION}.jar 33: {VERSION} | ${jetty.home}/lib/jetty-deploy-{VERSION}.jar
34: 1.0 | ${jetty.home}/lib/websocket/javax.websocket-api-1.0.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 35: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-client-{VERSION}.jar
36: {VERSION} | ${jetty.home}/lib/websocket/javax-websocket-server-{VERSION}.jar 36: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-server-{VERSION}.jar
37: {VERSION} | ${jetty.home}/lib/websocket/websocket-api-{VERSION}.jar 37: {VERSION} | ${jetty.home}/lib/websocket/websocket-api-{VERSION}.jar
38: {VERSION} | ${jetty.home}/lib/websocket/websocket-client-{VERSION}.jar 38: {VERSION} | ${jetty.home}/lib/websocket/websocket-client-{VERSION}.jar
39: {VERSION} | ${jetty.home}/lib/websocket/websocket-common-{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 32: 1.2 | ${jetty.home}/lib/annotations/javax.annotation-api-1.2.jar
33: {VERSION} | ${jetty.home}/lib/jetty-deploy-{VERSION}.jar 33: {VERSION} | ${jetty.home}/lib/jetty-deploy-{VERSION}.jar
34: 1.0 | ${jetty.home}/lib/websocket/javax.websocket-api-1.0.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 35: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-client-{VERSION}.jar
36: {VERSION} | ${jetty.home}/lib/websocket/javax-websocket-server-{VERSION}.jar 36: {VERSION} | ${jetty.home}/lib/websocket/websocket-javax-server-{VERSION}.jar
37: {VERSION} | ${jetty.home}/lib/websocket/websocket-api-{VERSION}.jar 37: {VERSION} | ${jetty.home}/lib/websocket/websocket-api-{VERSION}.jar
38: {VERSION} | ${jetty.home}/lib/websocket/websocket-client-{VERSION}.jar 38: {VERSION} | ${jetty.home}/lib/websocket/websocket-client-{VERSION}.jar
39: {VERSION} | ${jetty.home}/lib/websocket/websocket-common-{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. These pages are works in progress that have not been moved to their respective sections yet.
include::jetty-websocket-api.adoc[] include::websocket-jetty-api.adoc[]
include::jetty-websocket-api-events.adoc[] include::websocket-jetty-api-events.adoc[]
include::jetty-websocket-api-session.adoc[] include::websocket-jetty-api-session.adoc[]
include::jetty-websocket-api-send-message.adoc[] include::websocket-jetty-api-send-message.adoc[]
include::jetty-websocket-api-annotations.adoc[] include::websocket-jetty-api-annotations.adoc[]
include::jetty-websocket-api-listener.adoc[] include::websocket-jetty-api-listener.adoc[]
include::jetty-websocket-api-adapter.adoc[] include::websocket-jetty-api-adapter.adoc[]
include::jetty-websocket-server-api.adoc[] include::websocket-jetty-server-api.adoc[]
include::jetty-websocket-client-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 === Using the WebSocketAdapter
A basic adapter for managing the Session object on the WebSocketListener. A basic adapter for managing the Session object on the WebSocketListener.
[source, java, subs="{sub-order}"] [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. 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 === Using WebSocket Annotations
The most basic form of WebSocket is a marked up POJO with 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}"] [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. 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 === WebSocket Events
Every WebSocket can receive various events: Every WebSocket can receive various events:

View File

@ -16,14 +16,14 @@
// ======================================================================== // ========================================================================
// //
[[jetty-websocket-api-listener]] [[websocket-jetty-api-listener]]
=== Using WebSocketListener === 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. 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}"] [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. 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 === 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. 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 === WebSocket Session
The link:{JDURL}/org/eclipse/jetty/websocket/api/Session.html[Session] object can be used to: 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 WebSocket API Usage
Jetty provides its own more powerful WebSocket API, with a common core API for both server and client use of WebSockets. 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 WebSocket Client API
Jetty also provides a Jetty WebSocket Client Library to write make talking to WebSocket servers easier. 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}"] [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. 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}"] [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. 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 WebSocket Server API
Jetty provides the ability to wire up WebSocket endpoints to Servlet Path Specs via the use of a `JettyWebSocketServlet` bridge servlet. 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}"] [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. 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}"] [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 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}"] [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. 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>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId> <artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; 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-plus").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-annotations").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("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("websocket-jetty-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-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("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("websocket-jetty-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-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("websocket-javax-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("websocket-javax-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-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.toolchain").artifactId("jetty-javax-websocket-api").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("jetty-osgi-boot").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("jetty-osgi-boot").versionAsInProject().start());
return res; return res;

View File

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

View File

@ -58,6 +58,8 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
protected SessionTableSchema _sessionTableSchema; protected SessionTableSchema _sessionTableSchema;
protected boolean _schemaProvided; protected boolean _schemaProvided;
private static final ByteArrayInputStream EMPTY = new ByteArrayInputStream(new byte[0]);
/** /**
* SessionTableSchema * SessionTableSchema
*/ */
@ -707,17 +709,23 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
statement.setLong(10, data.getExpiry()); statement.setLong(10, data.getExpiry());
statement.setLong(11, data.getMaxInactiveMs()); statement.setLong(11, data.getMaxInactiveMs());
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); if(!data.getAllAttributes().isEmpty())
ObjectOutputStream oos = new ObjectOutputStream(baos))
{ {
SessionData.serializeAttributes(data, oos); try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] bytes = baos.toByteArray(); ObjectOutputStream oos = new ObjectOutputStream(baos))
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); {
statement.setBinaryStream(12, bais, bytes.length);//attribute map as blob SessionData.serializeAttributes( data, oos );
statement.executeUpdate(); byte[] bytes = baos.toByteArray();
if (LOG.isDebugEnabled()) ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
LOG.debug("Inserted session " + data); 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(5, data.getExpiry());
statement.setLong(6, data.getMaxInactiveMs()); statement.setLong(6, data.getMaxInactiveMs());
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); if(!data.getAllAttributes().isEmpty())
ObjectOutputStream oos = new ObjectOutputStream(baos))
{ {
SessionData.serializeAttributes(data, oos); try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] bytes = baos.toByteArray(); ObjectOutputStream oos = new ObjectOutputStream(baos))
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes))
{ {
statement.setBinaryStream(7, bais, bytes.length);//attribute map as blob SessionData.serializeAttributes(data, oos);
statement.executeUpdate(); byte[] bytes = baos.toByteArray();
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes))
if (LOG.isDebugEnabled()) {
LOG.debug("Updated session " + data); 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()); LOG.info("Legacy serialization detected for {}", data.getId());
//legacy serialization was used, we have just deserialized the //legacy serialization was used, we have just deserialized the
//entire attribute map //entire attribute map
data._attributes = new ConcurrentHashMap<String, Object>(); data._attributes = new ConcurrentHashMap<>();
data.putAllAttributes((Map<String, Object>)o); data.putAllAttributes((Map<String, Object>)o);
} }
} }

View File

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

View File

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

View File

@ -29,6 +29,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Utf8Appendable; import org.eclipse.jetty.util.Utf8Appendable;
import org.eclipse.jetty.util.component.Dumpable; 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 long maxTextMessageSize = WebSocketConstants.DEFAULT_MAX_TEXT_MESSAGE_SIZE;
private Duration idleTimeout = WebSocketConstants.DEFAULT_IDLE_TIMEOUT; private Duration idleTimeout = WebSocketConstants.DEFAULT_IDLE_TIMEOUT;
private Duration writeTimeout = WebSocketConstants.DEFAULT_WRITE_TIMEOUT; private Duration writeTimeout = WebSocketConstants.DEFAULT_WRITE_TIMEOUT;
private final ContextHandler contextHandler;
public WebSocketCoreSession(FrameHandler handler, Behavior behavior, Negotiated negotiated) public WebSocketCoreSession(FrameHandler handler, Behavior behavior, Negotiated negotiated)
{ {
@ -83,9 +85,28 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
this.behavior = behavior; this.behavior = behavior;
this.negotiated = negotiated; this.negotiated = negotiated;
this.demanding = handler.isDemanding(); 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); 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. * @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"); throw new ProtocolException("Frame has non-transmittable status code");
} }
} }
} }
} }
@ -325,7 +345,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
{ {
try try
{ {
handler.onClosed(closeStatus, callback); handle(() -> handler.onClosed(closeStatus, callback));
} }
catch (Throwable e) catch (Throwable e)
{ {
@ -337,7 +357,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
Throwable cause = closeStatus.getCause(); Throwable cause = closeStatus.getCause();
try try
{ {
handler.onError(cause, errorCallback); handle(() -> handler.onError(cause, errorCallback));
} }
catch (Throwable e) catch (Throwable e)
{ {
@ -351,7 +371,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
{ {
try try
{ {
handler.onClosed(closeStatus, callback); handle(() -> handler.onClosed(closeStatus, callback));
} }
catch (Throwable e) catch (Throwable e)
{ {
@ -454,7 +474,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
try try
{ {
// Open connection and handler // Open connection and handler
handler.onOpen(this, openCallback); handle(() -> handler.onOpen(this, openCallback));
} }
catch (Throwable t) catch (Throwable t)
{ {
@ -664,7 +684,7 @@ public class WebSocketCoreSession implements IncomingFrames, FrameHandler.CoreSe
// Handle inbound frame // Handle inbound frame
if (frame.getOpCode() != OpCode.CLOSE) if (frame.getOpCode() != OpCode.CLOSE)
{ {
handler.onFrame(frame, callback); handle(() -> handler.onFrame(frame, callback));
return; return;
} }

View File

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

View File

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

View File

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

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