WebSocket / making sure that filter always sees the correct target path, regardless of servlets

This commit is contained in:
Joakim Erdfelt 2013-09-11 08:56:19 -07:00
parent 09f01963ca
commit 4b3541b7d1
3 changed files with 18 additions and 2 deletions

View File

@ -45,6 +45,12 @@ public class OnErrorCallable extends JsrCallable
public void call(Object endpoint, Throwable cause)
{
if (idxThrowable == (-1))
{
idxThrowable = findIndexForRole(Param.Role.ERROR_CAUSE);
assertRoleRequired(idxThrowable,"Throwable");
}
if (idxThrowable >= 0)
{
super.args[idxThrowable] = cause;

View File

@ -45,7 +45,10 @@ public class EchoClientSocket extends TrackingSocket
public void close() throws IOException
{
this.session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE,"Test Complete"));
if (session != null)
{
this.session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE,"Test Complete"));
}
}
@OnClose
@ -82,7 +85,7 @@ public class EchoClientSocket extends TrackingSocket
addEvent(text);
eventCountLatch.countDown();
}
public boolean awaitAllEvents(long timeout, TimeUnit unit) throws InterruptedException
{
return eventCountLatch.await(timeout,unit);

View File

@ -110,7 +110,14 @@ public class WebSocketUpgradeFilter extends ContainerLifeCycle implements Filter
{
HttpServletRequest httpreq = (HttpServletRequest)request;
HttpServletResponse httpresp = (HttpServletResponse)response;
// Since this is a filter, we need to be smart about determining the target path
String contextPath = httpreq.getContextPath();
String target = httpreq.getRequestURI();
if (target.startsWith(contextPath))
{
target = target.substring(contextPath.length());
}
if (factory.isUpgradeRequest(httpreq,httpresp))
{