disable checks for duplicate websocket mappings
throwing on adding of a duplicate websocket mapping causes problems in EndpointViaConfigTest where we can add mappings even if they have already been discovered by annotation added a todo to review why we can't implement this check Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
74a5cfa190
commit
b06601e5f1
|
@ -18,6 +18,20 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.websocket.javax.tests.server;
|
package org.eclipse.jetty.websocket.javax.tests.server;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
import javax.websocket.DeploymentException;
|
||||||
|
import javax.websocket.EndpointConfig;
|
||||||
|
import javax.websocket.MessageHandler;
|
||||||
|
import javax.websocket.OnOpen;
|
||||||
|
import javax.websocket.Session;
|
||||||
|
import javax.websocket.server.ServerEndpoint;
|
||||||
|
import javax.websocket.server.ServerEndpointConfig;
|
||||||
|
|
||||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
||||||
import org.eclipse.jetty.util.Callback;
|
import org.eclipse.jetty.util.Callback;
|
||||||
|
@ -34,19 +48,6 @@ import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameHandlerTracker
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import javax.servlet.ServletContextEvent;
|
|
||||||
import javax.servlet.ServletContextListener;
|
|
||||||
import javax.websocket.DeploymentException;
|
|
||||||
import javax.websocket.EndpointConfig;
|
|
||||||
import javax.websocket.MessageHandler;
|
|
||||||
import javax.websocket.OnOpen;
|
|
||||||
import javax.websocket.Session;
|
|
||||||
import javax.websocket.server.ServerEndpoint;
|
|
||||||
import javax.websocket.server.ServerEndpointConfig;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ public class EndpointViaConfigTest
|
||||||
@ServerEndpoint("/echo")
|
@ServerEndpoint("/echo")
|
||||||
public static class BasicEchoEndpoint extends WSEventTracker implements MessageHandler.Whole<String>
|
public static class BasicEchoEndpoint extends WSEventTracker implements MessageHandler.Whole<String>
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public void onMessage(String msg)
|
public void onMessage(String msg)
|
||||||
{
|
{
|
||||||
super.onWsText(msg);
|
super.onWsText(msg);
|
||||||
|
|
|
@ -120,8 +120,9 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
||||||
public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, FrameHandler.Customizer customizer)
|
public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, FrameHandler.Customizer customizer)
|
||||||
throws WebSocketException
|
throws WebSocketException
|
||||||
{
|
{
|
||||||
if (getMapping(pathSpec) != null)
|
// TODO evaluate why this can't be done
|
||||||
throw new WebSocketException("Duplicate WebSocket Mapping for PathSpec");
|
//if (getMapping(pathSpec) != null)
|
||||||
|
// throw new WebSocketException("Duplicate WebSocket Mapping for PathSpec");
|
||||||
|
|
||||||
mappings.put(pathSpec, new Negotiator(creator, factory, customizer));
|
mappings.put(pathSpec, new Negotiator(creator, factory, customizer));
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.jetty.util.component.Dumpable;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||||
|
import org.eclipse.jetty.websocket.core.WebSocketResources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inline Servlet Filter to capture WebSocket upgrade requests.
|
* Inline Servlet Filter to capture WebSocket upgrade requests.
|
||||||
|
@ -184,7 +185,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
||||||
final ServletContext context = config.getServletContext();
|
final ServletContext context = config.getServletContext();
|
||||||
|
|
||||||
if (mapping == null)
|
if (mapping == null)
|
||||||
throw new IllegalStateException("no websocket mapping set in container");
|
mapping = new WebSocketMapping(WebSocketResources.ensureWebSocketResources(context));
|
||||||
|
|
||||||
String max = config.getInitParameter("maxIdleTime");
|
String max = config.getInitParameter("maxIdleTime");
|
||||||
if (max != null)
|
if (max != null)
|
||||||
|
|
Loading…
Reference in New Issue