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:
Lachlan Roberts 2019-01-23 10:18:42 +11:00
parent 74a5cfa190
commit b06601e5f1
3 changed files with 20 additions and 16 deletions

View File

@ -18,6 +18,20 @@
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.WorkDirExtension;
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.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.Matchers.is;
@ -62,6 +63,7 @@ public class EndpointViaConfigTest
@ServerEndpoint("/echo")
public static class BasicEchoEndpoint extends WSEventTracker implements MessageHandler.Whole<String>
{
@Override
public void onMessage(String msg)
{
super.onWsText(msg);

View File

@ -120,8 +120,9 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, FrameHandler.Customizer customizer)
throws WebSocketException
{
if (getMapping(pathSpec) != null)
throw new WebSocketException("Duplicate WebSocket Mapping for PathSpec");
// TODO evaluate why this can't be done
//if (getMapping(pathSpec) != null)
// throw new WebSocketException("Duplicate WebSocket Mapping for PathSpec");
mappings.put(pathSpec, new Negotiator(creator, factory, customizer));
}

View File

@ -43,6 +43,7 @@ import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.core.FrameHandler;
import org.eclipse.jetty.websocket.core.WebSocketResources;
/**
* Inline Servlet Filter to capture WebSocket upgrade requests.
@ -184,7 +185,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
final ServletContext context = config.getServletContext();
if (mapping == null)
throw new IllegalStateException("no websocket mapping set in container");
mapping = new WebSocketMapping(WebSocketResources.ensureWebSocketResources(context));
String max = config.getInitParameter("maxIdleTime");
if (max != null)