392237 fixed many TODOs and many minor code cleanups

This commit is contained in:
Greg Wilkins 2012-10-19 16:17:30 +11:00
parent f420f5016d
commit 2b13648b0e
90 changed files with 429 additions and 474 deletions

View File

@ -25,10 +25,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.JarEntry;
import org.eclipse.jetty.util.Loader;
@ -105,11 +102,13 @@ public class AnnotationParser
{
_val=val;
}
@Override
public Object getValue()
{
return _val;
}
@Override
public String toString()
{
return "("+getName()+":"+_val+")";
@ -126,6 +125,7 @@ public class AnnotationParser
_val = new ArrayList<Value>();
}
@Override
public Object getValue()
{
return _val;
@ -146,6 +146,7 @@ public class AnnotationParser
return _val.size();
}
@Override
public String toString()
{
StringBuffer buff = new StringBuffer();
@ -300,6 +301,7 @@ public class AnnotationParser
* Visit a single-valued (name,value) pair for this annotation
* @see org.objectweb.asm.AnnotationVisitor#visit(java.lang.String, java.lang.Object)
*/
@Override
public void visit(String aname, Object avalue)
{
SimpleValue v = new SimpleValue(aname);
@ -311,6 +313,7 @@ public class AnnotationParser
* Visit a (name,value) pair whose value is another Annotation
* @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(java.lang.String, java.lang.String)
*/
@Override
public AnnotationVisitor visitAnnotation(String name, String desc)
{
String s = normalize(desc);
@ -324,6 +327,7 @@ public class AnnotationParser
* Visit an array valued (name, value) pair for this annotation
* @see org.objectweb.asm.AnnotationVisitor#visitArray(java.lang.String)
*/
@Override
public AnnotationVisitor visitArray(String name)
{
ListValue v = new ListValue(name);
@ -336,11 +340,13 @@ public class AnnotationParser
* Visit a enum-valued (name,value) pair for this annotation
* @see org.objectweb.asm.AnnotationVisitor#visitEnum(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public void visitEnum(String name, String desc, String value)
{
//TODO
}
@Override
public void visitEnd()
{
}
@ -364,6 +370,7 @@ public class AnnotationParser
int _version;
@Override
public void visit (int version,
final int access,
final String name,
@ -398,10 +405,12 @@ public class AnnotationParser
}
}
@Override
public AnnotationVisitor visitAnnotation (String desc, boolean visible)
{
MyAnnotationVisitor visitor = new MyAnnotationVisitor(normalize(desc), new ArrayList<Value>())
{
@Override
public void visitEnd()
{
super.visitEnd();
@ -422,6 +431,7 @@ public class AnnotationParser
return visitor;
}
@Override
public MethodVisitor visitMethod (final int access,
final String name,
final String methodDesc,
@ -431,10 +441,12 @@ public class AnnotationParser
return new EmptyVisitor ()
{
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible)
{
MyAnnotationVisitor visitor = new MyAnnotationVisitor (normalize(desc), new ArrayList<Value>())
{
@Override
public void visitEnd()
{
super.visitEnd();
@ -456,6 +468,7 @@ public class AnnotationParser
};
}
@Override
public FieldVisitor visitField (final int access,
final String fieldName,
final String fieldType,
@ -465,10 +478,12 @@ public class AnnotationParser
return new EmptyVisitor ()
{
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible)
{
MyAnnotationVisitor visitor = new MyAnnotationVisitor(normalize(desc), new ArrayList<Value>())
{
@Override
public void visitEnd()
{
super.visitEnd();
@ -498,6 +513,7 @@ public class AnnotationParser
* @param annotationName
* @param handler
*/
@Deprecated
public void registerAnnotationHandler (String annotationName, DiscoverableAnnotationHandler handler)
{
_handlers.add(handler);
@ -509,6 +525,7 @@ public class AnnotationParser
* @param annotationName
* @return
*/
@Deprecated
public List<DiscoverableAnnotationHandler> getAnnotationHandlers(String annotationName)
{
List<DiscoverableAnnotationHandler> handlers = new ArrayList<DiscoverableAnnotationHandler>();
@ -529,6 +546,7 @@ public class AnnotationParser
* @deprecated
* @return
*/
@Deprecated
public List<DiscoverableAnnotationHandler> getAnnotationHandlers()
{
List<DiscoverableAnnotationHandler> allAnnotationHandlers = new ArrayList<DiscoverableAnnotationHandler>();
@ -544,6 +562,7 @@ public class AnnotationParser
* @deprecated see registerHandler(Handler)
* @param handler
*/
@Deprecated
public void registerClassHandler (ClassHandler handler)
{
_handlers.add(handler);
@ -649,10 +668,10 @@ public class AnnotationParser
* @param visitSuperClasses
* @throws Exception
*/
public void parse (Class clazz, ClassNameResolver resolver, boolean visitSuperClasses)
public void parse (Class<?> clazz, ClassNameResolver resolver, boolean visitSuperClasses)
throws Exception
{
Class cz = clazz;
Class<?> cz = clazz;
while (cz != null)
{
if (!resolver.isExcluded(cz.getName()))
@ -782,6 +801,7 @@ public class AnnotationParser
JarScanner scanner = new JarScanner()
{
@Override
public void processEntry(URI jarUri, JarEntry entry)
{
try
@ -827,6 +847,7 @@ public class AnnotationParser
JarScanner scanner = new JarScanner()
{
@Override
public void processEntry(URI jarUri, JarEntry entry)
{
try

View File

@ -90,30 +90,27 @@ public class ResourceA implements javax.servlet.Servlet
{
System.err.println("ResourceA.x");
}
@Override
public void destroy()
{
// TODO Auto-generated method stub
}
@Override
public ServletConfig getServletConfig()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getServletInfo()
{
// TODO Auto-generated method stub
return null;
}
@Override
public void init(ServletConfig arg0) throws ServletException
{
// TODO Auto-generated method stub
}
@Override
public void service(ServletRequest arg0, ServletResponse arg1)
throws ServletException, IOException
{
// TODO Auto-generated method stub
}
}

View File

@ -55,7 +55,7 @@ class FauxContinuation implements FilteredContinuation
private boolean _resumed=false;
private boolean _timeout=false;
private boolean _responseWrapped=false;
private long _timeoutMs=30000; // TODO configure
private long _timeoutMs=30000;
private ArrayList<ContinuationListener> _listeners;
@ -84,12 +84,14 @@ class FauxContinuation implements FilteredContinuation
/**
* @see org.eclipse.jetty.continuation.Continuation#isResponseWrapped()
*/
@Override
public boolean isResponseWrapped()
{
return _responseWrapped;
}
/* ------------------------------------------------------------ */
@Override
public boolean isInitial()
{
synchronized(this)
@ -99,6 +101,7 @@ class FauxContinuation implements FilteredContinuation
}
/* ------------------------------------------------------------ */
@Override
public boolean isResumed()
{
synchronized(this)
@ -108,6 +111,7 @@ class FauxContinuation implements FilteredContinuation
}
/* ------------------------------------------------------------ */
@Override
public boolean isSuspended()
{
synchronized(this)
@ -129,6 +133,7 @@ class FauxContinuation implements FilteredContinuation
}
/* ------------------------------------------------------------ */
@Override
public boolean isExpired()
{
synchronized(this)
@ -138,12 +143,14 @@ class FauxContinuation implements FilteredContinuation
}
/* ------------------------------------------------------------ */
@Override
public void setTimeout(long timeoutMs)
{
_timeoutMs = timeoutMs;
}
/* ------------------------------------------------------------ */
@Override
public void suspend(ServletResponse response)
{
_response=response;
@ -152,6 +159,7 @@ class FauxContinuation implements FilteredContinuation
}
/* ------------------------------------------------------------ */
@Override
public void suspend()
{
synchronized (this)
@ -185,6 +193,7 @@ class FauxContinuation implements FilteredContinuation
/* (non-Javadoc)
* @see org.mortbay.jetty.Suspendor#resume()
*/
@Override
public void resume()
{
synchronized (this)
@ -223,6 +232,7 @@ class FauxContinuation implements FilteredContinuation
/* ------------------------------------------------------------ */
@Override
public void complete()
{
// just like resume, except don't set _resumed=true;
@ -261,6 +271,7 @@ class FauxContinuation implements FilteredContinuation
/**
* @see org.eclipse.jetty.continuation.Continuation#getServletResponse()
*/
@Override
public boolean enter(ServletResponse response)
{
_response=response;
@ -271,6 +282,7 @@ class FauxContinuation implements FilteredContinuation
/**
* @see org.eclipse.jetty.continuation.Continuation#getServletResponse()
*/
@Override
public ServletResponse getServletResponse()
{
return _response;
@ -297,6 +309,9 @@ class FauxContinuation implements FilteredContinuation
case __SUSPENDED:
fauxResume();
_state=__HANDLING;
return;
case __UNSUSPENDING:
_state=__HANDLING;
return;
@ -312,6 +327,7 @@ class FauxContinuation implements FilteredContinuation
/**
* @return true if handling is complete
*/
@Override
public boolean exit()
{
synchronized (this)
@ -454,6 +470,7 @@ class FauxContinuation implements FilteredContinuation
}
@Override
public void addContinuationListener(ContinuationListener listener)
{
if (_listeners==null)
@ -466,6 +483,7 @@ class FauxContinuation implements FilteredContinuation
/**
* @see org.eclipse.jetty.continuation.Continuation#getAttribute(java.lang.String)
*/
@Override
public Object getAttribute(String name)
{
return _request.getAttribute(name);
@ -475,6 +493,7 @@ class FauxContinuation implements FilteredContinuation
/**
* @see org.eclipse.jetty.continuation.Continuation#removeAttribute(java.lang.String)
*/
@Override
public void removeAttribute(String name)
{
_request.removeAttribute(name);
@ -484,6 +503,7 @@ class FauxContinuation implements FilteredContinuation
/**
* @see org.eclipse.jetty.continuation.Continuation#setAttribute(java.lang.String, java.lang.Object)
*/
@Override
public void setAttribute(String name, Object attribute)
{
_request.setAttribute(name,attribute);
@ -493,6 +513,7 @@ class FauxContinuation implements FilteredContinuation
/**
* @see org.eclipse.jetty.continuation.Continuation#undispatch()
*/
@Override
public void undispatch()
{
if (isSuspended())

View File

@ -134,12 +134,13 @@ public class ScanningAppProviderRuntimeUpdatesTest
jetty.assertWebAppContextsExists("/foo");
jetty.removeWebapp("foo.war");
jetty.removeWebapp("foo.xml");
waitForDirectoryScan();
waitForDirectoryScan();
// FIXME: hot undeploy with removal not working! - jetty.assertNoWebAppContexts();
jetty.assertNoWebAppContexts();
}
/**

View File

@ -46,9 +46,7 @@ import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
// TODO: Make this class inherit from oej.util.Fields
// TODO move this class to jetty-http?
// TODO Make this class inherit from oej.util.Fields
/**
* HTTP Fields. A collection of HTTP header and or Trailer fields.

View File

@ -36,15 +36,14 @@ import static org.junit.Assert.assertTrue;
*/
public class HttpParserTest
{
/* ------------------------------------------------------------------------------- */
/**
* Parse until {@link #END END} state.
* If the parser is already in the END state, then it is {@link #reset reset} and re-parsed.
* @param parser TODO
* @param parser The parser to test
* @throws IllegalStateException If the buffers have already been partially parsed.
*/
public static void parseAll(HttpParser parser, ByteBuffer buffer) throws EofException
public static void parseAll(HttpParser parser, ByteBuffer buffer)
{
if (parser.isState(State.END))
parser.reset();

View File

@ -257,27 +257,25 @@ public abstract class AbstractConnection implements Connection
@Override
public int getMessagesIn()
{
return 0;
return -1;
}
@Override
public int getMessagesOut()
{
return 0;
return -1;
}
@Override
public long getBytesIn()
{
// TODO Auto-generated method stub
return 0;
return -1;
}
@Override
public long getBytesOut()
{
// TODO Auto-generated method stub
return 0;
return -1;
}
@Override

View File

@ -309,8 +309,6 @@ public class SslConnection extends AbstractConnection
}
getWriteFlusher().onFail(x);
// TODO release all buffers??? or may in onClose
}
}
};
@ -596,7 +594,6 @@ public class SslConnection extends AbstractConnection
}
catch (SSLException e)
{
LOG.warn(getEndPoint().toString(),e);
getEndPoint().close();
throw new EofException(e);
}

View File

@ -24,6 +24,7 @@ import java.lang.reflect.Modifier;
import org.eclipse.jetty.util.IntrospectionUtil;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.TypeUtil;
@ -106,7 +107,7 @@ public abstract class LifeCycleCallback
{
if (_targetClass == null)
_targetClass = Loader.loadClass(null, _className);
_target = _targetClass.getDeclaredMethod(_methodName, new Class[]{}); //TODO
_target = _targetClass.getDeclaredMethod(_methodName, TypeUtil.NO_ARGS);
}
if (_target != null)

View File

@ -49,7 +49,7 @@ public abstract class Rule
* @param response
*
* @return The new target if the rule has matched, else null
* @throws IOException TODO
* @throws IOException
*/
public abstract String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException;

View File

@ -60,6 +60,7 @@ public class SpnegoLoginService extends AbstractLifeCycle implements LoginServic
setConfig(config);
}
@Override
public String getName()
{
return _name;
@ -109,6 +110,7 @@ public class SpnegoLoginService extends AbstractLifeCycle implements LoginServic
/**
* username will be null since the credentials will contain all the relevant info
*/
@Override
public UserIdentity login(String username, Object credentials)
{
String encodedAuthToken = (String)credentials;
@ -161,24 +163,28 @@ public class SpnegoLoginService extends AbstractLifeCycle implements LoginServic
return null;
}
@Override
public boolean validate(UserIdentity user)
{
return false;
}
@Override
public IdentityService getIdentityService()
{
return _identityService;
}
@Override
public void setIdentityService(IdentityService service)
{
_identityService = service;
}
public void logout(UserIdentity user) {
// TODO Auto-generated method stub
}
@Override
public void logout(UserIdentity user)
{
// TODO Auto-generated method stub
}
}

View File

@ -112,7 +112,7 @@
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="stopTimeout">1000</Set>
<Set name="stopTimeout">5000</Set>
<Set name="dumpAfterStart">false</Set>
<Set name="dumpBeforeStop">false</Set>

View File

@ -198,7 +198,6 @@ public class CookieCutter
continue;
case ';':
// TODO case ',':
if (tokenstart>=0)
value = hdr.substring(tokenstart, tokenend+1);
else
@ -244,7 +243,6 @@ public class CookieCutter
continue;
case ';':
// TODO case ',':
if (tokenstart>=0)
{
name = hdr.substring(tokenstart, tokenend+1);
@ -278,7 +276,6 @@ public class CookieCutter
// If after processing the current character we have a value and a name, then it is a cookie
if (value!=null && name!=null)
{
// TODO handle unquoting during parsing! But quoting is uncommon
name=QuotedStringTokenizer.unquote(name);
value=QuotedStringTokenizer.unquote(value);

View File

@ -119,15 +119,11 @@ public class Dispatcher implements RequestDispatcher
{
Request baseRequest=(request instanceof Request)?((Request)request):HttpChannel.getCurrentHttpChannel().getRequest();
if (!(request instanceof HttpServletRequest))
request = new ServletRequestHttpWrapper(request);
if (!(response instanceof HttpServletResponse))
response = new ServletResponseHttpWrapper(response);
// TODO - allow stream or writer????
final DispatcherType old_type = baseRequest.getDispatcherType();
final Attributes old_attr=baseRequest.getAttributes();
MultiMap<String> old_params=baseRequest.getParameters();
@ -330,6 +326,7 @@ public class Dispatcher implements RequestDispatcher
}
/* ------------------------------------------------------------ */
@Override
public Object getAttribute(String key)
{
if (Dispatcher.this._named==null)
@ -353,13 +350,14 @@ public class Dispatcher implements RequestDispatcher
}
/* ------------------------------------------------------------ */
public Enumeration getAttributeNames()
@Override
public Enumeration<String> getAttributeNames()
{
HashSet set=new HashSet();
Enumeration e=_attr.getAttributeNames();
HashSet<String> set=new HashSet<>();
Enumeration<String> e=_attr.getAttributeNames();
while(e.hasMoreElements())
{
String name=(String)e.nextElement();
String name=e.nextElement();
if (!name.startsWith(__INCLUDE_PREFIX) &&
!name.startsWith(__FORWARD_PREFIX))
set.add(name);
@ -384,6 +382,7 @@ public class Dispatcher implements RequestDispatcher
}
/* ------------------------------------------------------------ */
@Override
public void setAttribute(String key, Object value)
{
if (_named==null && key.startsWith("javax.servlet."))
@ -418,12 +417,14 @@ public class Dispatcher implements RequestDispatcher
}
/* ------------------------------------------------------------ */
@Override
public void clearAttributes()
{
throw new IllegalStateException();
}
/* ------------------------------------------------------------ */
@Override
public void removeAttribute(String name)
{
setAttribute(name,null);
@ -449,6 +450,7 @@ public class Dispatcher implements RequestDispatcher
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
@Override
public Object getAttribute(String key)
{
if (Dispatcher.this._named==null)
@ -467,13 +469,14 @@ public class Dispatcher implements RequestDispatcher
}
/* ------------------------------------------------------------ */
public Enumeration getAttributeNames()
@Override
public Enumeration<String> getAttributeNames()
{
HashSet set=new HashSet();
Enumeration e=_attr.getAttributeNames();
HashSet<String> set=new HashSet<>();
Enumeration<String> e=_attr.getAttributeNames();
while(e.hasMoreElements())
{
String name=(String)e.nextElement();
String name=e.nextElement();
if (!name.startsWith(__INCLUDE_PREFIX))
set.add(name);
}
@ -497,6 +500,7 @@ public class Dispatcher implements RequestDispatcher
}
/* ------------------------------------------------------------ */
@Override
public void setAttribute(String key, Object value)
{
if (_named==null && key.startsWith("javax.servlet."))
@ -525,12 +529,14 @@ public class Dispatcher implements RequestDispatcher
}
/* ------------------------------------------------------------ */
@Override
public void clearAttributes()
{
throw new IllegalStateException();
}
/* ------------------------------------------------------------ */
@Override
public void removeAttribute(String name)
{
setAttribute(name,null);

View File

@ -398,7 +398,6 @@ public class HttpChannelState implements AsyncContext, Continuation
{
synchronized (this)
{
// TODO should we change state here?
if (_event!=null)
_event._cause=th;
}
@ -554,7 +553,6 @@ public class HttpChannelState implements AsyncContext, Continuation
if (_continuation)
dispatch();
else
// TODO maybe error dispatch?
complete();
}
}

View File

@ -21,12 +21,13 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.channels.IllegalSelectorException;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
@ -790,19 +791,6 @@ public class Response implements HttpServletResponse
}
}
}
/* TODO merged code not used???
else if (_mimeType!=null)
_contentType=_mimeType;
if (_contentType==null)
_connection.getResponseFields().remove(HttpHeaders.CONTENT_TYPE_BUFFER);
else
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
*/
}
@Override

View File

@ -44,14 +44,11 @@ import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.AttributesMap;
import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.component.Graceful;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
@ -570,21 +567,6 @@ public class Server extends HandlerWrapper implements Attributes
_attributes.setAttribute(name, attribute);
}
/* ------------------------------------------------------------ */
/**
* Set graceful shutdown timeout. If set, the internal <code>doStop()</code> method will not immediately stop the
* server. Instead, all {@link Connector}s will be closed so that new connections will not be accepted
* and all handlers that implement {@link Graceful} will be put into the shutdown mode so that no new requests
* will be accepted, but existing requests can complete. The server will then wait the configured timeout
* before stopping.
* @param timeoutMS the milliseconds to wait for existing request to complete before stopping the server.
*
*/
public void setGracefulShutdown(int timeoutMS)
{
// TODO
}
/* ------------------------------------------------------------ */
@Override
public String toString()

View File

@ -20,13 +20,10 @@
package org.eclipse.jetty.server;
import java.nio.channels.SocketChannel;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ChannelEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ssl.SslConnection;

View File

@ -19,14 +19,12 @@
package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HandlerContainer;
import org.eclipse.jetty.util.TypeUtil;
/* ------------------------------------------------------------ */

View File

@ -33,9 +33,11 @@ import java.util.EventListener;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
import javax.servlet.DispatcherType;
@ -67,11 +69,9 @@ import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HandlerContainer;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.ArrayUtil;
import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.AttributesMap;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil;
@ -127,9 +127,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
private final AttributesMap _attributes;
private final AttributesMap _contextAttributes;
private final Map<String, String> _initParams;
private ClassLoader _classLoader;
private String _contextPath = "/";
@ -138,30 +136,23 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
private Resource _baseResource;
private MimeTypes _mimeTypes;
private Map<String, String> _localeEncodingMap;
private String[] _welcomeFiles;
private ErrorHandler _errorHandler;
private String[] _vhosts;
private EventListener[] _eventListeners;
private Logger _logger;
private boolean _allowNullPathInfo;
private int _maxFormKeys = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormKeys",1000).intValue();
private int _maxFormContentSize = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormContentSize",200000).intValue();
private boolean _compactPath = false;
private boolean _aliases = false;
private Object _contextListeners;
private Object _contextAttributeListeners;
private Object _requestListeners;
private Object _requestAttributeListeners;
private final List<EventListener> _eventListeners=new CopyOnWriteArrayList<>();
private final List<EventListener> _programmaticListeners=new CopyOnWriteArrayList<>();
private final List<ServletContextListener> _contextListeners=new CopyOnWriteArrayList<>();
private final List<ServletContextAttributeListener> _contextAttributeListeners=new CopyOnWriteArrayList<>();
private final List<ServletRequestListener> _requestListeners=new CopyOnWriteArrayList<>();
private final List<ServletRequestAttributeListener> _requestAttributeListeners=new CopyOnWriteArrayList<>();
private Map<String, Object> _managedAttributes;
private String[] _protectedTargets;
@ -396,9 +387,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
/*
* @see javax.servlet.ServletContext#getAttributeNames()
*/
@SuppressWarnings("unchecked")
@Override
public Enumeration getAttributeNames()
public Enumeration<String> getAttributeNames()
{
return AttributesMap.getAttributeNamesCopy(_attributes);
}
@ -518,7 +508,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
/* ------------------------------------------------------------ */
public EventListener[] getEventListeners()
{
return _eventListeners;
return _eventListeners.toArray(new EventListener[_eventListeners.size()]);
}
/* ------------------------------------------------------------ */
@ -534,29 +524,14 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
*/
public void setEventListeners(EventListener[] eventListeners)
{
_contextListeners = null;
_contextAttributeListeners = null;
_requestListeners = null;
_requestAttributeListeners = null;
_contextListeners.clear();
_contextAttributeListeners.clear();
_requestListeners.clear();
_requestAttributeListeners.clear();
_eventListeners = eventListeners;
for (int i = 0; eventListeners != null && i < eventListeners.length; i++)
{
EventListener listener = _eventListeners[i];
if (listener instanceof ServletContextListener)
_contextListeners = LazyList.add(_contextListeners,listener);
if (listener instanceof ServletContextAttributeListener)
_contextAttributeListeners = LazyList.add(_contextAttributeListeners,listener);
if (listener instanceof ServletRequestListener)
_requestListeners = LazyList.add(_requestListeners,listener);
if (listener instanceof ServletRequestAttributeListener)
_requestAttributeListeners = LazyList.add(_requestAttributeListeners,listener);
}
if (eventListeners!=null)
for (EventListener listener : _eventListeners)
addEventListener(listener);
}
/* ------------------------------------------------------------ */
@ -570,22 +545,64 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
*/
public void addEventListener(EventListener listener)
{
setEventListeners((EventListener[])ArrayUtil.addToArray(getEventListeners(),listener,EventListener.class));
_eventListeners.add(listener);
if (listener instanceof ServletContextListener)
_contextListeners.add((ServletContextListener)listener);
if (listener instanceof ServletContextAttributeListener)
_contextAttributeListeners.add((ServletContextAttributeListener)listener);
if (listener instanceof ServletRequestListener)
_requestListeners.add((ServletRequestListener)listener);
if (listener instanceof ServletRequestAttributeListener)
_requestAttributeListeners.add((ServletRequestAttributeListener)listener);
}
/* ------------------------------------------------------------ */
/**
* Remove a context event listeners.
*
* @see ServletContextListener
* @see ServletContextAttributeListener
* @see ServletRequestListener
* @see ServletRequestAttributeListener
*/
public void removeEventListener(EventListener listener)
{
_eventListeners.remove(listener);
if (listener instanceof ServletContextListener)
_contextListeners.remove(listener);
if (listener instanceof ServletContextAttributeListener)
_contextAttributeListeners.remove(listener);
if (listener instanceof ServletRequestListener)
_requestListeners.remove(listener);
if (listener instanceof ServletRequestAttributeListener)
_requestAttributeListeners.remove(listener);
}
/* ------------------------------------------------------------ */
/**
* Apply any necessary restrictions on a programmatically added
* listener.
*
* Superclasses should implement.
* Apply any necessary restrictions on a programmatic added listener.
*
* @param listener
*/
public void restrictEventListener (EventListener listener)
protected void addProgrammaticListener (EventListener listener)
{
_programmaticListeners.add(listener);
}
/* ------------------------------------------------------------ */
protected boolean isProgrammaticListener(EventListener listener)
{
return _programmaticListeners.contains(listener);
}
/* ------------------------------------------------------------ */
/**
* @return true if this context is accepting new requests
@ -696,11 +713,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
__context.set(old_context);
// reset the classloader
if (_classLoader != null)
{
if (_classLoader != null && current_thread!=null)
current_thread.setContextClassLoader(old_classloader);
}
}
}
@ -721,10 +735,10 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
for (String attribute : attributes)
_managedAttributes.put(attribute,null);
Enumeration e = _scontext.getAttributeNames();
Enumeration<String> e = _scontext.getAttributeNames();
while (e.hasMoreElements())
{
String name = (String)e.nextElement();
String name = e.nextElement();
Object value = _scontext.getAttribute(name);
checkManagedAttribute(name,value);
}
@ -733,24 +747,22 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
super.doStart();
// Context listeners
if (_contextListeners != null)
if (!_contextListeners.isEmpty())
{
ServletContextEvent event = new ServletContextEvent(_scontext);
for (int i = 0; i < LazyList.size(_contextListeners); i++)
{
callContextInitialized(((ServletContextListener)LazyList.get(_contextListeners, i)), event);
}
for (ServletContextListener listener:_contextListeners)
callContextInitialized(listener, event);
}
}
/* ------------------------------------------------------------ */
public void callContextInitialized (ServletContextListener l, ServletContextEvent e)
protected void callContextInitialized (ServletContextListener l, ServletContextEvent e)
{
l.contextInitialized(e);
}
/* ------------------------------------------------------------ */
public void callContextDestroyed (ServletContextListener l, ServletContextEvent e)
protected void callContextDestroyed (ServletContextListener l, ServletContextEvent e)
{
l.contextDestroyed(e);
}
@ -782,31 +794,33 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
super.doStop();
// Context listeners
if (_contextListeners != null)
if (!_contextListeners.isEmpty())
{
ServletContextEvent event = new ServletContextEvent(_scontext);
for (int i = LazyList.size(_contextListeners); i-- > 0;)
{
((ServletContextListener)LazyList.get(_contextListeners,i)).contextDestroyed(event);
}
for (ServletContextListener listener : _contextListeners)
callContextDestroyed(listener,event);
}
if (_errorHandler != null)
_errorHandler.stop();
Enumeration e = _scontext.getAttributeNames();
Enumeration<String> e = _scontext.getAttributeNames();
while (e.hasMoreElements())
{
String name = (String)e.nextElement();
String name = e.nextElement();
checkManagedAttribute(name,null);
}
for (EventListener l : _programmaticListeners)
removeEventListener(l);
_programmaticListeners.clear();
}
finally
{
LOG.info("stopped {}",this);
__context.set(old_context);
// reset the classloader
if (_classLoader != null)
if (_classLoader != null && current_thread!=null)
current_thread.setContextClassLoader(old_classloader);
}
@ -817,7 +831,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
/*
* @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException, ServletException
public boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException
{
DispatcherType dispatch = baseRequest.getDispatcherType();
@ -840,7 +854,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
boolean match = false;
// TODO non-linear lookup
for (int i = 0; !match && i < _vhosts.length; i++)
{
String contextVhost = _vhosts[i];
@ -982,7 +995,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
if (old_context != _scontext)
{
// reset the classloader
if (_classLoader != null)
if (_classLoader != null && current_thread!=null)
{
current_thread.setContextClassLoader(old_classloader);
}
@ -1012,20 +1025,15 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
if (new_context)
{
// Handle the REALLY SILLY request events!
if (_requestAttributeListeners != null)
{
// TODO COW lists ???
final int s = LazyList.size(_requestAttributeListeners);
for (int i = 0; i < s; i++)
baseRequest.addEventListener(((EventListener)LazyList.get(_requestAttributeListeners,i)));
}
if (!_requestAttributeListeners.isEmpty())
for (ServletRequestAttributeListener l :_requestAttributeListeners)
baseRequest.addEventListener(l);
if (_requestListeners != null)
if (!_requestListeners.isEmpty())
{
final int s = LazyList.size(_requestListeners);
final ServletRequestEvent sre = new ServletRequestEvent(_scontext,request);
for (int i = 0; i < s; i++)
((ServletRequestListener)LazyList.get(_requestListeners,i)).requestInitialized(sre);
for (ServletRequestListener l : _requestListeners)
l.requestInitialized(sre);
}
}
@ -1051,17 +1059,23 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
// Handle more REALLY SILLY request events!
if (new_context)
{
if (_requestListeners != null)
if (!_requestListeners.isEmpty())
{
final ServletRequestEvent sre = new ServletRequestEvent(_scontext,request);
for (int i = LazyList.size(_requestListeners); i-- > 0;)
((ServletRequestListener)LazyList.get(_requestListeners,i)).requestDestroyed(sre);
ListIterator<ServletRequestListener> iter = _requestListeners.listIterator(_requestListeners.size());
while (iter.hasNext())
iter.next();
while (iter.hasPrevious())
iter.previous().requestDestroyed(sre);
}
if (_requestAttributeListeners != null)
if (!_requestAttributeListeners.isEmpty())
{
for (int i = LazyList.size(_requestAttributeListeners); i-- > 0;)
baseRequest.removeEventListener(((EventListener)LazyList.get(_requestAttributeListeners,i)));
ListIterator<ServletRequestAttributeListener> iter = _requestAttributeListeners.listIterator(_requestAttributeListeners.size());
while(iter.hasNext())
iter.next();
while(iter.hasPrevious())
baseRequest.removeEventListener(iter.previous());
}
}
}
@ -1094,7 +1108,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
finally
{
__context.set(old_context);
if (old_classloader != null)
if (old_classloader != null && current_thread!=null)
{
current_thread.setContextClassLoader(old_classloader);
}
@ -1182,10 +1196,10 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
{
_attributes.clearAttributes();
_attributes.addAll(attributes);
Enumeration e = _attributes.getAttributeNames();
Enumeration<String> e = _attributes.getAttributeNames();
while (e.hasMoreElements())
{
String name = (String)e.nextElement();
String name = e.nextElement();
checkManagedAttribute(name,attributes.getAttribute(name));
}
}
@ -1194,10 +1208,10 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
@Override
public void clearAttributes()
{
Enumeration e = _attributes.getAttributeNames();
Enumeration<String> e = _attributes.getAttributeNames();
while (e.hasMoreElements())
{
String name = (String)e.nextElement();
String name = e.nextElement();
checkManagedAttribute(name,null);
}
_attributes.clearAttributes();
@ -1651,7 +1665,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
/* ------------------------------------------------------------ */
public ContextHandler getContextHandler()
{
// TODO reduce visibility of this method
return ContextHandler.this;
}
@ -1890,7 +1903,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
* @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
*/
@Override
public Set getResourcePaths(String path)
public Set<String> getResourcePaths(String path)
{
return ContextHandler.this.getResourcePaths(path);
}
@ -1923,7 +1936,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
@SuppressWarnings("unchecked")
@Override
@Deprecated
public Enumeration getServletNames()
public Enumeration<String> getServletNames()
{
return Collections.enumeration(Collections.EMPTY_LIST);
}
@ -1935,7 +1948,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
@SuppressWarnings("unchecked")
@Override
@Deprecated
public Enumeration getServlets()
public Enumeration<Servlet> getServlets()
{
return Collections.enumeration(Collections.EMPTY_LIST);
}
@ -1986,7 +1999,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
*/
@SuppressWarnings("unchecked")
@Override
public Enumeration getInitParameterNames()
public Enumeration<String> getInitParameterNames()
{
return ContextHandler.this.getInitParameterNames();
}
@ -2008,9 +2021,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
/*
* @see javax.servlet.ServletContext#getAttributeNames()
*/
@SuppressWarnings("unchecked")
@Override
public synchronized Enumeration getAttributeNames()
public synchronized Enumeration<String> getAttributeNames()
{
HashSet<String> set = new HashSet<String>();
if (_contextAttributes != null)
@ -2041,14 +2053,12 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
else
_contextAttributes.setAttribute(name,value);
if (_contextAttributeListeners != null)
if (!_contextAttributeListeners.isEmpty())
{
ServletContextAttributeEvent event = new ServletContextAttributeEvent(_scontext,name,old_value == null?value:old_value);
for (int i = 0; i < LazyList.size(_contextAttributeListeners); i++)
for (ServletContextAttributeListener l : _contextAttributeListeners)
{
ServletContextAttributeListener l = (ServletContextAttributeListener)LazyList.get(_contextAttributeListeners,i);
if (old_value == null)
l.attributeAdded(event);
else if (value == null)
@ -2077,15 +2087,12 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
Object old_value = _contextAttributes.getAttribute(name);
_contextAttributes.removeAttribute(name);
if (old_value != null)
if (old_value != null &&!_contextAttributeListeners.isEmpty())
{
if (_contextAttributeListeners != null)
{
ServletContextAttributeEvent event = new ServletContextAttributeEvent(_scontext,name,old_value);
ServletContextAttributeEvent event = new ServletContextAttributeEvent(_scontext,name,old_value);
for (int i = 0; i < LazyList.size(_contextAttributeListeners); i++)
((ServletContextAttributeListener)LazyList.get(_contextAttributeListeners,i)).attributeRemoved(event);
}
for (ServletContextAttributeListener l : _contextAttributeListeners)
l.attributeRemoved(event);
}
}
@ -2278,7 +2285,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
{
EventListener e = createListener(listenerClass);
ContextHandler.this.addEventListener(e);
ContextHandler.this.restrictEventListener(e);
ContextHandler.this.addProgrammaticListener(e);
}
catch (ServletException e)
{
@ -2351,9 +2358,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
throw new IllegalStateException ();
if (!_enabled)
throw new UnsupportedOperationException();
// TODO Auto-generated method stub
}
public void setEnabled(boolean enabled)

View File

@ -46,7 +46,6 @@ import org.eclipse.jetty.util.resource.Resource;
* For requests for favicon.ico, the Jetty icon is served.
* For reqests to '/' a 404 with a list of known contexts is served.
* For all other requests a normal 404 is served.
* TODO Implement OPTIONS and TRACE methods for the server.
*
*
* @org.apache.xbean.XBean

View File

@ -62,7 +62,7 @@ public class ErrorHandler extends AbstractHandler
if (_cacheControl!=null)
response.setHeader(HttpHeader.CACHE_CONTROL.asString(), _cacheControl);
ByteArrayISO8859Writer writer= new ByteArrayISO8859Writer(4096);
String reason=(response instanceof Response)?((Response)response).getReason():null; // TODO
String reason=(response instanceof Response)?((Response)response).getReason():null;
handleErrorPage(request, writer, response.getStatus(), reason);
writer.flush();
response.setContentLength(writer.size());

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

View File

@ -29,7 +29,6 @@ import org.eclipse.jetty.server.HttpChannelState;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.RequestLog;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;

View File

@ -27,15 +27,14 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.NetworkTrafficListener;
import org.eclipse.jetty.io.NetworkTrafficSelectChannelEndPoint;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.session;
import java.io.IOException;
import java.util.EnumSet;
import java.util.EventListener;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.SessionTrackingMode;
@ -31,7 +32,6 @@ import javax.servlet.http.HttpSession;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.SessionManager;
import org.eclipse.jetty.server.handler.ScopedHandler;
import org.eclipse.jetty.util.log.Log;
@ -318,6 +318,16 @@ public class SessionHandler extends ScopedHandler
if (_sessionManager != null)
_sessionManager.addEventListener(listener);
}
/* ------------------------------------------------------------ */
/**
* @param listener
*/
public void removeEventListener(EventListener listener)
{
if (_sessionManager != null)
_sessionManager.removeEventListener(listener);
}
/* ------------------------------------------------------------ */
public void clearEventListeners()

View File

@ -20,8 +20,8 @@ package org.eclipse.jetty.server.ssl;
import org.eclipse.jetty.server.AbstractConnectionFactory;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
/* ------------------------------------------------------------ */

View File

@ -45,7 +45,6 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -27,6 +27,7 @@ import java.net.Socket;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -18,6 +18,11 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.matchers.JUnitMatchers.containsString;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -25,6 +30,7 @@ import java.net.Socket;
import java.net.SocketException;
import java.util.concurrent.Exchanger;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -37,11 +43,6 @@ import org.eclipse.jetty.util.IO;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.matchers.JUnitMatchers.containsString;
public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
{
protected static final int MAX_IDLE_TIME=500;

View File

@ -409,7 +409,7 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
assertThat("response code is 200", response.getCode(), is("200"));
assertThat("no exceptions", handler.failure(), is(nullValue()));
if (!"HTTP/1.0".equals(httpVersion))
assertHeader(response, "transfer-encoding", "chunked"); // TODO HTTP/1.0 does not do chunked
assertHeader(response, "transfer-encoding", "chunked");
}
private class WriteFlushWriteMoreHandler extends ThrowExceptionOnDemandHandler

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
@ -37,6 +38,7 @@ import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.Exchanger;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
@ -54,9 +56,6 @@ import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertTrue;
/**
*
*/
@ -186,7 +185,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
throw new ServletException("handler exception");
throw new ServletException("TEST handler exception");
}
});
@ -196,11 +195,20 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
Socket client = newSocket(HOST, _connector.getLocalPort());
OutputStream os = client.getOutputStream();
os.write(request.toString().getBytes());
os.flush();
try
{
((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true);
Log.getLogger(HttpChannel.class).info("Expecting ServletException: TEST handler exception...");
os.write(request.toString().getBytes());
os.flush();
String response = readResponse(client);
assertThat("response code is 500", response.contains("500"), is(true));
String response = readResponse(client);
assertThat("response code is 500", response.contains("500"), is(true));
}
finally
{
((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false);
}
}
@Test

View File

@ -18,13 +18,16 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.util.MultiMap;
@ -33,11 +36,6 @@ import org.eclipse.jetty.util.TypeUtil;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class HttpURITest
{
private final String[][] partial_tests=

View File

@ -18,6 +18,10 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -26,10 +30,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class LocalConnectorTest
{
private Server _server;

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -25,6 +28,7 @@ import java.io.PrintWriter;
import java.net.Socket;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -40,9 +44,6 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@Ignore("Ignored while refactoring the connection events and statistics")
public class SelectChannelStatisticsTest
{

View File

@ -42,8 +42,8 @@ import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

View File

@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import javax.net.ssl.SSLContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

View File

@ -51,8 +51,8 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.IO;

View File

@ -41,8 +41,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.AfterClass;

View File

@ -18,12 +18,15 @@
package org.eclipse.jetty.server.ssl;
import static org.junit.Assert.assertEquals;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketException;
import java.security.KeyStore;
import java.util.Arrays;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
@ -36,8 +39,6 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
/**
* HttpServer Tester.

View File

@ -39,6 +39,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket;

View File

@ -36,8 +36,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.IO;

View File

@ -235,14 +235,6 @@ public class ErrorPageErrorHandler extends ErrorHandler
_servletContext=ContextHandler.getCurrentContext();
}
/* ------------------------------------------------------------ */
@Override
protected void doStop() throws Exception
{
// TODO Auto-generated method stub
super.doStop();
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
private class ErrorCodeRange

View File

@ -89,8 +89,6 @@ public class ServletContextHandler extends ContextHandler
protected ServletHandler _servletHandler;
protected int _options;
protected JspConfigDescriptor _jspConfig;
protected List<ServletContextListener> _restrictedContextListeners = new ArrayList<>();
private boolean _restrictListeners = true;
/* ------------------------------------------------------------ */
public ServletContextHandler()
@ -413,30 +411,13 @@ public class ServletContextHandler extends ContextHandler
return Collections.emptySet();
}
@Override
public void restrictEventListener (EventListener e)
{
if (_restrictListeners && e instanceof ServletContextListener)
{
_restrictedContextListeners.add((ServletContextListener)e);
}
}
public boolean isRestrictListeners() {
return _restrictListeners;
}
public void setRestrictListeners(boolean restrictListeners) {
this._restrictListeners = restrictListeners;
}
@Override
public void callContextInitialized(ServletContextListener l, ServletContextEvent e)
{
try
{
//toggle state of the dynamic API so that the listener cannot use it
if(_restrictedContextListeners.contains(l))
if(isProgrammaticListener(l))
this.getServletContext().setEnabled(false);
super.callContextInitialized(l, e);
@ -1066,7 +1047,6 @@ public class ServletContextHandler extends ContextHandler
@Override
public boolean setInitParameter(String name, String value)
{
// TODO other started conditions
if (!isStarting())
throw new IllegalStateException();
@ -1197,7 +1177,6 @@ public class ServletContextHandler extends ContextHandler
@Override
public SessionCookieConfig getSessionCookieConfig()
{
// TODO other started conditions
if (!_enabled)
throw new UnsupportedOperationException();
@ -1209,7 +1188,6 @@ public class ServletContextHandler extends ContextHandler
@Override
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
{
// TODO other started conditions
if (!isStarting())
throw new IllegalStateException();
if (!_enabled)
@ -1223,7 +1201,6 @@ public class ServletContextHandler extends ContextHandler
@Override
public void addListener(String className)
{
// TODO other started conditions
if (!isStarting())
throw new IllegalStateException();
if (!_enabled)
@ -1234,7 +1211,6 @@ public class ServletContextHandler extends ContextHandler
@Override
public <T extends EventListener> void addListener(T t)
{
// TODO other started conditions
if (!isStarting())
throw new IllegalStateException();
if (!_enabled)
@ -1245,7 +1221,6 @@ public class ServletContextHandler extends ContextHandler
@Override
public void addListener(Class<? extends EventListener> listenerClass)
{
// TODO other started conditions
if (!isStarting())
throw new IllegalStateException();
if (!_enabled)

View File

@ -36,7 +36,7 @@
<property name="stopAtShutdown" value="true"/>
<property name="sendServerVersion" value="true"/>
<property name="sendDateHeader" value="true"/>
<property name="gracefulShutdown" value="1000"/>
<property name="stopTimeout" value="1000"/>
<property name="dumpAfterStart" value="true"/>
<property name="dumpBeforeStop" value="false"/>

View File

@ -856,22 +856,11 @@ public class Main
{
return JarVersion.getVersion(element);
}
if (name.endsWith(".zip"))
{
return getZipVersion(element);
}
}
return "";
}
private String getZipVersion(File element)
{
// TODO - find version in zip file. Look for META-INF/MANIFEST.MF ?
return "";
}
private List<String> resolveXmlConfigs(List<String> xmls) throws FileNotFoundException
{
List<String> ret = new ArrayList<String>();

View File

@ -466,8 +466,6 @@ public class BufferUtil
boolean started = false;
boolean minus = false;
// TODO add version that operates on array
for (int i = buffer.position(); i < buffer.limit(); i++)
{
byte b = buffer.get(i);
@ -506,7 +504,6 @@ public class BufferUtil
long val = 0;
boolean started = false;
boolean minus = false;
// TODO add version that operates on array
for (int i = buffer.position(); i < buffer.limit(); i++)
{

View File

@ -34,6 +34,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletException;
import javax.servlet.http.Part;

View File

@ -47,6 +47,7 @@ import org.eclipse.jetty.util.log.Logger;
public class TypeUtil
{
private static final Logger LOG = Log.getLogger(TypeUtil.class);
public static final Class<?>[] NO_ARGS = new Class[]{};
public static int CR = '\015';
public static int LF = '\012';

View File

@ -31,7 +31,6 @@ import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.OpenOption;
import java.nio.file.StandardOpenOption;
import java.security.Permission;

View File

@ -323,6 +323,6 @@ public class URLResource extends Resource
@Override
public boolean isContainedIn (Resource containingResource) throws MalformedURLException
{
return false; //TODO check this!
return false;
}
}

View File

@ -22,6 +22,7 @@ import java.net.Socket;
import java.security.Principal;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.X509ExtendedKeyManager;
import javax.net.ssl.X509KeyManager;

View File

@ -22,6 +22,7 @@ import java.net.Socket;
import java.security.Principal;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509KeyManager;

View File

@ -41,6 +41,7 @@ import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.net.ssl.CertPathTrustManagerParameters;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;

View File

@ -18,12 +18,12 @@
package org.eclipse.jetty.util;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ArrayQueueTest
{

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -29,9 +32,6 @@ import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@RunWith(AdvancedRunner.class)
public class BlockingArrayQueueTest
{
@ -256,7 +256,6 @@ public class BlockingArrayQueueTest
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@ -298,7 +297,6 @@ public class BlockingArrayQueueTest
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

View File

@ -19,15 +19,15 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class BufferUtilTest
{
@Test

View File

@ -18,12 +18,12 @@
package org.eclipse.jetty.util;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;
public class IPAddressMapTest
{

View File

@ -18,6 +18,12 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
@ -30,12 +36,6 @@ import java.util.ListIterator;
import org.junit.Assume;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* Tests for LazyList utility class.
*/

View File

@ -18,13 +18,13 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class MultiExceptionTest
{

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.util;
import static org.hamcrest.Matchers.nullValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -26,8 +28,6 @@ import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.Matchers.nullValue;
public class MultiMapTest
{
/**

View File

@ -18,20 +18,6 @@
package org.eclipse.jetty.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletException;
import javax.servlet.http.Part;
import org.eclipse.jetty.util.MultiPartInputStream.MultiPart;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
@ -44,6 +30,20 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletException;
import javax.servlet.http.Part;
import org.eclipse.jetty.util.MultiPartInputStream.MultiPart;
import org.junit.Test;
/**
* MultiPartInputStreamTest
*

View File

@ -18,12 +18,12 @@
package org.eclipse.jetty.util;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
*

View File

@ -18,15 +18,15 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
*

View File

@ -18,13 +18,13 @@
package org.eclipse.jetty.util;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Test;
public class StringUtilTest
{
@Test

View File

@ -18,15 +18,15 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* TestInjection

View File

@ -18,10 +18,10 @@
package org.eclipse.jetty.util;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/* ------------------------------------------------------------ */
/** Util meta Tests.

View File

@ -18,14 +18,14 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/* ------------------------------------------------------------ */
/** Util meta Tests.

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.util;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@ -25,9 +28,6 @@ import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
public class Utf8LineParserTest
{
private void appendUtf8(ByteBuffer buf, String line)

View File

@ -18,13 +18,13 @@
package org.eclipse.jetty.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.UnsupportedEncodingException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class Utf8StringBufferTest
{
@Test

View File

@ -18,12 +18,12 @@
package org.eclipse.jetty.util;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Test;
public class Utf8StringBuilderTest
{
@Test

View File

@ -24,7 +24,6 @@ import java.io.StringReader;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.TypeUtil;
import org.junit.Assert;

View File

@ -18,14 +18,14 @@
package org.eclipse.jetty.util.component;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StdErrLog;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StdErrLog;
import org.junit.Test;
public class LifeCycleListenerTest
{

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.util.log;
import static org.hamcrest.Matchers.containsString;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.Handler;
@ -26,8 +28,6 @@ import java.util.logging.LogRecord;
import org.eclipse.jetty.util.IO;
import org.junit.Assert;
import static org.hamcrest.Matchers.containsString;
public class CapturingJULHandler extends Handler
{
private static final String LN = System.getProperty("line.separator");

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.util.log;
import static org.hamcrest.Matchers.is;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.Handler;
@ -29,8 +31,6 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
public class JavaUtilLogTest
{
private static Handler[] originalHandlers;

View File

@ -18,14 +18,14 @@
package org.eclipse.jetty.util.log;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.junit.Assert;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
public class StdErrCapture
{
private ByteArrayOutputStream test;

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.util.log;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
@ -29,9 +32,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
/**
* Tests for StdErrLog
*/

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.util.resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
@ -25,9 +28,6 @@ import java.io.InputStreamReader;
import org.eclipse.jetty.util.IO;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ResourceCollectionTest
{

View File

@ -18,6 +18,11 @@
package org.eclipse.jetty.util.resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.io.FilePermission;
import java.io.FilenameFilter;
@ -35,11 +40,6 @@ import org.eclipse.jetty.util.IO;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
public class ResourceTest
{

View File

@ -18,6 +18,11 @@
package org.eclipse.jetty.util.ssl;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
@ -30,11 +35,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class SslContextFactoryTest
{

View File

@ -18,12 +18,12 @@
package org.eclipse.jetty.util.statistic;
import static org.junit.Assert.assertEquals;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/* ------------------------------------------------------------ */
public class SampleStatisticTest

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.util.thread;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -28,8 +30,6 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertTrue;
@RunWith(AdvancedRunner.class)
public class QueuedThreadPoolTest
{

View File

@ -18,14 +18,14 @@
package org.eclipse.jetty.util.thread;
import static org.junit.Assert.assertEquals;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicIntegerArray;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TimeoutTest
{

View File

@ -292,7 +292,6 @@ public class WebAppClassLoader extends URLClassLoader
/* ------------------------------------------------------------ */
public PermissionCollection getPermissions(CodeSource cs)
{
// TODO check CodeSource
PermissionCollection permissions=_context.getPermissions();
PermissionCollection pc= (permissions == null) ? super.getPermissions(cs) : permissions;
return pc;

View File

@ -32,12 +32,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.HttpMethodConstraintElement;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration.Dynamic;
import javax.servlet.ServletSecurityElement;
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingListener;
@ -66,7 +63,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection;
import org.eclipse.jetty.util.security.Constraint;
/* ------------------------------------------------------------ */
/** Web Application Context Handler.
@ -115,7 +111,6 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2)
"org.xml.", // needed by javax.xml
"org.w3c.", // needed by javax.xml
"org.apache.commons.logging.", // TODO: review if special case still needed
"org.eclipse.jetty.continuation.", // webapp cannot change continuation classes
"org.eclipse.jetty.jndi.", // webapp cannot change naming classes
"org.eclipse.jetty.plus.jaas.", // webapp cannot change jaas classes
@ -149,7 +144,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
private boolean _distributable=false;
private boolean _extractWAR=true;
private boolean _copyDir=false;
private boolean _copyWebInf=false; // TODO change to true?
private boolean _copyWebInf=false;
private boolean _logUrlOnStart =false;
private boolean _parentLoaderPriority= Boolean.getBoolean("org.eclipse.jetty.server.webapp.parentLoaderPriority");
private PermissionCollection _permissions;
@ -635,6 +630,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
/**
* @return Returns the permissions.
*/
@Override
public PermissionCollection getPermissions()
{
return _permissions;
@ -686,6 +682,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
}
/* ------------------------------------------------------------ */
@Override
public boolean isServerClass(String name)
{
if (_serverClasses == null)
@ -695,6 +692,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
}
/* ------------------------------------------------------------ */
@Override
public boolean isSystemClass(String name)
{
if (_systemClasses == null)
@ -821,6 +819,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
* should first try to load from WEB-INF/lib or WEB-INF/classes (servlet
* spec recommendation).
*/
@Override
@ManagedAttribute(value="parent classloader given priority", readonly=true)
public boolean isParentLoaderPriority()
{
@ -985,34 +984,41 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
_sessionHandler.clearEventListeners();
super.setEventListeners(eventListeners);
for (int i=0; eventListeners!=null && i<eventListeners.length;i ++)
{
EventListener listener = eventListeners[i];
if ((listener instanceof HttpSessionActivationListener)
|| (listener instanceof HttpSessionAttributeListener)
|| (listener instanceof HttpSessionBindingListener)
|| (listener instanceof HttpSessionListener))
{
if (_sessionHandler!=null)
_sessionHandler.addEventListener(listener);
}
}
}
/* ------------------------------------------------------------ */
/** Add EventListener
* Conveniance method that calls {@link #setEventListeners(EventListener[])}
* Convenience method that calls {@link #setEventListeners(EventListener[])}
* @param listener
*/
@Override
public void addEventListener(EventListener listener)
{
setEventListeners(ArrayUtil.addToArray(getEventListeners(), listener, EventListener.class));
super.addEventListener(listener);
if ((listener instanceof HttpSessionActivationListener)
|| (listener instanceof HttpSessionAttributeListener)
|| (listener instanceof HttpSessionBindingListener)
|| (listener instanceof HttpSessionListener))
{
if (_sessionHandler!=null)
_sessionHandler.addEventListener(listener);
}
}
@Override
public void removeEventListener(EventListener listener)
{
super.removeEventListener(listener);
if ((listener instanceof HttpSessionActivationListener)
|| (listener instanceof HttpSessionAttributeListener)
|| (listener instanceof HttpSessionBindingListener)
|| (listener instanceof HttpSessionListener))
{
if (_sessionHandler!=null)
_sessionHandler.removeEventListener(listener);
}
}
/* ------------------------------------------------------------ */
/**
@ -1174,6 +1180,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
* pointing to directories or jar files. Directories should end
* with '/'.
*/
@Override
@ManagedAttribute(value="extra classpath for context classloader", readonly=true)
public String getExtraClasspath()
{
@ -1290,7 +1297,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
Collection<String> pathMappings = registration.getMappings();
if (pathMappings != null)
{
Constraint constraint = ConstraintSecurityHandler.createConstraint(registration.getName(), servletSecurityElement);
ConstraintSecurityHandler.createConstraint(registration.getName(), servletSecurityElement);
for (String pathSpec:pathMappings)
{

View File

@ -72,7 +72,6 @@ public class DefaultWebSocketClient extends FutureCallback<UpgradeResponse> impl
public void completed(UpgradeResponse context)
{
LOG.debug("completed() - {}",context);
// TODO Auto-generated method stub
super.completed(context);
}
@ -130,7 +129,6 @@ public class DefaultWebSocketClient extends FutureCallback<UpgradeResponse> impl
{
LOG.debug("failed() - {}, {}",context,cause);
LOG.info(cause);
// TODO Auto-generated method stub
super.failed(context,cause);
}

View File

@ -82,10 +82,7 @@ public class WebSocketClientSelectorManager extends SelectorManager
return sslConnection;
}
else
{
// FIXME: throw error
throw new IOException("Cannot init SSL");
}
}
else
{

View File

@ -23,7 +23,6 @@ import java.net.URI;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -51,13 +50,11 @@ public class TestClient
@Override
public void onWebSocketBinary(byte[] payload, int offset, int len)
{
// TODO
}
@Override
public void onWebSocketClose(int statusCode, String reason)
{
// TODO Auto-generated method stub
super.onWebSocketClose(statusCode,reason);
}
@ -84,19 +81,6 @@ public class TestClient
while (off < data.length)
{
__framesSent++;
byte flags = (byte)((off + len) == data.length?0x8:0);
// byte op = (byte)(off == 0?opcode:WebSocketConnectionRFC6455.OP_CONTINUATION);
if (_verbose)
{
// System.err.printf("%s#sendFrame %s|%s %s\n",
// this.getClass().getSimpleName(),
// TypeUtil.toHexString(flags),
// TypeUtil.toHexString(op),
// TypeUtil.toHexString(data,off,len));
}
// _connection.sendFrame(flags,op,data,off,len);
off += len;
if ((data.length - off) > len)
@ -121,7 +105,6 @@ public class TestClient
private final String _protocol;
private final int _timeout;
private static boolean __quiet;
private static int __framesSent;
private static int __messagesSent;
private static AtomicInteger __framesReceived = new AtomicInteger();
@ -187,10 +170,6 @@ public class TestClient
{
delay = Integer.parseInt(args[++i]);
}
else if ("-q".equals(a) || "--quiet".equals(a))
{
__quiet = true;
}
else if (a.startsWith("-"))
{
usage(args);
@ -287,7 +266,6 @@ public class TestClient
System.err.println(" -p|--port PORT (default 8080)");
System.err.println(" -b|--binary");
System.err.println(" -v|--verbose");
System.err.println(" -q|--quiet");
System.err.println(" -c|--count n (default 10)");
System.err.println(" -s|--size n (default 64)");
System.err.println(" -f|--fragment n (default 4000) ");
@ -302,7 +280,6 @@ public class TestClient
int _messageBytes;
int _frames;
byte _opcode = -1;
private final CountDownLatch _handshook = new CountDownLatch(1);
private WebSocketClientFactory factory;
private TestSocket socket;

View File

@ -75,13 +75,11 @@ public class WebSocketLoadRFC6455Test
@Override
public void incoming(WebSocketException e)
{
// TODO Auto-generated method stub
}
@Override
public void incoming(WebSocketFrame frame)
{
// TODO Auto-generated method stub
}
};
private volatile ByteBuffer _response;

View File

@ -31,7 +31,6 @@ import javax.servlet.ServletRegistration;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletSecurityElement;
import javax.servlet.HttpConstraintElement;
import javax.servlet.HttpMethodConstraintElement;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSessionActivationListener;
@ -45,31 +44,37 @@ import java.util.Set;
public class TestListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
{
@Override
public void attributeAdded(HttpSessionBindingEvent se)
{
// System.err.println("attributedAdded "+se);
}
@Override
public void attributeRemoved(HttpSessionBindingEvent se)
{
// System.err.println("attributeRemoved "+se);
}
@Override
public void attributeReplaced(HttpSessionBindingEvent se)
{
// System.err.println("attributeReplaced "+se);
}
@Override
public void sessionWillPassivate(HttpSessionEvent se)
{
// System.err.println("sessionWillPassivate "+se);
}
@Override
public void sessionDidActivate(HttpSessionEvent se)
{
// System.err.println("sessionDidActivate "+se);
}
@Override
public void contextInitialized(ServletContextEvent sce)
{
//configure programmatic security
@ -98,26 +103,31 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
new String[]{"/*"});
}
@Override
public void contextDestroyed(ServletContextEvent sce)
{
// System.err.println("contextDestroyed "+sce);
}
@Override
public void attributeAdded(ServletContextAttributeEvent scab)
{
// System.err.println("attributeAdded "+scab);
}
@Override
public void attributeRemoved(ServletContextAttributeEvent scab)
{
// System.err.println("attributeRemoved "+scab);
}
@Override
public void attributeReplaced(ServletContextAttributeEvent scab)
{
// System.err.println("attributeReplaced "+scab);
}
@Override
public void requestDestroyed(ServletRequestEvent sre)
{
((HttpServletRequest)sre.getServletRequest()).getSession(false);
@ -125,53 +135,42 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
// System.err.println("requestDestroyed "+sre);
}
@Override
public void requestInitialized(ServletRequestEvent sre)
{
sre.getServletRequest().setAttribute("requestInitialized","'"+sre.getServletContext().getContextPath()+"'");
// System.err.println("requestInitialized "+sre);
}
@Override
public void attributeAdded(ServletRequestAttributeEvent srae)
{
// System.err.println("attributeAdded "+srae);
}
@Override
public void attributeRemoved(ServletRequestAttributeEvent srae)
{
// System.err.println("attributeRemoved "+srae);
}
@Override
public void attributeReplaced(ServletRequestAttributeEvent srae)
{
// System.err.println("attributeReplaced "+srae);
}
@Override
public void sessionCreated(HttpSessionEvent se)
{
// System.err.println("sessionCreated "+se);
}
@Override
public void sessionDestroyed(HttpSessionEvent se)
{
// System.err.println("sessionDestroyed "+se);
}
public void requestCompleted(ServletRequestEvent rre)
{
// TODO Auto-generated method stub
}
public void requestResumed(ServletRequestEvent rre)
{
// TODO Auto-generated method stub
}
public void requestSuspended(ServletRequestEvent rre)
{
// TODO Auto-generated method stub
}
}