Fixed erroneous warning message when the context path is "/".

This commit is contained in:
Simone Bordet 2013-08-12 22:46:28 +02:00
parent 0cc46e8beb
commit 6a831dc2ca
1 changed files with 19 additions and 23 deletions

View File

@ -40,7 +40,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterRegistration; import javax.servlet.FilterRegistration;
@ -62,9 +61,6 @@ import javax.servlet.SessionTrackingMode;
import javax.servlet.descriptor.JspConfigDescriptor; import javax.servlet.descriptor.JspConfigDescriptor;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionIdListener;
import javax.servlet.http.HttpSessionListener;
import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.server.ClassLoaderDump; import org.eclipse.jetty.server.ClassLoaderDump;
@ -107,7 +103,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
{ {
public final static int SERVLET_MAJOR_VERSION=3; public final static int SERVLET_MAJOR_VERSION=3;
public final static int SERVLET_MINOR_VERSION=0; public final static int SERVLET_MINOR_VERSION=0;
public static final Class[] SERVLET_LISTENER_TYPES = new Class[] {ServletContextListener.class, public static final Class[] SERVLET_LISTENER_TYPES = new Class[] {ServletContextListener.class,
ServletContextAttributeListener.class, ServletContextAttributeListener.class,
ServletRequestListener.class, ServletRequestListener.class,
ServletRequestAttributeListener.class}; ServletRequestAttributeListener.class};
@ -559,7 +555,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
_requestListeners.clear(); _requestListeners.clear();
_requestAttributeListeners.clear(); _requestAttributeListeners.clear();
_eventListeners.clear(); _eventListeners.clear();
if (eventListeners!=null) if (eventListeners!=null)
for (EventListener listener : eventListeners) for (EventListener listener : eventListeners)
addEventListener(listener); addEventListener(listener);
@ -637,7 +633,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
return _programmaticListeners.contains(listener); return _programmaticListeners.contains(listener);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** /**
@ -837,7 +833,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
for (int i = _contextListeners.size(); i-->0;) for (int i = _contextListeners.size(); i-->0;)
callContextDestroyed(_contextListeners.get(i),event); callContextDestroyed(_contextListeners.get(i),event);
} }
//retain only durable listeners //retain only durable listeners
setEventListeners(_durableListeners.toArray(new EventListener[_durableListeners.size()])); setEventListeners(_durableListeners.toArray(new EventListener[_durableListeners.size()]));
_durableListeners.clear(); _durableListeners.clear();
@ -977,8 +973,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
if (old_context != _scontext) if (old_context != _scontext)
{ {
// check the target. // check the target.
if (DispatcherType.REQUEST.equals(dispatch) || if (DispatcherType.REQUEST.equals(dispatch) ||
DispatcherType.ASYNC.equals(dispatch) || DispatcherType.ASYNC.equals(dispatch) ||
DispatcherType.ERROR.equals(dispatch) && baseRequest.getHttpChannelState().isAsync()) DispatcherType.ERROR.equals(dispatch) && baseRequest.getHttpChannelState().isAsync())
{ {
if (_compactPath) if (_compactPath)
@ -1309,18 +1305,18 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
LOG.warn(this+" contextPath ends with /*"); LOG.warn(this+" contextPath ends with /*");
contextPath=contextPath.substring(0,contextPath.length()-2); contextPath=contextPath.substring(0,contextPath.length()-2);
} }
else if (contextPath.endsWith("/")) else if (contextPath.length()>1 && contextPath.endsWith("/"))
{ {
LOG.warn(this+" contextPath ends with /"); LOG.warn(this+" contextPath ends with /");
contextPath=contextPath.substring(0,contextPath.length()-1); contextPath=contextPath.substring(0,contextPath.length()-1);
} }
if (contextPath.length()==0) if (contextPath.length()==0)
{ {
LOG.warn("Empty contextPath"); LOG.warn("Empty contextPath");
contextPath="/"; contextPath="/";
} }
_contextPath = contextPath; _contextPath = contextPath;
if (getServer() != null && (getServer().isStarting() || getServer().isStarted())) if (getServer() != null && (getServer().isStarting() || getServer().isStarted()))
@ -1732,7 +1728,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
{ {
protected boolean _enabled = true; //whether or not the dynamic API is enabled for callers protected boolean _enabled = true; //whether or not the dynamic API is enabled for callers
protected boolean _extendedListenerTypes = false; protected boolean _extendedListenerTypes = false;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected Context() protected Context()
@ -2153,7 +2149,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
checkListener(t.getClass()); checkListener(t.getClass());
ContextHandler.this.addEventListener(t); ContextHandler.this.addEventListener(t);
ContextHandler.this.addProgrammaticListener(t); ContextHandler.this.addProgrammaticListener(t);
} }
@ -2165,7 +2161,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
checkListener(listenerClass); checkListener(listenerClass);
try try
{ {
EventListener e = createListener(listenerClass); EventListener e = createListener(listenerClass);
@ -2191,7 +2187,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
} }
} }
public void checkListener (Class<? extends EventListener> listener) throws IllegalStateException public void checkListener (Class<? extends EventListener> listener) throws IllegalStateException
{ {
boolean ok = false; boolean ok = false;
@ -2212,13 +2208,13 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
{ {
_extendedListenerTypes = extended; _extendedListenerTypes = extended;
} }
public boolean isExtendedListenerTypes() public boolean isExtendedListenerTypes()
{ {
return _extendedListenerTypes; return _extendedListenerTypes;
} }
@Override @Override
public ClassLoader getClassLoader() public ClassLoader getClassLoader()
{ {
@ -2256,8 +2252,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
{ {
return _enabled; return _enabled;
} }
public <T> T createInstance (Class<T> clazz) throws Exception public <T> T createInstance (Class<T> clazz) throws Exception
{ {
@ -2605,7 +2601,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
LOG.warn(__unimplmented); LOG.warn(__unimplmented);
} }
/** /**
* @see javax.servlet.ServletContext#getVirtualServerName() * @see javax.servlet.ServletContext#getVirtualServerName()
*/ */
@Override @Override