Issue #3162 - Correcting websocket issues in OSGi
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
8ff82423f9
commit
c3348a0a03
|
@ -14,8 +14,8 @@
|
|||
<bundle-symbolic-name>${project.groupId}.boot.test.osgi</bundle-symbolic-name>
|
||||
<jetty-orbit-url>http://download.eclipse.org/jetty/orbit/</jetty-orbit-url>
|
||||
<assembly-directory>target/distribution</assembly-directory>
|
||||
<exam.version>4.12.0</exam.version>
|
||||
<url.version>2.5.2</url.version>
|
||||
<exam.version>4.13.0</exam.version>
|
||||
<url.version>2.5.4</url.version>
|
||||
<injection.bundle.version>1.0</injection.bundle.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
@ -65,7 +65,7 @@
|
|||
<dependency>
|
||||
<groupId>org.ops4j.pax.url</groupId>
|
||||
<artifactId>pax-url-wrap</artifactId>
|
||||
<version>2.5.4</version>
|
||||
<version>${url.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -81,9 +81,9 @@
|
|||
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.webapp.JmxConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.server.JettyWebSocketConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.jsr356.JavaxWebSocketExtensionConfig</Item>
|
||||
<Item>org.eclipse.jetty.osgi.annotations.AnnotationConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.server.JettyWebSocketConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.jsr356.server.JavaxWebSocketConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.osgi.boot.OSGiMetaInfConfiguration</Item>
|
||||
</Array>
|
||||
|
|
|
@ -85,9 +85,9 @@
|
|||
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.webapp.JmxConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.server.JettyWebSocketConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.jsr356.JavaxWebSocketExtensionConfig</Item>
|
||||
<Item>org.eclipse.jetty.osgi.annotations.AnnotationConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.server.JettyWebSocketConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.websocket.jsr356.server.JavaxWebSocketConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.osgi.boot.OSGiMetaInfConfiguration</Item>
|
||||
</Array>
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
package org.eclipse.jetty.osgi.test;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.StatusCode;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
|
||||
|
@ -35,6 +36,7 @@ import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
|||
@WebSocket(maxTextMessageSize = 64 * 1024)
|
||||
public class SimpleEchoSocket
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SimpleEchoSocket.class);
|
||||
private final CountDownLatch closeLatch;
|
||||
@SuppressWarnings("unused")
|
||||
private Session session;
|
||||
|
@ -52,7 +54,8 @@ public class SimpleEchoSocket
|
|||
@OnWebSocketClose
|
||||
public void onClose(int statusCode, String reason)
|
||||
{
|
||||
//System.out.printf("Connection closed: %d - %s%n",statusCode,reason);
|
||||
LOG.debug("Connection closed: {} - {}", statusCode, reason);
|
||||
|
||||
this.session = null;
|
||||
this.closeLatch.countDown(); // trigger latch
|
||||
}
|
||||
|
@ -60,16 +63,11 @@ public class SimpleEchoSocket
|
|||
@OnWebSocketConnect
|
||||
public void onConnect(Session session)
|
||||
{
|
||||
//System.out.printf("Got connect: %s%n",session);
|
||||
LOG.debug("Got connect: {}", session);
|
||||
this.session = session;
|
||||
try
|
||||
{
|
||||
Future<Void> fut;
|
||||
//System.err.println("Sending Foo!");
|
||||
fut = session.getRemote().sendStringByFuture("Foo");
|
||||
|
||||
fut.get(2,TimeUnit.SECONDS); // wait for send to complete.
|
||||
//System.err.println("Foo complete");
|
||||
session.getRemote().sendString("Foo");
|
||||
|
||||
session.close(StatusCode.NORMAL,"I'm done");
|
||||
}
|
||||
|
@ -82,6 +80,6 @@ public class SimpleEchoSocket
|
|||
@OnWebSocketMessage
|
||||
public void onMessage(String msg)
|
||||
{
|
||||
//System.out.printf("Got msg: %s%n",msg);
|
||||
LOG.debug("Got msg: {}", msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public class TestJettyOSGiBootWithWebSocket
|
|||
public static Option[] configure()
|
||||
{
|
||||
ArrayList<Option> options = new ArrayList<>();
|
||||
options.add(TestOSGiUtil.optionalRemoteDebug());
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-with-websocket.xml"));
|
||||
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.sql.*","javax.xml.*", "javax.activation.*"));
|
||||
|
|
|
@ -97,7 +97,12 @@ public class TestOSGiUtil
|
|||
res.addAll(coreJettyDependencies());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static Option optionalRemoteDebug()
|
||||
{
|
||||
return CoreOptions.when(Boolean.getBoolean("pax.exam.debug.remote"))
|
||||
.useOptions(CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"));
|
||||
}
|
||||
|
||||
public static List<Option> coreJettyDependencies()
|
||||
{
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -48,7 +48,7 @@
|
|||
<logback.version>1.2.3</logback.version>
|
||||
<spring-version>5.1.1.RELEASE</spring-version>
|
||||
<jetty-test-policy.version>1.2</jetty-test-policy.version>
|
||||
<servlet.api.version>4.0.0-SNAPSHOT</servlet.api.version>
|
||||
<servlet.api.version>4.0.1-SNAPSHOT</servlet.api.version>
|
||||
<jsp.version>8.5.33</jsp.version>
|
||||
<!-- default values are unsupported, but required to be defined for reactor sanity reasons -->
|
||||
<alpn.version>undefined</alpn.version>
|
||||
|
|
Loading…
Reference in New Issue