diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java index fc79225ead2..59082e104ee 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java @@ -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(); } + @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()) { + @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()) { + @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()) { + @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 getAnnotationHandlers(String annotationName) { List handlers = new ArrayList(); @@ -529,6 +546,7 @@ public class AnnotationParser * @deprecated * @return */ + @Deprecated public List getAnnotationHandlers() { List allAnnotationHandlers = new ArrayList(); @@ -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 diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/ResourceA.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/ResourceA.java index ae3046d6068..6a098d0feca 100644 --- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/ResourceA.java +++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/ResourceA.java @@ -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 - } } diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java index bc191215ecd..b6d2b30aaec 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java @@ -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 _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()) diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java index 6008c5aa443..b4544b02e0f 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java @@ -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(); } /** diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index d221c1d3dea..6657b94f4a3 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -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. diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java index 98d13e8f598..e04a091612b 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java @@ -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(); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java index 2d6a42b54bd..3b3b785a646 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java @@ -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 diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java index e9e1ee2f299..f8ea42c56c8 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java @@ -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); } diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java index a34a11db758..81dfb0cbd35 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java @@ -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) diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/Rule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/Rule.java index 6f41c7afe03..6e980143e37 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/Rule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/Rule.java @@ -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; diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java index 1e1bd6ab96d..cd21dd6ff9c 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java @@ -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 + } } diff --git a/jetty-server/src/main/config/etc/jetty.xml b/jetty-server/src/main/config/etc/jetty.xml index 7202e210496..1729d8d9c43 100644 --- a/jetty-server/src/main/config/etc/jetty.xml +++ b/jetty-server/src/main/config/etc/jetty.xml @@ -112,7 +112,7 @@ true true true - 1000 + 5000 false false diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java b/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java index 00b25354e0c..57e3f042024 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java @@ -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); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java index 9919323211b..438bb5d7ad8 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java @@ -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 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 getAttributeNames() { - HashSet set=new HashSet(); - Enumeration e=_attr.getAttributeNames(); + HashSet set=new HashSet<>(); + Enumeration 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 getAttributeNames() { - HashSet set=new HashSet(); - Enumeration e=_attr.getAttributeNames(); + HashSet set=new HashSet<>(); + Enumeration 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); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java index 996d26a23e0..9bf5520a574 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java @@ -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(); } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index 4cc8a885ccb..99da268d1dc 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -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 diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java index 564e01b1dca..09290f9c7e2 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java @@ -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 doStop() 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() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java index fb83c0451c4..48a118bd847 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java @@ -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; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java index 99785c3ea23..0369cdfa056 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandlerContainer.java @@ -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; /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 4404be008b4..01f21af9566 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -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 _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 _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 _eventListeners=new CopyOnWriteArrayList<>(); + private final List _programmaticListeners=new CopyOnWriteArrayList<>(); + private final List _contextListeners=new CopyOnWriteArrayList<>(); + private final List _contextAttributeListeners=new CopyOnWriteArrayList<>(); + private final List _requestListeners=new CopyOnWriteArrayList<>(); + private final List _requestAttributeListeners=new CopyOnWriteArrayList<>(); private Map _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 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 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 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 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 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 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 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 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 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 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 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 getAttributeNames() { HashSet set = new HashSet(); 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) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java index 35e1aa10781..00cdad1e0f6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java @@ -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 diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java index e8d7311fe75..f0feba01605 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java @@ -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()); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java index cff469b80d4..c2bf74a9952 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java @@ -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; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java index 3f02b11531a..241994e0f94 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java @@ -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; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java index 8b866f684e1..4654a259643 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java @@ -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; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java index 4d34ef78b9c..58e100d6e78 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java @@ -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() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java index 3ba0da60f87..a659d44eb94 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @@ -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; /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java index 43cb5f3d17a..22d28736b3b 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectionOpenCloseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectionOpenCloseTest.java index 7e3a63c13b8..3cff5d6c9a9 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectionOpenCloseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectionOpenCloseTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 66c9365c262..2a80902fce3 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToAsyncCommitTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToAsyncCommitTest.java index 664fc9b21da..60cfadca0be 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToAsyncCommitTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToAsyncCommitTest.java @@ -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 diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index c98c22be755..84cb9f372e3 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -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 diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpURITest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpURITest.java index def37c10ad8..0c09d704858 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpURITest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpURITest.java @@ -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= diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java index 7b1a146f4e0..0c543c9f18e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java index 8e0f048ccb1..cc33e1a95bf 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java @@ -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 { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/IPAccessHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/IPAccessHandlerTest.java index b8578c9894f..287ae0d3750 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/IPAccessHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/IPAccessHandlerTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java index 6487c7ce5b7..2007ec17f4d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java index 1df73bfd851..be3bc96f5e7 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java index da4aa103537..680c4c0a29b 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java index fe779438845..250f517857f 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java @@ -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. diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java index 644422cdefe..1e1eef12aa4 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java @@ -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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java index 2b2648be0fa..60eb6b65448 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java @@ -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; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java index 1b651d9c0c7..a0a5eb7e3ac 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java @@ -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 diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java index e0f2730b10e..c7537278d86 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java @@ -89,8 +89,6 @@ public class ServletContextHandler extends ContextHandler protected ServletHandler _servletHandler; protected int _options; protected JspConfigDescriptor _jspConfig; - protected List _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 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 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 listenerClass) { - // TODO other started conditions if (!isStarting()) throw new IllegalStateException(); if (!_enabled) diff --git a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml b/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml index ee2717ce979..0aded0fd6fe 100644 --- a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml +++ b/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml @@ -36,7 +36,7 @@ - + diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index 77665035226..529f76456d9 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -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 resolveXmlConfigs(List xmls) throws FileNotFoundException { List ret = new ArrayList(); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java index 08b0b750c51..7bd83248da8 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java @@ -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++) { diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java index 6d6efa788d4..d070687b86a 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java @@ -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; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java index 7f5522aacb6..67974f9bc3f 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java @@ -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'; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java index 758aac8d9d7..1111cb6b524 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java @@ -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; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java index 09eaa330935..88e737aa8ac 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java @@ -323,6 +323,6 @@ public class URLResource extends Resource @Override public boolean isContainedIn (Resource containingResource) throws MalformedURLException { - return false; //TODO check this! + return false; } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509ExtendedKeyManager.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509ExtendedKeyManager.java index 98d50494978..6e5bd761e12 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509ExtendedKeyManager.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509ExtendedKeyManager.java @@ -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; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509KeyManager.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509KeyManager.java index 488aad37885..9155bd667fe 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509KeyManager.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/AliasedX509KeyManager.java @@ -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; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index af6cee6b3d5..7b9769ef426 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -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; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ArrayQueueTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ArrayQueueTest.java index 7cbd9e1a002..782e9473c62 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ArrayQueueTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ArrayQueueTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/BlockingArrayQueueTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/BlockingArrayQueueTest.java index ea634b72e80..5b3a27c4297 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/BlockingArrayQueueTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/BlockingArrayQueueTest.java @@ -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(); } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java index e912c56393b..a2d989e5efc 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java @@ -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 diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/IPAddressMapTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/IPAddressMapTest.java index b9af773d447..cc1cf04a586 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/IPAddressMapTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/IPAddressMapTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/LazyListTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/LazyListTest.java index f38ea76a28f..ab01b72ed26 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/LazyListTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/LazyListTest.java @@ -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. */ diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java index 1fa82c4d9fa..e42943f3879 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java index 369d27a3add..aba87c61d43 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java @@ -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 { /** diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java index 307af340660..37cfea79fde 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java @@ -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 * diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/QuotedStringTokenizerTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/QuotedStringTokenizerTest.java index 884101280f4..3429df9138a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/QuotedStringTokenizerTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/QuotedStringTokenizerTest.java @@ -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; + /** * diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/StringMapTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/StringMapTest.java index 3e8032bd133..0712b89a46b 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/StringMapTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/StringMapTest.java @@ -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; - /** * diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/StringUtilTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/StringUtilTest.java index 2b722fcd7fa..231dd0a7401 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/StringUtilTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/StringUtilTest.java @@ -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 diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/TestIntrospectionUtil.java b/jetty-util/src/test/java/org/eclipse/jetty/util/TestIntrospectionUtil.java index a032dd48fbc..1969faf8f45 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/TestIntrospectionUtil.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/TestIntrospectionUtil.java @@ -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 diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java index bf457dca928..9e7479ff82f 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java @@ -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. diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java index 0f55c91a013..dbeeb5658a5 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java @@ -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. diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8LineParserTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8LineParserTest.java index a8c8afd83a3..da583b6500a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8LineParserTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8LineParserTest.java @@ -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) diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java index 3e6d2d52534..e39eaff09d9 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java @@ -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 diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java index 293b4116d3e..7a0d1830579 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java @@ -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 diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/component/ContainerLifeCycleTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/component/ContainerLifeCycleTest.java index 21b17965faf..a30494c4a9b 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/component/ContainerLifeCycleTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/component/ContainerLifeCycleTest.java @@ -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; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java index 83337e28b95..e412fccb382 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java index 5bd2179c7cd..a3d4bf5429c 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java @@ -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"); diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java index 09753b4bccd..722cc411dfe 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java @@ -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; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java index 295a95ddd84..4d29f8de276 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java @@ -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; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java index 68aea654ac5..ed9e6069091 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java @@ -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 */ diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceCollectionTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceCollectionTest.java index 4b70ff76ab8..757a0b9cb00 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceCollectionTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceCollectionTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java index 81e457e02f0..840939c7689 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java index b4dab77afc0..5841aa1116a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java index db5b33ae2c9..ba133acb60e 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java @@ -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 diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java index 35ec3eed654..bdc914cc389 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java @@ -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 { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/TimeoutTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/TimeoutTest.java index f56b93994c3..bfc00d8e860 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/TimeoutTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/TimeoutTest.java @@ -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 { diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java index 0420b03054e..34e2f304af1 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java @@ -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; diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java index 0e492dd68e0..0f92415b2c7 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java @@ -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 pathMappings = registration.getMappings(); if (pathMappings != null) { - Constraint constraint = ConstraintSecurityHandler.createConstraint(registration.getName(), servletSecurityElement); + ConstraintSecurityHandler.createConstraint(registration.getName(), servletSecurityElement); for (String pathSpec:pathMappings) { diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DefaultWebSocketClient.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DefaultWebSocketClient.java index 609b49b570d..6d44cd5805d 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DefaultWebSocketClient.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DefaultWebSocketClient.java @@ -72,7 +72,6 @@ public class DefaultWebSocketClient extends FutureCallback 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 impl { LOG.debug("failed() - {}, {}",context,cause); LOG.info(cause); - // TODO Auto-generated method stub super.failed(context,cause); } diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java index 70a28cb7b45..dac7c76f161 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java @@ -82,10 +82,7 @@ public class WebSocketClientSelectorManager extends SelectorManager return sslConnection; } else - { - // FIXME: throw error throw new IOException("Cannot init SSL"); - } } else { diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/examples/TestClient.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/examples/TestClient.java index 1d6e56455e8..c9f97d6157b 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/examples/TestClient.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/examples/TestClient.java @@ -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; diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java index 0ffa6c97fe1..b03a076ffba 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java @@ -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; diff --git a/test-jetty-webapp/src/main/java/com/acme/TestListener.java b/test-jetty-webapp/src/main/java/com/acme/TestListener.java index 02674b48820..79767d27b04 100644 --- a/test-jetty-webapp/src/main/java/com/acme/TestListener.java +++ b/test-jetty-webapp/src/main/java/com/acme/TestListener.java @@ -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 - - } }