diff --git a/build-resources/src/main/resources/jetty-checkstyle.xml b/build-resources/src/main/resources/jetty-checkstyle.xml index 29412985a337..d81529a266cb 100644 --- a/build-resources/src/main/resources/jetty-checkstyle.xml +++ b/build-resources/src/main/resources/jetty-checkstyle.xml @@ -38,10 +38,16 @@ =========================================================================================== --> + + + + + + - + @@ -51,7 +57,7 @@ - + diff --git a/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/AsyncRestServlet.java b/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/AsyncRestServlet.java index c7754f466d9c..57edf98b3914 100644 --- a/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/AsyncRestServlet.java +++ b/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/AsyncRestServlet.java @@ -130,7 +130,7 @@ void onComplete() // We have results! // Generate the response - String thumbs = generateThumbs(results); + final String thumbs = generateThumbs(results); response.setContentType("text/html"); PrintWriter out = response.getWriter(); @@ -194,9 +194,10 @@ public void onComplete(Result result) onComplete(); } + abstract void onComplete(); + abstract void onAuctionFound(Map details); - abstract void onComplete(); } @Override diff --git a/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/SerialRestServlet.java b/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/SerialRestServlet.java index afa291ec8732..6d895b70194f 100644 --- a/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/SerialRestServlet.java +++ b/examples/async-rest/async-rest-jar/src/main/java/org/eclipse/jetty/example/asyncrest/SerialRestServlet.java @@ -42,7 +42,7 @@ public class SerialRestServlet extends AbstractRestServlet @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - long start = System.nanoTime(); + final long start = System.nanoTime(); String[] keywords = sanitize(request.getParameter(ITEMS_PARAM)).split(","); Queue> results = new LinkedList>(); @@ -67,7 +67,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t } // Generate the response - String thumbs = generateThumbs(results); + final String thumbs = generateThumbs(results); response.setContentType("text/html"); PrintWriter out = response.getWriter(); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java index 1934f2e73120..e57bc126c4f3 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java @@ -35,7 +35,7 @@ public static void main(String[] args) throws Exception // Create a basic Jetty server object that will listen on port 8080. Note that if you set this to port 0 // then a randomly available port will be assigned that you can either look in the logs for the port, // or programmatically obtain it for use in test cases. - Server server = new Server(8080); + final Server server = new Server(8080); // Create the ResourceHandler. It is the object that will actually handle the request for a given file. It is // a Jetty Handler object so it is suitable for chaining with other handlers as you will see in other examples. diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java index 9b32d6a16cc2..c84ee9b3c335 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java @@ -34,7 +34,7 @@ public class JarServer { public static void main(String[] args) throws Exception { - Server server = new Server(8080); + final Server server = new Server(8080); ServletContextHandler context = new ServletContextHandler(); Resource.setDefaultUseCaches(true); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java index 552631044711..752d071f682b 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java @@ -186,10 +186,10 @@ public static void main(String[] args) throws Exception // === jetty-requestlog.xml === AsyncRequestLogWriter logWriter = new AsyncRequestLogWriter(jettyHome + "/logs/yyyy_mm_dd.request.log"); - CustomRequestLog requestLog = new CustomRequestLog(logWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT + " \"%C\""); logWriter.setFilenameDateFormat("yyyy_MM_dd"); logWriter.setRetainDays(90); logWriter.setTimeZone("GMT"); + CustomRequestLog requestLog = new CustomRequestLog(logWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT + " \"%C\""); server.setRequestLog(requestLog); // === jetty-lowresources.xml === diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java index dc1f10985f5e..944cce31853d 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java @@ -27,7 +27,7 @@ public class ManyContexts { public static void main(String[] args) throws Exception { - Server server = new Server(8080); + final Server server = new Server(8080); ContextHandler context = new ContextHandler("/"); context.setContextPath("/"); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java index 49bc494302f7..1cbc13d0d4f9 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java @@ -106,13 +106,13 @@ public void handle(String target, public static void main(String[] args) throws Exception { - Server server = new Server(8080); + final Server server = new Server(8080); // create the handlers - Handler param = new ParamHandler(); - HandlerWrapper wrapper = new WelcomeWrapHandler(); - Handler hello = new HelloHandler(); - Handler dft = new DefaultHandler(); + final Handler param = new ParamHandler(); + final HandlerWrapper wrapper = new WelcomeWrapHandler(); + final Handler hello = new HelloHandler(); + final Handler dft = new DefaultHandler(); // configure request logging File requestLogFile = File.createTempFile("demo", "log"); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java index faed8deeae42..7b148e0c703a 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java @@ -39,7 +39,7 @@ public class ServerWithAnnotations public static final void main(String[] args) throws Exception { // Create the server - Server server = new Server(8080); + final Server server = new Server(8080); // Create a WebApp WebAppContext webapp = new WebAppContext(); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java index b4d316c448d1..d3ac32dafbdf 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java @@ -48,7 +48,7 @@ public void onMessage(Session session, String message) public static void main(String[] args) throws Exception { - Server server = new Server(8080); + final Server server = new Server(8080); HandlerList handlers = new HandlerList(); diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java index b49407c29335..f97ee6019723 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java @@ -428,8 +428,6 @@ protected void scanForAnnotations(WebAppContext context) AnnotationParser parser = createAnnotationParser(javaPlatform); _parserTasks = new ArrayList(); - long start = 0; - if (LOG.isDebugEnabled()) LOG.debug("Annotation scanning commencing: webxml={}, metadatacomplete={}, configurationDiscovered={}, multiThreaded={}, maxScanWait={}", context.getServletContext().getEffectiveMajorVersion(), @@ -447,7 +445,7 @@ protected void scanForAnnotations(WebAppContext context) parseWebInfClasses(context, parser); parseWebInfLib(context, parser); - start = System.nanoTime(); + long start = System.nanoTime(); //execute scan, either effectively synchronously (1 thread only), or asynchronously (limited by number of processors available) final Semaphore task_limit = (isUseMultiThreading(context) ? new Semaphore(ProcessorUtils.availableProcessors()) : new Semaphore(1)); 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 a81135dd9080..cff8252d1df2 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 @@ -694,68 +694,6 @@ public void parse(Set handlers, List classNames) thro me.ifExceptionThrow(); } - /** - * Parse all classes in a directory - * - * @param handlers the set of handlers to look for classes in - * @param root the resource directory to look for classes - * @throws Exception if unable to parse - */ - protected void parseDir(Set handlers, Resource root) throws Exception - { - if (!root.isDirectory() || !root.exists() || root.getName().startsWith(".")) - return; - - if (LOG.isDebugEnabled()) - LOG.debug("Scanning dir {}", root); - - File rootFile = root.getFile(); - - MultiException me = new MultiException(); - Collection resources = root.getAllResources(); - if (resources != null) - { - for (Resource r : resources) - { - if (r.isDirectory()) - continue; - - File file = r.getFile(); - if (isValidClassFileName((file == null ? null : file.getName()))) - { - Path classpath = rootFile.toPath().relativize(file.toPath()); - String str = classpath.toString(); - str = str.substring(0, str.lastIndexOf(".class")); - str = StringUtil.replace(str, File.separatorChar, '.'); - - try - { - if (LOG.isDebugEnabled()) - LOG.debug("Scanning class {}", r); - addParsedClass(str, r); - try (InputStream is = r.getInputStream()) - { - scanClass(handlers, Resource.newResource(file.getParentFile()), is); - } - } - catch (Exception ex) - { - if (LOG.isDebugEnabled()) - LOG.debug("Error scanning file " + file, ex); - me.add(new RuntimeException("Error scanning file " + file, ex)); - } - } - else - { - if (LOG.isDebugEnabled()) - LOG.debug("Skipping scan on invalid file {}", file); - } - } - } - - me.ifExceptionThrow(); - } - /** * Parse classes in the supplied uris. * @@ -837,6 +775,68 @@ public void parse(final Set handlers, Resource r) throws Exce LOG.warn("Resource not scannable for classes: {}", r); } + /** + * Parse all classes in a directory + * + * @param handlers the set of handlers to look for classes in + * @param root the resource directory to look for classes + * @throws Exception if unable to parse + */ + protected void parseDir(Set handlers, Resource root) throws Exception + { + if (!root.isDirectory() || !root.exists() || root.getName().startsWith(".")) + return; + + if (LOG.isDebugEnabled()) + LOG.debug("Scanning dir {}", root); + + File rootFile = root.getFile(); + + MultiException me = new MultiException(); + Collection resources = root.getAllResources(); + if (resources != null) + { + for (Resource r : resources) + { + if (r.isDirectory()) + continue; + + File file = r.getFile(); + if (isValidClassFileName((file == null ? null : file.getName()))) + { + Path classpath = rootFile.toPath().relativize(file.toPath()); + String str = classpath.toString(); + str = str.substring(0, str.lastIndexOf(".class")); + str = StringUtil.replace(str, File.separatorChar, '.'); + + try + { + if (LOG.isDebugEnabled()) + LOG.debug("Scanning class {}", r); + addParsedClass(str, r); + try (InputStream is = r.getInputStream()) + { + scanClass(handlers, Resource.newResource(file.getParentFile()), is); + } + } + catch (Exception ex) + { + if (LOG.isDebugEnabled()) + LOG.debug("Error scanning file " + file, ex); + me.add(new RuntimeException("Error scanning file " + file, ex)); + } + } + else + { + if (LOG.isDebugEnabled()) + LOG.debug("Skipping scan on invalid file {}", file); + } + } + } + + me.ifExceptionThrow(); + } + /** * Parse a resource that is a jar file. * diff --git a/jetty-ant/src/main/java/org/eclipse/jetty/ant/AntWebAppContext.java b/jetty-ant/src/main/java/org/eclipse/jetty/ant/AntWebAppContext.java index 911f6cd2f698..e46b30941f19 100644 --- a/jetty-ant/src/main/java/org/eclipse/jetty/ant/AntWebAppContext.java +++ b/jetty-ant/src/main/java/org/eclipse/jetty/ant/AntWebAppContext.java @@ -201,12 +201,6 @@ protected Class findClass(String name) throws ClassNotFoundException return super.findClass(name); } - @Override - protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException - { - return super.definePackage(name, man, url); - } - @Override public URL findResource(String name) { @@ -255,6 +249,12 @@ public Enumeration getResources(String name) throws IOException return super.getResources(name); } + @Override + protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException + { + return super.definePackage(name, man, url); + } + @Override protected Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) throws IllegalArgumentException diff --git a/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java b/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java index 30ca0d9adb4c..feb95456da1f 100644 --- a/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java +++ b/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java @@ -484,14 +484,12 @@ private void startScanners() throws Exception if (scanIntervalSecs <= 0) return; - List scanList = awc.getScanFiles(); - TaskLog.log("Web application '" + awc + "': starting scanner at interval of " + scanIntervalSecs + " seconds."); Scanner.Listener changeListener = new WebAppScannerListener(awc); Scanner scanner = new Scanner(); scanner.setScanInterval(scanIntervalSecs); scanner.addListener(changeListener); - scanner.setScanDirs(scanList); + scanner.setScanDirs(awc.getScanFiles()); scanner.setReportExistingFilesOnStartup(false); scanner.start(); } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java index f2642ced9eb2..53cb43a74306 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java @@ -79,12 +79,54 @@ public void send(Request request, Response.CompleteListener listener) httpRequest.abort(result.failure); } + protected SendFailure send(HttpChannel channel, HttpExchange exchange) + { + // Forbid idle timeouts for the time window where + // the request is associated to the channel and sent. + // Use a counter to support multiplexed requests. + boolean send; + synchronized (this) + { + send = idleTimeoutGuard >= 0; + if (send) + ++idleTimeoutGuard; + } + + if (send) + { + HttpRequest request = exchange.getRequest(); + SendFailure result; + if (channel.associate(exchange)) + { + channel.send(); + result = null; + } + else + { + channel.release(); + result = new SendFailure(new HttpRequestException("Could not associate request to connection", request), false); + } + + synchronized (this) + { + --idleTimeoutGuard; + idleTimeoutStamp = System.nanoTime(); + } + + return result; + } + else + { + return new SendFailure(new TimeoutException(), true); + } + } + protected void normalizeRequest(Request request) { - HttpVersion version = request.getVersion(); - HttpFields headers = request.getHeaders(); - ContentProvider content = request.getContent(); - ProxyConfiguration.Proxy proxy = destination.getProxy(); + final HttpVersion version = request.getVersion(); + final HttpFields headers = request.getHeaders(); + final ContentProvider content = request.getContent(); + final ProxyConfiguration.Proxy proxy = destination.getProxy(); // Make sure the path is there String path = request.getPath(); @@ -176,48 +218,6 @@ private void applyAuthentication(Request request, URI uri) } } - protected SendFailure send(HttpChannel channel, HttpExchange exchange) - { - // Forbid idle timeouts for the time window where - // the request is associated to the channel and sent. - // Use a counter to support multiplexed requests. - boolean send; - synchronized (this) - { - send = idleTimeoutGuard >= 0; - if (send) - ++idleTimeoutGuard; - } - - if (send) - { - HttpRequest request = exchange.getRequest(); - SendFailure result; - if (channel.associate(exchange)) - { - channel.send(); - result = null; - } - else - { - channel.release(); - result = new SendFailure(new HttpRequestException("Could not associate request to connection", request), false); - } - - synchronized (this) - { - --idleTimeoutGuard; - idleTimeoutStamp = System.nanoTime(); - } - - return result; - } - else - { - return new SendFailure(new TimeoutException(), true); - } - } - public boolean onIdleTimeout(long idleTimeout) { synchronized (this) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java index 847d5f45ee58..06e300173f67 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java @@ -304,11 +304,6 @@ public void send(HttpExchange exchange) } } - protected boolean enqueue(Queue queue, HttpExchange exchange) - { - return queue.offer(exchange); - } - public void send() { if (getHttpExchanges().isEmpty()) @@ -316,6 +311,11 @@ public void send() process(); } + protected boolean enqueue(Queue queue, HttpExchange exchange) + { + return queue.offer(exchange); + } + private void process() { while (true) @@ -396,6 +396,11 @@ public boolean remove(HttpExchange exchange) return exchanges.remove(exchange); } + public boolean remove(Connection connection) + { + return connectionPool.remove(connection); + } + @Override public void close() { @@ -406,6 +411,24 @@ public void close() timeout.destroy(); } + public void close(Connection connection) + { + boolean removed = remove(connection); + + if (getHttpExchanges().isEmpty()) + { + tryRemoveIdleDestination(); + } + else + { + // We need to execute queued requests even if this connection failed. + // We may create a connection that is not needed, but it will eventually + // idle timeout, so no worries. + if (removed) + process(); + } + } + public void release(Connection connection) { if (LOG.isDebugEnabled()) @@ -434,29 +457,6 @@ public void release(Connection connection) } } - public boolean remove(Connection connection) - { - return connectionPool.remove(connection); - } - - public void close(Connection connection) - { - boolean removed = remove(connection); - - if (getHttpExchanges().isEmpty()) - { - tryRemoveIdleDestination(); - } - else - { - // We need to execute queued requests even if this connection failed. - // We may create a connection that is not needed, but it will eventually - // idle timeout, so no worries. - if (removed) - process(); - } - } - /** * Aborts all the {@link HttpExchange}s queued in this destination. * diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java index fbf558977fec..7646656649e8 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java @@ -116,12 +116,13 @@ protected boolean responseBegin(HttpExchange exchange) if (!updateResponseState(ResponseState.IDLE, ResponseState.TRANSIENT)) return false; - HttpConversation conversation = exchange.getConversation(); - HttpResponse response = exchange.getResponse(); + final HttpConversation conversation = exchange.getConversation(); + final HttpResponse response = exchange.getResponse(); // Probe the protocol handlers - HttpDestination destination = getHttpDestination(); - HttpClient client = destination.getHttpClient(); - ProtocolHandler protocolHandler = client.findProtocolHandler(exchange.getRequest(), response); + final HttpDestination destination = getHttpDestination(); + final HttpClient client = destination.getHttpClient(); + final ProtocolHandler protocolHandler = client.findProtocolHandler(exchange.getRequest(), response); + Response.Listener handlerListener = null; if (protocolHandler != null) { diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java index 4e6a6a0799c2..6e5e330cf34b 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java @@ -175,58 +175,6 @@ public Request redirect(Request request, Response response, Response.CompleteLis } } - /** - * Extracts and sanitizes (by making it absolute and escaping paths and query parameters) - * the redirect URI of the given {@code response}. - * - * @param response the response to extract the redirect URI from - * @return the absolute redirect URI, or null if the response does not contain a valid redirect location - */ - public URI extractRedirectURI(Response response) - { - String location = response.getHeaders().get("location"); - if (location != null) - return sanitize(location); - return null; - } - - private URI sanitize(String location) - { - // Redirects should be valid, absolute, URIs, with properly escaped paths and encoded - // query parameters. However, shit happens, and here we try our best to recover. - - try - { - // Direct hit first: if passes, we're good - return new URI(location); - } - catch (URISyntaxException x) - { - Matcher matcher = URI_PATTERN.matcher(location); - if (matcher.matches()) - { - String scheme = matcher.group(2); - String authority = matcher.group(3); - String path = matcher.group(4); - String query = matcher.group(5); - if (query.length() == 0) - query = null; - String fragment = matcher.group(6); - if (fragment.length() == 0) - fragment = null; - try - { - return new URI(scheme, authority, path, query, fragment); - } - catch (URISyntaxException ex) - { - // Give up - } - } - return null; - } - } - private Request redirect(Request request, Response response, Response.CompleteListener listener, URI newURI) { if (!newURI.isAbsolute()) @@ -307,6 +255,58 @@ private Request redirect(Request request, Response response, Response.CompleteLi } } + /** + * Extracts and sanitizes (by making it absolute and escaping paths and query parameters) + * the redirect URI of the given {@code response}. + * + * @param response the response to extract the redirect URI from + * @return the absolute redirect URI, or null if the response does not contain a valid redirect location + */ + public URI extractRedirectURI(Response response) + { + String location = response.getHeaders().get("location"); + if (location != null) + return sanitize(location); + return null; + } + + private URI sanitize(String location) + { + // Redirects should be valid, absolute, URIs, with properly escaped paths and encoded + // query parameters. However, shit happens, and here we try our best to recover. + + try + { + // Direct hit first: if passes, we're good + return new URI(location); + } + catch (URISyntaxException x) + { + Matcher matcher = URI_PATTERN.matcher(location); + if (matcher.matches()) + { + String scheme = matcher.group(2); + String authority = matcher.group(3); + String path = matcher.group(4); + String query = matcher.group(5); + if (query.length() == 0) + query = null; + String fragment = matcher.group(6); + if (fragment.length() == 0) + fragment = null; + try + { + return new URI(scheme, authority, path, query, fragment); + } + catch (URISyntaxException ex) + { + // Give up + } + } + return null; + } + } + private Request sendRedirect(final HttpRequest httpRequest, Response response, Response.CompleteListener listener, URI location, String method) { try diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java index 1edae1336090..b8e23ef058d5 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java @@ -237,7 +237,7 @@ protected Action process() throws Exception } case FLUSH: { - EndPoint endPoint = getHttpChannel().getHttpConnection().getEndPoint(); + final EndPoint endPoint = getHttpChannel().getHttpConnection().getEndPoint(); if (headerBuffer == null) headerBuffer = BufferUtil.EMPTY_BUFFER; if (chunkBuffer == null) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/util/DigestAuthentication.java b/jetty-client/src/main/java/org/eclipse/jetty/client/util/DigestAuthentication.java index 9d2079fd0789..fd095cb68058 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/util/DigestAuthentication.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/util/DigestAuthentication.java @@ -85,7 +85,7 @@ public Result authenticate(Request request, ContentResponse response, HeaderInfo String nonce = params.get("nonce"); if (nonce == null || nonce.length() == 0) return null; - String opaque = params.get("opaque"); + final String opaque = params.get("opaque"); String algorithm = params.get("algorithm"); if (algorithm == null) algorithm = "MD5"; @@ -186,7 +186,7 @@ public void apply(Request request) clientNonce = null; a3 = hashA1 + ":" + nonce + ":" + hashA2; } - String hashA3 = toHexString(digester.digest(a3.getBytes(StandardCharsets.ISO_8859_1))); + final String hashA3 = toHexString(digester.digest(a3.getBytes(StandardCharsets.ISO_8859_1))); StringBuilder value = new StringBuilder("Digest"); value.append(" username=\"").append(user).append("\""); diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java b/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java index e6441371d578..f540ade09c5f 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java @@ -365,6 +365,9 @@ public ByteBuffer next() { throw new NoSuchElementException(); } + + default: + throw new IllegalStateException(state.toString()); } } } diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java index 360ecf6a133b..64de4a6444ee 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java @@ -338,6 +338,11 @@ public Collection getApps(Node node) return ret; } + public Collection getApps(String nodeName) + { + return getApps(_lifecycle.getNodeByName(nodeName)); + } + public List getAppsWithSameContext(App app) { List ret = new ArrayList(); @@ -538,15 +543,6 @@ private void requestAppGoal(AppEntry appentry, String nodeName) } } - private synchronized void addOnStartupError(Throwable cause) - { - if (onStartupErrors == null) - { - onStartupErrors = new MultiException(); - } - onStartupErrors.add(cause); - } - /** * Move an {@link App} through the {@link AppLifeCycle} to the desired {@link Node}, executing each lifecycle step * in the process to reach the desired state. @@ -565,6 +561,15 @@ public void requestAppGoal(@Name("appId") String appId, @Name("nodeName") String requestAppGoal(appentry, nodeName); } + private synchronized void addOnStartupError(Throwable cause) + { + if (onStartupErrors == null) + { + onStartupErrors = new MultiException(); + } + onStartupErrors.add(cause); + } + /** * Set a contextAttribute that will be set for every Context deployed by this provider. * @@ -628,11 +633,6 @@ public Collection getNodes() return _lifecycle.getNodes(); } - public Collection getApps(String nodeName) - { - return getApps(_lifecycle.getNodeByName(nodeName)); - } - public void scope(XmlConfiguration xmlc, Resource webapp) throws IOException { diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java index 42f076ed0a6e..30f9b7cb87d5 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java @@ -56,12 +56,6 @@ public Collection getApps() return ret; } - @ManagedOperation(value = "list nodes that are tracked by DeploymentManager", impact = "INFO") - public Collection getNodes() - { - return _manager.getNodes().stream().map(Node::getName).collect(Collectors.toList()); - } - @ManagedOperation(value = "list apps that are located at specified App LifeCycle nodes", impact = "ACTION") public Collection getApps(@Name("nodeName") String nodeName) { @@ -82,6 +76,12 @@ public Collection getApps(@Name("nodeName") String nodeName) return ret; } + @ManagedOperation(value = "list nodes that are tracked by DeploymentManager", impact = "INFO") + public Collection getNodes() + { + return _manager.getNodes().stream().map(Node::getName).collect(Collectors.toList()); + } + private String toRef(App app) { return String.format("originId=%s,contextPath=%s,appProvider=%s", app.getContextPath(), app.getOriginId(), app.getAppProvider().getClass().getName()); diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java index 8e53ea67b5f2..4280ddd284a4 100644 --- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java +++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/StreamContentParser.java @@ -62,7 +62,7 @@ public Result parse(ByteBuffer buffer) int length = Math.min(contentLength, buffer.remaining()); int limit = buffer.limit(); buffer.limit(buffer.position() + length); - ByteBuffer slice = buffer.slice(); + final ByteBuffer slice = buffer.slice(); buffer.position(buffer.limit()); buffer.limit(limit); contentLength -= length; diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java index 595a6422b793..5589c1942203 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java +++ b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java @@ -904,14 +904,14 @@ protected SessionData sessionFromEntity(Entity entity) throws Exception return null; //turn an Entity into a Session - String id = entity.getString(_model.getId()); - String contextPath = entity.getString(_model.getContextPath()); - String vhost = entity.getString(_model.getVhost()); - long accessed = entity.getLong(_model.getAccessed()); - long lastAccessed = entity.getLong(_model.getLastAccessed()); - long createTime = entity.getLong(_model.getCreateTime()); - long cookieSet = entity.getLong(_model.getCookieSetTime()); - String lastNode = entity.getString(_model.getLastNode()); + final String id = entity.getString(_model.getId()); + final String contextPath = entity.getString(_model.getContextPath()); + final String vhost = entity.getString(_model.getVhost()); + final long accessed = entity.getLong(_model.getAccessed()); + final long lastAccessed = entity.getLong(_model.getLastAccessed()); + final long createTime = entity.getLong(_model.getCreateTime()); + final long cookieSet = entity.getLong(_model.getCookieSetTime()); + final String lastNode = entity.getString(_model.getLastNode()); long lastSaved = 0; //for compatibility with previously saved sessions, lastSaved may not be present diff --git a/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/SessionDataSerializer.java b/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/SessionDataSerializer.java index b4b82fb96aea..da11033940de 100644 --- a/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/SessionDataSerializer.java +++ b/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/SessionDataSerializer.java @@ -77,17 +77,17 @@ public void write(ObjectDataOutput out, SessionData data) throws IOException @Override public SessionData read(ObjectDataInput in) throws IOException { - String id = in.readUTF(); - String contextPath = in.readUTF(); - String vhost = in.readUTF(); + final String id = in.readUTF(); + final String contextPath = in.readUTF(); + final String vhost = in.readUTF(); - long accessed = in.readLong(); - long lastAccessed = in.readLong(); - long created = in.readLong(); - long cookieSet = in.readLong(); - String lastNode = in.readUTF(); - long expiry = in.readLong(); - long maxInactiveMs = in.readLong(); + final long accessed = in.readLong(); + final long lastAccessed = in.readLong(); + final long created = in.readLong(); + final long cookieSet = in.readLong(); + final String lastNode = in.readUTF(); + final long expiry = in.readLong(); + final long maxInactiveMs = in.readLong(); SessionData sd = new SessionData(id, contextPath, vhost, created, accessed, lastAccessed, maxInactiveMs); diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java index faee5d99998f..0733ac6a2f63 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java @@ -259,6 +259,12 @@ public HttpContext createContext(String path, HttpHandler httpHandler) return context; } + @Override + public HttpContext createContext(String path) + { + return createContext(path, null); + } + private void checkIfContextIsFree(String path) { Handler serverHandler = _server.getHandler(); @@ -284,12 +290,6 @@ private void checkIfContextIsFree(String path) } } - @Override - public HttpContext createContext(String path) - { - return createContext(path, null); - } - @Override public void removeContext(String path) throws IllegalArgumentException { diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/DateGenerator.java b/jetty-http/src/main/java/org/eclipse/jetty/http/DateGenerator.java index f37b2cb0ab48..4b0cf79a3f52 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/DateGenerator.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/DateGenerator.java @@ -101,16 +101,16 @@ public String doFormatDate(long date) buf.setLength(0); gc.setTimeInMillis(date); - int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK); - int dayOfMonth = gc.get(Calendar.DAY_OF_MONTH); - int month = gc.get(Calendar.MONTH); - int year = gc.get(Calendar.YEAR); - int century = year / 100; - year = year % 100; + final int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK); + final int dayOfMonth = gc.get(Calendar.DAY_OF_MONTH); + final int month = gc.get(Calendar.MONTH); + final int fullYear = gc.get(Calendar.YEAR); + final int century = fullYear / 100; + final int year = fullYear % 100; - int hours = gc.get(Calendar.HOUR_OF_DAY); - int minutes = gc.get(Calendar.MINUTE); - int seconds = gc.get(Calendar.SECOND); + final int hours = gc.get(Calendar.HOUR_OF_DAY); + final int minutes = gc.get(Calendar.MINUTE); + final int seconds = gc.get(Calendar.SECOND); buf.append(DAYS[dayOfWeek]); buf.append(','); @@ -143,17 +143,17 @@ public void doFormatCookieDate(StringBuilder buf, long date) { gc.setTimeInMillis(date); - int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK); - int dayOfMonth = gc.get(Calendar.DAY_OF_MONTH); - int month = gc.get(Calendar.MONTH); - int year = gc.get(Calendar.YEAR); - year = year % 10000; - - int epoch = (int)((date / 1000) % (60 * 60 * 24)); - int seconds = epoch % 60; - epoch = epoch / 60; - int minutes = epoch % 60; - int hours = epoch / 60; + final int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK); + final int dayOfMonth = gc.get(Calendar.DAY_OF_MONTH); + final int month = gc.get(Calendar.MONTH); + final int fullYear = gc.get(Calendar.YEAR); + final int year = fullYear % 10000; + + final int epochSec = (int)((date / 1000) % (60 * 60 * 24)); + final int seconds = epochSec % 60; + final int epoch = epochSec / 60; + final int minutes = epoch % 60; + final int hours = epoch / 60; buf.append(DAYS[dayOfWeek]); buf.append(','); diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/DateParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/DateParser.java index 3367bb567cfc..073d26d700b9 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/DateParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/DateParser.java @@ -36,19 +36,19 @@ public class DateParser } static final String[] DATE_RECEIVE_FMT = - { - "EEE, dd MMM yyyy HH:mm:ss zzz", - "EEE, dd-MMM-yy HH:mm:ss", - "EEE MMM dd HH:mm:ss yyyy", + { + "EEE, dd MMM yyyy HH:mm:ss zzz", + "EEE, dd-MMM-yy HH:mm:ss", + "EEE MMM dd HH:mm:ss yyyy", - "EEE, dd MMM yyyy HH:mm:ss", "EEE dd MMM yyyy HH:mm:ss zzz", - "EEE dd MMM yyyy HH:mm:ss", "EEE MMM dd yyyy HH:mm:ss zzz", "EEE MMM dd yyyy HH:mm:ss", - "EEE MMM-dd-yyyy HH:mm:ss zzz", "EEE MMM-dd-yyyy HH:mm:ss", "dd MMM yyyy HH:mm:ss zzz", - "dd MMM yyyy HH:mm:ss", "dd-MMM-yy HH:mm:ss zzz", "dd-MMM-yy HH:mm:ss", "MMM dd HH:mm:ss yyyy zzz", - "MMM dd HH:mm:ss yyyy", "EEE MMM dd HH:mm:ss yyyy zzz", - "EEE, MMM dd HH:mm:ss yyyy zzz", "EEE, MMM dd HH:mm:ss yyyy", "EEE, dd-MMM-yy HH:mm:ss zzz", - "EEE dd-MMM-yy HH:mm:ss zzz", "EEE dd-MMM-yy HH:mm:ss" - }; + "EEE, dd MMM yyyy HH:mm:ss", "EEE dd MMM yyyy HH:mm:ss zzz", + "EEE dd MMM yyyy HH:mm:ss", "EEE MMM dd yyyy HH:mm:ss zzz", "EEE MMM dd yyyy HH:mm:ss", + "EEE MMM-dd-yyyy HH:mm:ss zzz", "EEE MMM-dd-yyyy HH:mm:ss", "dd MMM yyyy HH:mm:ss zzz", + "dd MMM yyyy HH:mm:ss", "dd-MMM-yy HH:mm:ss zzz", "dd-MMM-yy HH:mm:ss", "MMM dd HH:mm:ss yyyy zzz", + "MMM dd HH:mm:ss yyyy", "EEE MMM dd HH:mm:ss yyyy zzz", + "EEE, MMM dd HH:mm:ss yyyy zzz", "EEE, MMM dd HH:mm:ss yyyy", "EEE, dd-MMM-yy HH:mm:ss zzz", + "EEE dd-MMM-yy HH:mm:ss zzz", "EEE dd-MMM-yy HH:mm:ss" + }; public static long parseDate(String date) { 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 55d6a4dc5eb4..ba4022b48612 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 @@ -661,6 +661,39 @@ public void add(HttpHeader header, String value) add(field); } + public void add(HttpField field) + { + if (field != null) + { + if (_size == _fields.length) + _fields = Arrays.copyOf(_fields, _size * 2); + _fields[_size++] = field; + } + } + + /** + * Add fields from another HttpFields instance. Single valued fields are replaced, while all + * others are added. + * + * @param fields the fields to add + */ + public void add(HttpFields fields) + { + if (fields == null) + return; + + Enumeration e = fields.getFieldNames(); + while (e.hasMoreElements()) + { + String name = e.nextElement(); + Enumeration values = fields.getValues(name); + while (values.hasMoreElements()) + { + add(name, values.nextElement()); + } + } + } + /** * Remove a field. * @@ -873,16 +906,6 @@ public void clear() _size = 0; } - public void add(HttpField field) - { - if (field != null) - { - if (_size == _fields.length) - _fields = Arrays.copyOf(_fields, _size * 2); - _fields[_size++] = field; - } - } - public void addAll(HttpFields fields) { for (int i = 0; i < fields._size; i++) @@ -891,29 +914,6 @@ public void addAll(HttpFields fields) } } - /** - * Add fields from another HttpFields instance. Single valued fields are replaced, while all - * others are added. - * - * @param fields the fields to add - */ - public void add(HttpFields fields) - { - if (fields == null) - return; - - Enumeration e = fields.getFieldNames(); - while (e.hasMoreElements()) - { - String name = e.nextElement(); - Enumeration values = fields.getValues(name); - while (values.hasMoreElements()) - { - add(name, values.nextElement()); - } - } - } - /** * Get field value without parameters. Some field values can have parameters. This method separates the * value from the parameters and optionally populates a map with the parameters. For example: diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java index 72c9bc8ed4ce..2161ea88c221 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java @@ -171,23 +171,6 @@ public void parse(String uri) parse(State.START, uri); } - /** - * Parse according to https://tools.ietf.org/html/rfc7230#section-5.3 - * - * @param method the request method - * @param uri the request uri - */ - public void parseRequestTarget(String method, String uri) - { - clear(); - _uri = uri; - - if (HttpMethod.CONNECT.is(method)) - _path = uri; - else - parse(uri.startsWith("/") ? State.PATH : State.START, uri); - } - public void parse(String uri, int offset, int length) { clear(); @@ -297,6 +280,9 @@ private void parse(State state, final String uri) _path = uri.substring(mark, i); state = State.FRAGMENT; break; + + default: + break; } continue; } @@ -361,6 +347,9 @@ private void parse(State state, final String uri) case '[': state = State.IPV6; break; + + default: + break; } break; } @@ -385,6 +374,9 @@ private void parse(State state, final String uri) state = State.PATH; } break; + + default: + break; } break; @@ -434,6 +426,9 @@ else if (c == '/') case '.': if ('/' == last) encoded = true; + break; + default: + break; } break; } @@ -463,6 +458,8 @@ else if (c == '/') // multiple parameters mark = i + 1; break; + default: + break; } break; } @@ -489,6 +486,9 @@ else if (c == '/') i = end; break; } + + default: + throw new IllegalStateException(state.toString()); } last = c; } @@ -536,6 +536,9 @@ else if (c == '/') case QUERY: _query = uri.substring(mark, end); break; + + default: + throw new IllegalStateException(state.toString()); } if (!encoded) @@ -547,6 +550,23 @@ else if (c == '/') } } + /** + * Parse according to https://tools.ietf.org/html/rfc7230#section-5.3 + * + * @param method the request method + * @param uri the request uri + */ + public void parseRequestTarget(String method, String uri) + { + clear(); + _uri = uri; + + if (HttpMethod.CONNECT.is(method)) + _path = uri; + else + parse(uri.startsWith("/") ? State.PATH : State.START, uri); + } + public String getScheme() { return _scheme; diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java index 762372ef5cc4..483233846d29 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java @@ -68,15 +68,19 @@ public static HttpVersion lookAheadGet(byte[] bytes, int position, int limit) return HTTP_1_0; case '1': return HTTP_1_1; + default: + return null; } - break; case '2': switch (bytes[position + 7]) { case '0': return HTTP_2; + default: + return null; } - break; + default: + return null; } } diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java b/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java index 4f3bf0b69dfc..08f19690362e 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java @@ -483,14 +483,12 @@ else if (' ' != b) else state = 0; break; - case 8: if ('=' == b) state = 9; else if (' ' != b) state = 0; break; - case 9: if (' ' == b) break; @@ -504,11 +502,13 @@ else if (' ' != b) start = i; state = 10; break; - case 10: if (!quote && (';' == b || ' ' == b) || (quote && '"' == b)) return StringUtil.normalizeCharset(value, start, i - start); + break; + default: + throw new IllegalStateException(); } } @@ -658,7 +658,6 @@ else if (' ' != b) else if (' ' != b) state = 0; break; - case 9: if (' ' == b) break; @@ -666,7 +665,6 @@ else if (' ' != b) builder.append(value, 0, start + 1); state = 10; break; - case 10: if (';' == b) { @@ -677,6 +675,9 @@ else if (' ' != b) case 11: if (' ' != b) builder.append(b); + break; + default: + throw new IllegalStateException(); } } if (builder == null) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java b/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java index 4da3bf443848..2494522e1901 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java @@ -149,6 +149,38 @@ protected void write(byte[] bytes, int offset, int length) throws IOException _size += length; } + @Override + public void write(String fileName) throws IOException + { + if (_file == null) + { + _temporary = false; + + // part data is only in the ByteArrayOutputStream and never been written to disk + _file = new File(_tmpDir, fileName); + + try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_file))) + { + _bout.writeTo(bos); + bos.flush(); + } + finally + { + _bout = null; + } + } + else + { + // the part data is already written to a temporary file, just rename it + _temporary = false; + + Path src = _file.toPath(); + Path target = src.resolveSibling(fileName); + Files.move(src, target, StandardCopyOption.REPLACE_EXISTING); + _file = target.toFile(); + } + } + protected void createFile() throws IOException { /* @@ -248,38 +280,6 @@ public long getSize() return _size; } - @Override - public void write(String fileName) throws IOException - { - if (_file == null) - { - _temporary = false; - - // part data is only in the ByteArrayOutputStream and never been written to disk - _file = new File(_tmpDir, fileName); - - try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(_file))) - { - _bout.writeTo(bos); - bos.flush(); - } - finally - { - _bout = null; - } - } - else - { - // the part data is already written to a temporary file, just rename it - _temporary = false; - - Path src = _file.toPath(); - Path target = src.resolveSibling(fileName); - Files.move(src, target, StandardCopyOption.REPLACE_EXISTING); - _file = target.toFile(); - } - } - /** * Remove the file, whether or not Part.write() was called on it (ie no longer temporary) */ diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/QuotedCSVParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/QuotedCSVParser.java index 3cdf5e5af7c5..b730258fe3f3 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/QuotedCSVParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/QuotedCSVParser.java @@ -133,6 +133,8 @@ public void addValue(String value) if (!_keepQuotes) continue; break; + default: + break; } } @@ -194,7 +196,10 @@ else if (state == State.PARAM_VALUE && paramValue < 0) case PARAM_VALUE: parsedParam(buffer, valueLength, paramName, paramValue); break; + default: + throw new IllegalStateException(state.toString()); } + parsedValueAndParams(buffer); } buffer.setLength(0); @@ -209,9 +214,9 @@ else if (state == State.PARAM_VALUE && paramValue < 0) { case VALUE: // It wasn't really a value, it was a param name - valueLength = paramName = 0; + paramName = 0; buffer.setLength(nwsLength); // trim following OWS - String param = buffer.toString(); + final String param = buffer.toString(); buffer.setLength(0); parsedValue(buffer); valueLength = buffer.length(); @@ -234,8 +239,10 @@ else if (state == State.PARAM_VALUE && paramValue < 0) buffer.append(c); nwsLength = buffer.length(); continue; + + default: + throw new IllegalStateException(state.toString()); } - continue; default: { @@ -265,6 +272,9 @@ else if (state == State.PARAM_VALUE && paramValue < 0) nwsLength = buffer.length(); continue; } + + default: + throw new IllegalStateException(state.toString()); } } } diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java b/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java index 4194b8db83fc..f3c50aaeff37 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java @@ -271,6 +271,8 @@ public boolean remove(PathSpec pathSpec) case SUFFIX_GLOB: _suffixMap.remove(pathSpec.getSuffix()); break; + default: + break; } Iterator> iter = _mappings.iterator(); diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/ServletPathSpec.java b/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/ServletPathSpec.java index cceb6e519f11..aea328cca0a5 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/ServletPathSpec.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/ServletPathSpec.java @@ -241,6 +241,8 @@ else if (servletPathSpec.charAt(0) == '*') case '/': super.pathDepth++; break; + default: + break; } } } diff --git a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java index 10111da82a04..007507a8ee8c 100644 --- a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java +++ b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java @@ -51,24 +51,24 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory @Override public Connection newConnection(EndPoint endPoint, Map context) { - HTTP2Client client = (HTTP2Client)context.get(CLIENT_CONTEXT_KEY); - ByteBufferPool byteBufferPool = client.getByteBufferPool(); - Executor executor = client.getExecutor(); - Scheduler scheduler = client.getScheduler(); - Session.Listener listener = (Session.Listener)context.get(SESSION_LISTENER_CONTEXT_KEY); + final HTTP2Client client = (HTTP2Client)context.get(CLIENT_CONTEXT_KEY); + final ByteBufferPool byteBufferPool = client.getByteBufferPool(); + final Executor executor = client.getExecutor(); + final Scheduler scheduler = client.getScheduler(); + final Session.Listener listener = (Session.Listener)context.get(SESSION_LISTENER_CONTEXT_KEY); @SuppressWarnings("unchecked") - Promise promise = (Promise)context.get(SESSION_PROMISE_CONTEXT_KEY); + final Promise promise = (Promise)context.get(SESSION_PROMISE_CONTEXT_KEY); - Generator generator = new Generator(byteBufferPool); - FlowControlStrategy flowControl = client.getFlowControlStrategyFactory().newFlowControlStrategy(); - HTTP2ClientSession session = new HTTP2ClientSession(scheduler, endPoint, generator, listener, flowControl); + final Generator generator = new Generator(byteBufferPool); + final FlowControlStrategy flowControl = client.getFlowControlStrategyFactory().newFlowControlStrategy(); + final HTTP2ClientSession session = new HTTP2ClientSession(scheduler, endPoint, generator, listener, flowControl); session.setMaxRemoteStreams(client.getMaxConcurrentPushedStreams()); - Parser parser = new Parser(byteBufferPool, session, 4096, 8192); + final Parser parser = new Parser(byteBufferPool, session, 4096, 8192); parser.setMaxFrameLength(client.getMaxFrameLength()); parser.setMaxSettingsKeys(client.getMaxSettingsKeys()); - HTTP2ClientConnection connection = new HTTP2ClientConnection(client, byteBufferPool, executor, endPoint, + final HTTP2ClientConnection connection = new HTTP2ClientConnection(client, byteBufferPool, executor, endPoint, parser, session, client.getInputBufferSize(), promise, listener); connection.addListener(connectionListener); return customize(connection, context); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Cipher.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Cipher.java index 5936d2462799..8d8d33797717 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Cipher.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Cipher.java @@ -39,284 +39,284 @@ public class HTTP2Cipher } String[] ciphers = - { - "TLS_NULL_WITH_NULL_NULL", - "TLS_RSA_WITH_NULL_MD5", - "TLS_RSA_WITH_NULL_SHA", - "TLS_RSA_EXPORT_WITH_RC4_40_MD5", - "TLS_RSA_WITH_RC4_128_MD5", - "TLS_RSA_WITH_RC4_128_SHA", - "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", - "TLS_RSA_WITH_IDEA_CBC_SHA", - "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", - "TLS_RSA_WITH_DES_CBC_SHA", - "TLS_RSA_WITH_3DES_EDE_CBC_SHA", - "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", - "TLS_DH_DSS_WITH_DES_CBC_SHA", - "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA", - "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", - "TLS_DH_RSA_WITH_DES_CBC_SHA", - "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA", - "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", - "TLS_DHE_DSS_WITH_DES_CBC_SHA", - "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA", - "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", - "TLS_DHE_RSA_WITH_DES_CBC_SHA", - "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA", - "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5", - "TLS_DH_anon_WITH_RC4_128_MD5", - "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA", - "TLS_DH_anon_WITH_DES_CBC_SHA", - "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA", - "TLS_KRB5_WITH_DES_CBC_SHA", - "TLS_KRB5_WITH_3DES_EDE_CBC_SHA", - "TLS_KRB5_WITH_RC4_128_SHA", - "TLS_KRB5_WITH_IDEA_CBC_SHA", - "TLS_KRB5_WITH_DES_CBC_MD5", - "TLS_KRB5_WITH_3DES_EDE_CBC_MD5", - "TLS_KRB5_WITH_RC4_128_MD5", - "TLS_KRB5_WITH_IDEA_CBC_MD5", - "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", - "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA", - "TLS_KRB5_EXPORT_WITH_RC4_40_SHA", - "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", - "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5", - "TLS_KRB5_EXPORT_WITH_RC4_40_MD5", - "TLS_PSK_WITH_NULL_SHA", - "TLS_DHE_PSK_WITH_NULL_SHA", - "TLS_RSA_PSK_WITH_NULL_SHA", - "TLS_RSA_WITH_AES_128_CBC_SHA", - "TLS_DH_DSS_WITH_AES_128_CBC_SHA", - "TLS_DH_RSA_WITH_AES_128_CBC_SHA", - "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_DH_anon_WITH_AES_128_CBC_SHA", - "TLS_RSA_WITH_AES_256_CBC_SHA", - "TLS_DH_DSS_WITH_AES_256_CBC_SHA", - "TLS_DH_RSA_WITH_AES_256_CBC_SHA", - "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_DH_anon_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_NULL_SHA256", - "TLS_RSA_WITH_AES_128_CBC_SHA256", - "TLS_RSA_WITH_AES_256_CBC_SHA256", - "TLS_DH_DSS_WITH_AES_128_CBC_SHA256", - "TLS_DH_RSA_WITH_AES_128_CBC_SHA256", - "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", - "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA", - "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA", - "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA", - "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", - "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", - "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA", - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", - "TLS_DH_DSS_WITH_AES_256_CBC_SHA256", - "TLS_DH_RSA_WITH_AES_256_CBC_SHA256", - "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", - "TLS_DH_anon_WITH_AES_128_CBC_SHA256", - "TLS_DH_anon_WITH_AES_256_CBC_SHA256", - "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA", - "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA", - "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA", - "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", - "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", - "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA", - "TLS_PSK_WITH_RC4_128_SHA", - "TLS_PSK_WITH_3DES_EDE_CBC_SHA", - "TLS_PSK_WITH_AES_128_CBC_SHA", - "TLS_PSK_WITH_AES_256_CBC_SHA", - "TLS_DHE_PSK_WITH_RC4_128_SHA", - "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA", - "TLS_DHE_PSK_WITH_AES_128_CBC_SHA", - "TLS_DHE_PSK_WITH_AES_256_CBC_SHA", - "TLS_RSA_PSK_WITH_RC4_128_SHA", - "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA", - "TLS_RSA_PSK_WITH_AES_128_CBC_SHA", - "TLS_RSA_PSK_WITH_AES_256_CBC_SHA", - "TLS_RSA_WITH_SEED_CBC_SHA", - "TLS_DH_DSS_WITH_SEED_CBC_SHA", - "TLS_DH_RSA_WITH_SEED_CBC_SHA", - "TLS_DHE_DSS_WITH_SEED_CBC_SHA", - "TLS_DHE_RSA_WITH_SEED_CBC_SHA", - "TLS_DH_anon_WITH_SEED_CBC_SHA", - "TLS_RSA_WITH_AES_128_GCM_SHA256", - "TLS_RSA_WITH_AES_256_GCM_SHA384", - "TLS_DH_RSA_WITH_AES_128_GCM_SHA256", - "TLS_DH_RSA_WITH_AES_256_GCM_SHA384", - "TLS_DH_DSS_WITH_AES_128_GCM_SHA256", - "TLS_DH_DSS_WITH_AES_256_GCM_SHA384", - "TLS_DH_anon_WITH_AES_128_GCM_SHA256", - "TLS_DH_anon_WITH_AES_256_GCM_SHA384", - "TLS_PSK_WITH_AES_128_GCM_SHA256", - "TLS_PSK_WITH_AES_256_GCM_SHA384", - "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256", - "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384", - "TLS_PSK_WITH_AES_128_CBC_SHA256", - "TLS_PSK_WITH_AES_256_CBC_SHA384", - "TLS_PSK_WITH_NULL_SHA256", - "TLS_PSK_WITH_NULL_SHA384", - "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256", - "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384", - "TLS_DHE_PSK_WITH_NULL_SHA256", - "TLS_DHE_PSK_WITH_NULL_SHA384", - "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256", - "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384", - "TLS_RSA_PSK_WITH_NULL_SHA256", - "TLS_RSA_PSK_WITH_NULL_SHA384", - "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256", - "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256", - "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256", - "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256", - "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256", - "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256", - "TLS_EMPTY_RENEGOTIATION_INFO_SCSV", - "TLS_ECDH_ECDSA_WITH_NULL_SHA", - "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", - "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", - "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", - "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_ECDSA_WITH_NULL_SHA", - "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", - "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", - "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", - "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", - "TLS_ECDH_RSA_WITH_NULL_SHA", - "TLS_ECDH_RSA_WITH_RC4_128_SHA", - "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", - "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", - "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_NULL_SHA", - "TLS_ECDHE_RSA_WITH_RC4_128_SHA", - "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDH_anon_WITH_NULL_SHA", - "TLS_ECDH_anon_WITH_RC4_128_SHA", - "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", - "TLS_ECDH_anon_WITH_AES_128_CBC_SHA", - "TLS_ECDH_anon_WITH_AES_256_CBC_SHA", - "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA", - "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA", - "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA", - "TLS_SRP_SHA_WITH_AES_128_CBC_SHA", - "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA", - "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA", - "TLS_SRP_SHA_WITH_AES_256_CBC_SHA", - "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA", - "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", - "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", - "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", - "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", - "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", - "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", - "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", - "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", - "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", - "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", - "TLS_ECDHE_PSK_WITH_RC4_128_SHA", - "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA", - "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", - "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256", - "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384", - "TLS_ECDHE_PSK_WITH_NULL_SHA", - "TLS_ECDHE_PSK_WITH_NULL_SHA256", - "TLS_ECDHE_PSK_WITH_NULL_SHA384", - "TLS_RSA_WITH_ARIA_128_CBC_SHA256", - "TLS_RSA_WITH_ARIA_256_CBC_SHA384", - "TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256", - "TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384", - "TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256", - "TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384", - "TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256", - "TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384", - "TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256", - "TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384", - "TLS_DH_anon_WITH_ARIA_128_CBC_SHA256", - "TLS_DH_anon_WITH_ARIA_256_CBC_SHA384", - "TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256", - "TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384", - "TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256", - "TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384", - "TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256", - "TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384", - "TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256", - "TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384", - "TLS_RSA_WITH_ARIA_128_GCM_SHA256", - "TLS_RSA_WITH_ARIA_256_GCM_SHA384", - "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256", - "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384", - "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256", - "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384", - "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256", - "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384", - "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256", - "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384", - "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256", - "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384", - "TLS_PSK_WITH_ARIA_128_CBC_SHA256", - "TLS_PSK_WITH_ARIA_256_CBC_SHA384", - "TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256", - "TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384", - "TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256", - "TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384", - "TLS_PSK_WITH_ARIA_128_GCM_SHA256", - "TLS_PSK_WITH_ARIA_256_GCM_SHA384", - "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256", - "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384", - "TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256", - "TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384", - "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256", - "TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384", - "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256", - "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384", - "TLS_RSA_WITH_AES_128_CCM", - "TLS_RSA_WITH_AES_256_CCM", - "TLS_RSA_WITH_AES_128_CCM_8", - "TLS_RSA_WITH_AES_256_CCM_8", - "TLS_PSK_WITH_AES_128_CCM", - "TLS_PSK_WITH_AES_256_CCM", - "TLS_PSK_WITH_AES_128_CCM_8", - "TLS_PSK_WITH_AES_256_CCM_8" - }; + { + "TLS_NULL_WITH_NULL_NULL", + "TLS_RSA_WITH_NULL_MD5", + "TLS_RSA_WITH_NULL_SHA", + "TLS_RSA_EXPORT_WITH_RC4_40_MD5", + "TLS_RSA_WITH_RC4_128_MD5", + "TLS_RSA_WITH_RC4_128_SHA", + "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", + "TLS_RSA_WITH_IDEA_CBC_SHA", + "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", + "TLS_RSA_WITH_DES_CBC_SHA", + "TLS_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", + "TLS_DH_DSS_WITH_DES_CBC_SHA", + "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA", + "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", + "TLS_DH_RSA_WITH_DES_CBC_SHA", + "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", + "TLS_DHE_DSS_WITH_DES_CBC_SHA", + "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA", + "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", + "TLS_DHE_RSA_WITH_DES_CBC_SHA", + "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5", + "TLS_DH_anon_WITH_RC4_128_MD5", + "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA", + "TLS_DH_anon_WITH_DES_CBC_SHA", + "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA", + "TLS_KRB5_WITH_DES_CBC_SHA", + "TLS_KRB5_WITH_3DES_EDE_CBC_SHA", + "TLS_KRB5_WITH_RC4_128_SHA", + "TLS_KRB5_WITH_IDEA_CBC_SHA", + "TLS_KRB5_WITH_DES_CBC_MD5", + "TLS_KRB5_WITH_3DES_EDE_CBC_MD5", + "TLS_KRB5_WITH_RC4_128_MD5", + "TLS_KRB5_WITH_IDEA_CBC_MD5", + "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", + "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA", + "TLS_KRB5_EXPORT_WITH_RC4_40_SHA", + "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", + "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5", + "TLS_KRB5_EXPORT_WITH_RC4_40_MD5", + "TLS_PSK_WITH_NULL_SHA", + "TLS_DHE_PSK_WITH_NULL_SHA", + "TLS_RSA_PSK_WITH_NULL_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA", + "TLS_DH_DSS_WITH_AES_128_CBC_SHA", + "TLS_DH_RSA_WITH_AES_128_CBC_SHA", + "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_DH_anon_WITH_AES_128_CBC_SHA", + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_DH_DSS_WITH_AES_256_CBC_SHA", + "TLS_DH_RSA_WITH_AES_256_CBC_SHA", + "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_DH_anon_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_NULL_SHA256", + "TLS_RSA_WITH_AES_128_CBC_SHA256", + "TLS_RSA_WITH_AES_256_CBC_SHA256", + "TLS_DH_DSS_WITH_AES_128_CBC_SHA256", + "TLS_DH_RSA_WITH_AES_128_CBC_SHA256", + "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", + "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA", + "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA", + "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA", + "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", + "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", + "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA", + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", + "TLS_DH_DSS_WITH_AES_256_CBC_SHA256", + "TLS_DH_RSA_WITH_AES_256_CBC_SHA256", + "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", + "TLS_DH_anon_WITH_AES_128_CBC_SHA256", + "TLS_DH_anon_WITH_AES_256_CBC_SHA256", + "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA", + "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA", + "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA", + "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", + "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", + "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA", + "TLS_PSK_WITH_RC4_128_SHA", + "TLS_PSK_WITH_3DES_EDE_CBC_SHA", + "TLS_PSK_WITH_AES_128_CBC_SHA", + "TLS_PSK_WITH_AES_256_CBC_SHA", + "TLS_DHE_PSK_WITH_RC4_128_SHA", + "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA", + "TLS_DHE_PSK_WITH_AES_128_CBC_SHA", + "TLS_DHE_PSK_WITH_AES_256_CBC_SHA", + "TLS_RSA_PSK_WITH_RC4_128_SHA", + "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA", + "TLS_RSA_PSK_WITH_AES_128_CBC_SHA", + "TLS_RSA_PSK_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_SEED_CBC_SHA", + "TLS_DH_DSS_WITH_SEED_CBC_SHA", + "TLS_DH_RSA_WITH_SEED_CBC_SHA", + "TLS_DHE_DSS_WITH_SEED_CBC_SHA", + "TLS_DHE_RSA_WITH_SEED_CBC_SHA", + "TLS_DH_anon_WITH_SEED_CBC_SHA", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_DH_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DH_RSA_WITH_AES_256_GCM_SHA384", + "TLS_DH_DSS_WITH_AES_128_GCM_SHA256", + "TLS_DH_DSS_WITH_AES_256_GCM_SHA384", + "TLS_DH_anon_WITH_AES_128_GCM_SHA256", + "TLS_DH_anon_WITH_AES_256_GCM_SHA384", + "TLS_PSK_WITH_AES_128_GCM_SHA256", + "TLS_PSK_WITH_AES_256_GCM_SHA384", + "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256", + "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384", + "TLS_PSK_WITH_AES_128_CBC_SHA256", + "TLS_PSK_WITH_AES_256_CBC_SHA384", + "TLS_PSK_WITH_NULL_SHA256", + "TLS_PSK_WITH_NULL_SHA384", + "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256", + "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384", + "TLS_DHE_PSK_WITH_NULL_SHA256", + "TLS_DHE_PSK_WITH_NULL_SHA384", + "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256", + "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384", + "TLS_RSA_PSK_WITH_NULL_SHA256", + "TLS_RSA_PSK_WITH_NULL_SHA384", + "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256", + "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256", + "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256", + "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256", + "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256", + "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256", + "TLS_EMPTY_RENEGOTIATION_INFO_SCSV", + "TLS_ECDH_ECDSA_WITH_NULL_SHA", + "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", + "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", + "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_NULL_SHA", + "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", + "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDH_RSA_WITH_NULL_SHA", + "TLS_ECDH_RSA_WITH_RC4_128_SHA", + "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_NULL_SHA", + "TLS_ECDHE_RSA_WITH_RC4_128_SHA", + "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDH_anon_WITH_NULL_SHA", + "TLS_ECDH_anon_WITH_RC4_128_SHA", + "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDH_anon_WITH_AES_128_CBC_SHA", + "TLS_ECDH_anon_WITH_AES_256_CBC_SHA", + "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA", + "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA", + "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA", + "TLS_SRP_SHA_WITH_AES_128_CBC_SHA", + "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA", + "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA", + "TLS_SRP_SHA_WITH_AES_256_CBC_SHA", + "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA", + "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", + "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", + "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_PSK_WITH_RC4_128_SHA", + "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", + "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256", + "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_PSK_WITH_NULL_SHA", + "TLS_ECDHE_PSK_WITH_NULL_SHA256", + "TLS_ECDHE_PSK_WITH_NULL_SHA384", + "TLS_RSA_WITH_ARIA_128_CBC_SHA256", + "TLS_RSA_WITH_ARIA_256_CBC_SHA384", + "TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256", + "TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384", + "TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256", + "TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384", + "TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256", + "TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384", + "TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256", + "TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384", + "TLS_DH_anon_WITH_ARIA_128_CBC_SHA256", + "TLS_DH_anon_WITH_ARIA_256_CBC_SHA384", + "TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256", + "TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384", + "TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256", + "TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384", + "TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256", + "TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384", + "TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256", + "TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384", + "TLS_RSA_WITH_ARIA_128_GCM_SHA256", + "TLS_RSA_WITH_ARIA_256_GCM_SHA384", + "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256", + "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384", + "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256", + "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384", + "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256", + "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384", + "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256", + "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384", + "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256", + "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384", + "TLS_PSK_WITH_ARIA_128_CBC_SHA256", + "TLS_PSK_WITH_ARIA_256_CBC_SHA384", + "TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256", + "TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384", + "TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256", + "TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384", + "TLS_PSK_WITH_ARIA_128_GCM_SHA256", + "TLS_PSK_WITH_ARIA_256_GCM_SHA384", + "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256", + "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384", + "TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256", + "TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384", + "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256", + "TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384", + "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256", + "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384", + "TLS_RSA_WITH_AES_128_CCM", + "TLS_RSA_WITH_AES_256_CCM", + "TLS_RSA_WITH_AES_128_CCM_8", + "TLS_RSA_WITH_AES_256_CCM_8", + "TLS_PSK_WITH_AES_128_CCM", + "TLS_PSK_WITH_AES_256_CCM", + "TLS_PSK_WITH_AES_128_CCM_8", + "TLS_PSK_WITH_AES_256_CCM_8" + }; for (String c : ciphers) { __blackCiphers.put(c, Boolean.TRUE); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java index 5a6ba2bed13b..2e1238c17314 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java @@ -163,6 +163,14 @@ protected void offerTask(Runnable task, boolean dispatch) produce(); } + private void offerTask(Runnable task) + { + synchronized (this) + { + tasks.offer(task); + } + } + protected void produce() { if (LOG.isDebugEnabled()) @@ -185,14 +193,6 @@ public void close() session.close(ErrorCode.NO_ERROR.code, "close", Callback.NOOP); } - private void offerTask(Runnable task) - { - synchronized (this) - { - tasks.offer(task); - } - } - private Runnable pollTask() { synchronized (this) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java index 770f1d07f286..1ffafe920653 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java @@ -504,6 +504,21 @@ public void onWindowUpdate(WindowUpdateFrame frame) } } + @Override + public void onWindowUpdate(IStream stream, WindowUpdateFrame frame) + { + // WindowUpdateFrames arrive concurrently with writes. + // Increasing (or reducing) the window size concurrently + // with writes requires coordination with the flusher, that + // decides how many frames to write depending on the available + // window sizes. If the window sizes vary concurrently, the + // flusher may take non-optimal or wrong decisions. + // Here, we "queue" window updates to the flusher, so it will + // be the only component responsible for window updates, for + // both increments and reductions. + flusher.window(stream, frame); + } + @Override public void onStreamFailure(int streamId, int error, String reason) { @@ -574,6 +589,11 @@ public void newStream(HeadersFrame frame, Promise promise, Stream.Listen } } + protected IStream newStream(int streamId, boolean local) + { + return new HTTP2Stream(scheduler, this, streamId, local); + } + @Override public int priority(PriorityFrame frame, Callback callback) { @@ -833,11 +853,6 @@ void updateStreamCount(boolean local, int deltaStreams, int deltaClosing) remoteStreamCount.add(deltaStreams, deltaClosing); } - protected IStream newStream(int streamId, boolean local) - { - return new HTTP2Stream(scheduler, this, streamId, local); - } - @Override public void removeStream(IStream stream) { @@ -893,21 +908,6 @@ public int updateRecvWindow(int delta) return recvWindow.getAndAdd(delta); } - @Override - public void onWindowUpdate(IStream stream, WindowUpdateFrame frame) - { - // WindowUpdateFrames arrive concurrently with writes. - // Increasing (or reducing) the window size concurrently - // with writes requires coordination with the flusher, that - // decides how many frames to write depending on the available - // window sizes. If the window sizes vary concurrently, the - // flusher may take non-optimal or wrong decisions. - // Here, we "queue" window updates to the flusher, so it will - // be the only component responsible for window updates, for - // both increments and reductions. - flusher.window(stream, frame); - } - @Override @ManagedAttribute(value = "Whether HTTP/2 push is enabled", readonly = true) public boolean isPushEnabled() diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/SimpleFlowControlStrategy.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/SimpleFlowControlStrategy.java index e8ba053ef634..430a79b1fe34 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/SimpleFlowControlStrategy.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/SimpleFlowControlStrategy.java @@ -44,7 +44,7 @@ public void onDataConsumed(ISession session, IStream stream, int length) // This method is called when a whole flow controlled frame has been consumed. // We send a WindowUpdate every time, even if the frame was very small. - WindowUpdateFrame sessionFrame = new WindowUpdateFrame(0, length); + final WindowUpdateFrame sessionFrame = new WindowUpdateFrame(0, length); session.updateRecvWindow(length); if (LOG.isDebugEnabled()) LOG.debug("Data consumed, increased session recv window by {} for {}", length, session); diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java index bc3b244c8d07..eaa17a53ee41 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java @@ -217,15 +217,6 @@ else if (metadata.isResponse()) LOG.debug(String.format("CtxTbl[%x] encoded %d octets", _context.hashCode(), buffer.position() - pos)); } - public void encodeMaxDynamicTableSize(ByteBuffer buffer, int maxDynamicTableSize) - { - if (maxDynamicTableSize > _remoteMaxDynamicTableSize) - throw new IllegalArgumentException(); - buffer.put((byte)0x20); - NBitInteger.encode(buffer, 5, maxDynamicTableSize); - _context.resize(maxDynamicTableSize); - } - public void encode(ByteBuffer buffer, HttpField field) { if (field.getValue() == null) @@ -369,6 +360,15 @@ else if (fieldSize >= _context.getMaxDynamicTableSize() || header == HttpHeader. } } + public void encodeMaxDynamicTableSize(ByteBuffer buffer, int maxDynamicTableSize) + { + if (maxDynamicTableSize > _remoteMaxDynamicTableSize) + throw new IllegalArgumentException(); + buffer.put((byte)0x20); + NBitInteger.encode(buffer, 5, maxDynamicTableSize); + _context.resize(maxDynamicTableSize); + } + private void encodeName(ByteBuffer buffer, byte mask, int bits, String name, Entry entry) { buffer.put(mask); diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/Huffman.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/Huffman.java index 38aff6f8d68d..0bbe4f661d49 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/Huffman.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/Huffman.java @@ -422,16 +422,6 @@ public static String decode(ByteBuffer buffer, int length) throws HpackException return out.toString(); } - public static int octetsNeeded(String s) - { - return octetsNeeded(CODES, s); - } - - public static void encode(ByteBuffer buffer, String s) - { - encode(CODES, buffer, s); - } - public static int octetsNeededLC(String s) { return octetsNeeded(LCCODES, s); @@ -442,6 +432,11 @@ public static void encodeLC(ByteBuffer buffer, String s) encode(LCCODES, buffer, s); } + public static int octetsNeeded(String s) + { + return octetsNeeded(CODES, s); + } + private static int octetsNeeded(final int[][] table, String s) { int needed = 0; @@ -457,6 +452,11 @@ private static int octetsNeeded(final int[][] table, String s) return (needed + 7) / 8; } + public static void encode(ByteBuffer buffer, String s) + { + encode(CODES, buffer, s); + } + private static void encode(final int[][] table, ByteBuffer buffer, String s) { long current = 0; diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java index 22689d7af768..7e45753e5c0a 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java @@ -113,6 +113,12 @@ public boolean onIdleTimeout(Session session) return getConnection().onSessionTimeout(new TimeoutException("Session idle timeout " + idleTimeout + " ms")); } + @Override + public boolean onIdleTimeout(Stream stream, Throwable x) + { + return getConnection().onStreamTimeout((IStream)stream, x); + } + @Override public void onClose(Session session, GoAwayFrame frame, Callback callback) { @@ -128,6 +134,12 @@ public void onFailure(Session session, Throwable failure, Callback callback) getConnection().onSessionFailure(failure, callback); } + @Override + public void onFailure(Stream stream, int error, String reason, Callback callback) + { + getConnection().onStreamFailure((IStream)stream, new EofException(String.format("Failure %s/%s", ErrorCode.toString(error, null), reason)), callback); + } + @Override public void onHeaders(Stream stream, HeadersFrame frame) { @@ -157,18 +169,6 @@ public void onReset(Stream stream, ResetFrame frame, Callback callback) getConnection().onStreamFailure((IStream)stream, new EofException("Reset " + ErrorCode.toString(frame.getError(), null)), callback); } - @Override - public void onFailure(Stream stream, int error, String reason, Callback callback) - { - getConnection().onStreamFailure((IStream)stream, new EofException(String.format("Failure %s/%s", ErrorCode.toString(error, null), reason)), callback); - } - - @Override - public boolean onIdleTimeout(Stream stream, Throwable x) - { - return getConnection().onStreamTimeout((IStream)stream, x); - } - private void close(Stream stream, String reason) { stream.getSession().close(ErrorCode.PROTOCOL_ERROR.code, reason, Callback.NOOP); diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java index 73919eb6500e..617025a5465b 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java @@ -300,7 +300,7 @@ public boolean isRequestIdle() public boolean onStreamTimeout(Throwable failure, Consumer consumer) { - boolean delayed = _delayedUntilContent; + final boolean delayed = _delayedUntilContent; _delayedUntilContent = false; boolean result = isRequestIdle(); diff --git a/jetty-infinispan/infinispan-common/src/main/java/org/eclipse/jetty/session/infinispan/SessionDataMarshaller.java b/jetty-infinispan/infinispan-common/src/main/java/org/eclipse/jetty/session/infinispan/SessionDataMarshaller.java index 7a16fcf12654..27f98672ddbc 100644 --- a/jetty-infinispan/infinispan-common/src/main/java/org/eclipse/jetty/session/infinispan/SessionDataMarshaller.java +++ b/jetty-infinispan/infinispan-common/src/main/java/org/eclipse/jetty/session/infinispan/SessionDataMarshaller.java @@ -52,20 +52,20 @@ public String getTypeName() @Override public InfinispanSessionData readFrom(ProtoStreamReader in) throws IOException { - int version = in.readInt("version");// version of serialized session - String id = in.readString("id"); // session id - String cpath = in.readString("contextPath"); // context path - String vhost = in.readString("vhost"); // first vhost + final int version = in.readInt("version");// version of serialized session + final String id = in.readString("id"); // session id + final String cpath = in.readString("contextPath"); // context path + final String vhost = in.readString("vhost"); // first vhost - long accessed = in.readLong("accessed");// accessTime - long lastAccessed = in.readLong("lastAccessed"); // lastAccessTime - long created = in.readLong("created"); // time created - long cookieSet = in.readLong("cookieSet");// time cookie was set - String lastNode = in.readString("lastNode"); // name of last node + final long accessed = in.readLong("accessed");// accessTime + final long lastAccessed = in.readLong("lastAccessed"); // lastAccessTime + final long created = in.readLong("created"); // time created + final long cookieSet = in.readLong("cookieSet");// time cookie was set + final String lastNode = in.readString("lastNode"); // name of last node // managing - long expiry = in.readLong("expiry"); - long maxInactiveMs = in.readLong("maxInactiveMs"); + final long expiry = in.readLong("expiry"); + final long maxInactiveMs = in.readLong("maxInactiveMs"); InfinispanSessionData sd = new InfinispanSessionData(id, cpath, vhost, created, accessed, lastAccessed, maxInactiveMs); sd.setCookieSet(cookieSet); 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 4a06932e70aa..74ba6f0ed52a 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 @@ -117,6 +117,10 @@ protected void failedCallback(final Callback callback, final Throwable x) case EITHER: Invocable.invokeNonBlocking(failCallback); + break; + + default: + throw new IllegalStateException(); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java index 892105df9604..7e926856c046 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java @@ -109,6 +109,9 @@ protected final void shutdownInput() case CLOSED: // already closed return; + + default: + throw new IllegalStateException(s.toString()); } } } @@ -163,6 +166,9 @@ public final void shutdownOutput() case CLOSED: // already closed return; + + default: + throw new IllegalStateException(s.toString()); } } } @@ -201,6 +207,9 @@ public final void close(Throwable failure) case CLOSED: // already closed return; + + default: + throw new IllegalStateException(s.toString()); } } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java index 542365364d7e..14948563718b 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java @@ -225,6 +225,16 @@ public void addInput(ByteBuffer in) _runFillable.run(); } + public void addInput(String s) + { + addInput(BufferUtil.toBuffer(s, StandardCharsets.UTF_8)); + } + + public void addInput(String s, Charset charset) + { + addInput(BufferUtil.toBuffer(s, charset)); + } + public void addInputAndExecute(ByteBuffer in) { boolean fillable = false; @@ -248,16 +258,6 @@ public void addInputAndExecute(ByteBuffer in) execute(_runFillable); } - public void addInput(String s) - { - addInput(BufferUtil.toBuffer(s, StandardCharsets.UTF_8)); - } - - public void addInput(String s, Charset charset) - { - addInput(BufferUtil.toBuffer(s, charset)); - } - /** * @return Returns the out. */ diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index e23ca67b078a..da76d773ed90 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -323,8 +323,8 @@ public void dump(Appendable out, String indent) throws IOException Selector selector = _selector; if (selector != null && selector.isOpen()) { - DumpKeys dump = new DumpKeys(); - String updatesAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()); + final DumpKeys dump = new DumpKeys(); + final String updatesAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()); synchronized (ManagedSelector.this) { updates = new ArrayList<>(_updates); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java index 29abac57e686..4115e471a77f 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java @@ -253,6 +253,11 @@ protected ManagedSelector newSelector(int id) return new ManagedSelector(this, id); } + protected Selector newSelector() throws IOException + { + return Selector.open(); + } + @Override protected void doStop() throws Exception { @@ -359,11 +364,6 @@ protected void connectionFailed(SelectableChannel channel, Throwable ex, Object LOG.warn(String.format("%s - %s", channel, attachment), ex); } - protected Selector newSelector() throws IOException - { - return Selector.open(); - } - /** *

Factory method to create {@link EndPoint}.

*

This method is invoked as a result of the registration of a channel via {@link #connect(SelectableChannel, Object)} diff --git a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java index f428515238ea..1b56e592633f 100644 --- a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java +++ b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java @@ -81,6 +81,9 @@ public Principal getPrincipal() return this.principal; } + /** + * @param subject The subject + */ public void setJAASInfo(Subject subject) { subject.getPrincipals().add(this.principal); @@ -91,6 +94,9 @@ public void setJAASInfo(Subject subject) subject.getPrincipals().addAll(roles); } + /** + * @param subject The subject + */ public void unsetJAASInfo(Subject subject) { subject.getPrincipals().remove(this.principal); diff --git a/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticator.java b/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticator.java index 3ee6dc1836ab..122a980edfd0 100644 --- a/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticator.java +++ b/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticator.java @@ -94,30 +94,6 @@ public String getAuthMethod() return "JASPI"; } - @Override - public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException - { - JaspiMessageInfo info = new JaspiMessageInfo(request, response, mandatory); - request.setAttribute("org.eclipse.jetty.security.jaspi.info", info); - - Authentication a = validateRequest(info); - - //if its not mandatory to authenticate, and the authenticator returned UNAUTHENTICATED, we treat it as authentication deferred - if (_allowLazyAuthentication && !info.isAuthMandatory() && a == Authentication.UNAUTHENTICATED) - a = new DeferredAuthentication(this); - return a; - } - - // most likely validatedUser is not needed here. - @Override - public boolean secureResponse(ServletRequest req, ServletResponse res, boolean mandatory, User validatedUser) throws ServerAuthException - { - JaspiMessageInfo info = (JaspiMessageInfo)req.getAttribute("org.eclipse.jetty.security.jaspi.info"); - if (info == null) - throw new NullPointerException("MessageInfo from request missing: " + req); - return secureResponse(info, validatedUser); - } - /** * @see org.eclipse.jetty.security.authentication.LoginAuthenticator#login(java.lang.String, java.lang.Object, javax.servlet.ServletRequest) */ @@ -138,6 +114,20 @@ public UserIdentity login(String username, Object password, ServletRequest reque return user; } + @Override + public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException + { + JaspiMessageInfo info = new JaspiMessageInfo(request, response, mandatory); + request.setAttribute("org.eclipse.jetty.security.jaspi.info", info); + + Authentication a = validateRequest(info); + + //if its not mandatory to authenticate, and the authenticator returned UNAUTHENTICATED, we treat it as authentication deferred + if (_allowLazyAuthentication && !info.isAuthMandatory() && a == Authentication.UNAUTHENTICATED) + a = new DeferredAuthentication(this); + return a; + } + public Authentication validateRequest(JaspiMessageInfo messageInfo) throws ServerAuthException { try @@ -218,6 +208,16 @@ public Authentication validateRequest(JaspiMessageInfo messageInfo) throws Serve } } + // most likely validatedUser is not needed here. + @Override + public boolean secureResponse(ServletRequest req, ServletResponse res, boolean mandatory, User validatedUser) throws ServerAuthException + { + JaspiMessageInfo info = (JaspiMessageInfo)req.getAttribute("org.eclipse.jetty.security.jaspi.info"); + if (info == null) + throw new NullPointerException("MessageInfo from request missing: " + req); + return secureResponse(info, validatedUser); + } + public boolean secureResponse(JaspiMessageInfo messageInfo, Authentication validatedUser) throws ServerAuthException { try diff --git a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MetaData.java b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MetaData.java index 9519932eeb92..6a12bf17338e 100644 --- a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MetaData.java +++ b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MetaData.java @@ -91,6 +91,21 @@ else if (_parent != null) return mbean; } + private static Object newInstance(Constructor constructor, Object bean) + { + try + { + Object mbean = constructor.getParameterCount() == 0 ? constructor.newInstance() : constructor.newInstance(bean); + if (mbean instanceof ModelMBean) + ((ModelMBean)mbean).setManagedResource(bean, "objectReference"); + return mbean; + } + catch (Throwable x) + { + return null; + } + } + MBeanInfo getMBeanInfo() { return _info; @@ -175,21 +190,6 @@ private OperationInfo findOperation(String signature) return result; } - private static Object newInstance(Constructor constructor, Object bean) - { - try - { - Object mbean = constructor.getParameterCount() == 0 ? constructor.newInstance() : constructor.newInstance(bean); - if (mbean instanceof ModelMBean) - ((ModelMBean)mbean).setManagedResource(bean, "objectReference"); - return mbean; - } - catch (Throwable x) - { - return null; - } - } - private void parseMethods(Class... classes) { for (Class klass : classes) diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java index 5e1226346638..cd255b6962cf 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java @@ -243,7 +243,7 @@ public void startJetty() throws MojoExecutionException webApp.start(); //just enough to generate the quickstart //save config of the webapp BEFORE we stop - File props = prepareConfiguration(); + final File props = prepareConfiguration(); webApp.stop(); diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/OverlayConfig.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/OverlayConfig.java index 364835925be2..fe7dd6d9af5a 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/OverlayConfig.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/OverlayConfig.java @@ -112,6 +112,8 @@ public OverlayConfig(String fmt, List defaultIncludes, List defa excludes = Arrays.asList(exs); break; } + default: + break; } } } diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java index f44cdd0ad88a..a097fc68c57d 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java @@ -449,7 +449,7 @@ public void initialize(SessionContext context) throws Exception public void doStore(String id, SessionData data, long lastSaveTime) throws Exception { // Form query for upsert - BasicDBObject key = new BasicDBObject(__ID, id); + final BasicDBObject key = new BasicDBObject(__ID, id); // Form updates BasicDBObject update = new BasicDBObject(); diff --git a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/ContainerTldBundleDiscoverer.java b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/ContainerTldBundleDiscoverer.java index 23a2de9ee8c5..89173c4c0818 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/ContainerTldBundleDiscoverer.java +++ b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/ContainerTldBundleDiscoverer.java @@ -95,7 +95,7 @@ public URL[] getUrlsForBundlesWithTlds(DeploymentManager deploymentManager, Bund if (jstlBundle == null) jstlBundle = findJstlBundle(); - Bundle[] bundles = FrameworkUtil.getBundle(ContainerTldBundleDiscoverer.class).getBundleContext().getBundles(); + final Bundle[] bundles = FrameworkUtil.getBundle(ContainerTldBundleDiscoverer.class).getBundleContext().getBundles(); HashSet urls = new HashSet(); String tmp = System.getProperty(OSGiMetaInfConfiguration.SYS_PROP_TLD_BUNDLES); //comma separated exact names List sysNames = new ArrayList(); diff --git a/jetty-osgi/test-jetty-osgi-webapp/src/main/java/com/acme/osgi/Activator.java b/jetty-osgi/test-jetty-osgi-webapp/src/main/java/com/acme/osgi/Activator.java index 0acdaad41a89..4bfb84e3990d 100644 --- a/jetty-osgi/test-jetty-osgi-webapp/src/main/java/com/acme/osgi/Activator.java +++ b/jetty-osgi/test-jetty-osgi-webapp/src/main/java/com/acme/osgi/Activator.java @@ -77,7 +77,7 @@ public void start(BundleContext context) throws Exception //Create a second webappB as a Service and target it at a custom Server //deployed by another bundle - WebAppContext webappB = new WebAppContext(); + final WebAppContext webappB = new WebAppContext(); Dictionary propsB = new Hashtable(); propsB.put("Jetty-WarResourcePath", "webappB"); propsB.put("Web-ContextPath", "/acme"); 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 044aaa271e46..562c403f2358 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 @@ -170,6 +170,5 @@ public boolean equals(Object o) return false; } - public abstract void validate(Class clazz, Method m); } diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallbackCollection.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallbackCollection.java index b11fa534ee43..8c3a63301251 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallbackCollection.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallbackCollection.java @@ -98,6 +98,21 @@ public Set getPreDestroyCallbacks(Object o) return preDestroyCallbacksMap.get(clazz.getName()); } + /** + * Amalgamate all pre-destroy callbacks and return a read only set + * + * @return the collection of {@link PreDestroyCallback}s + */ + public Collection getPreDestroyCallbacks() + { + Set set = new HashSet(); + for (String s : preDestroyCallbacksMap.keySet()) + { + set.addAll(preDestroyCallbacksMap.get(s)); + } + return Collections.unmodifiableCollection(set); + } + public Set getPostConstructCallbacks(Object o) { if (o == null) @@ -107,6 +122,21 @@ public Set getPostConstructCallbacks(Object o) return postConstructCallbacksMap.get(clazz.getName()); } + /** + * Amalgamate all post-construct callbacks and return a read only set + * + * @return the collection of {@link PostConstructCallback}s + */ + public Collection getPostConstructCallbacks() + { + Set set = new HashSet(); + for (String s : postConstructCallbacksMap.keySet()) + { + set.addAll(postConstructCallbacksMap.get(s)); + } + return Collections.unmodifiableCollection(set); + } + /** * Call the method, if one exists, that is annotated with @PostConstruct * or with <post-construct> in web.xml @@ -172,34 +202,4 @@ public Map> getPreDestroyCallbackMap() { return Collections.unmodifiableMap(preDestroyCallbacksMap); } - - /** - * Amalgamate all post-construct callbacks and return a read only set - * - * @return the collection of {@link PostConstructCallback}s - */ - public Collection getPostConstructCallbacks() - { - Set set = new HashSet(); - for (String s : postConstructCallbacksMap.keySet()) - { - set.addAll(postConstructCallbacksMap.get(s)); - } - return Collections.unmodifiableCollection(set); - } - - /** - * Amalgamate all pre-destroy callbacks and return a read only set - * - * @return the collection of {@link PreDestroyCallback}s - */ - public Collection getPreDestroyCallbacks() - { - Set set = new HashSet(); - for (String s : preDestroyCallbacksMap.keySet()) - { - set.addAll(preDestroyCallbacksMap.get(s)); - } - return Collections.unmodifiableCollection(set); - } } diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jndi/NamingEntryUtil.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jndi/NamingEntryUtil.java index 6d6420f4814f..bae499699c17 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jndi/NamingEntryUtil.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jndi/NamingEntryUtil.java @@ -130,6 +130,33 @@ public static List lookupNamingEntries(Object scope, Class c } } + /** + * Build up a list of NamingEntry objects that are of a specific type. + */ + private static List lookupNamingEntries(List list, Context context, Class clazz) + throws NamingException + { + try + { + NamingEnumeration nenum = context.listBindings(""); + while (nenum.hasMoreElements()) + { + Binding binding = nenum.next(); + if (binding.getObject() instanceof Context) + lookupNamingEntries(list, (Context)binding.getObject(), clazz); + else if (clazz.isInstance(binding.getObject())) + list.add(binding.getObject()); + } + } + catch (NameNotFoundException e) + { + if (LOG.isDebugEnabled()) + LOG.debug("No entries of type " + clazz.getName() + " in context=" + context); + } + + return list; + } + public static Name makeNamingEntryName(NameParser parser, NamingEntry namingEntry) throws NamingException { @@ -194,33 +221,6 @@ public static Context getContextForNamingEntries(Object scope) return (Context)scopeContext.lookup(NamingEntry.__contextName); } - /** - * Build up a list of NamingEntry objects that are of a specific type. - */ - private static List lookupNamingEntries(List list, Context context, Class clazz) - throws NamingException - { - try - { - NamingEnumeration nenum = context.listBindings(""); - while (nenum.hasMoreElements()) - { - Binding binding = nenum.next(); - if (binding.getObject() instanceof Context) - lookupNamingEntries(list, (Context)binding.getObject(), clazz); - else if (clazz.isInstance(binding.getObject())) - list.add(binding.getObject()); - } - } - catch (NameNotFoundException e) - { - if (LOG.isDebugEnabled()) - LOG.debug("No entries of type " + clazz.getName() + " in context=" + context); - } - - return list; - } - private static String canonicalizeScope(Object scope) { if (scope == null) diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java index ee64d4f9c8ed..e3f0d3bde4c3 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java @@ -178,6 +178,8 @@ public void visitEnvEntry(WebAppContext context, Descriptor descriptor, XmlParse //ServletSpec p.75. No declaration in web.xml, but in multiple web-fragments. Error. throw new IllegalStateException("Conflicting env-entry " + name + " in " + descriptor.getResource()); } + default: + break; } } @@ -312,16 +314,16 @@ public void visitResourceRef(WebAppContext context, Descriptor descriptor, XmlPa { //declarations of the resource-ref must be the same in both fragment descriptors String otherType = otherNode.getString("res-type", false, true); + otherType = (otherType == null ? "" : otherType); String otherAuth = otherNode.getString("res-auth", false, true); + otherAuth = (otherAuth == null ? "" : otherAuth); String otherShared = otherNode.getString("res-sharing-scope", false, true); + otherShared = (otherShared == null ? "" : otherShared); //otherType, otherAuth and otherShared must be the same as type, auth, shared type = (type == null ? "" : type); - otherType = (otherType == null ? "" : otherType); auth = (auth == null ? "" : auth); - otherAuth = (otherAuth == null ? "" : otherAuth); shared = (shared == null ? "" : shared); - otherShared = (otherShared == null ? "" : otherShared); //ServletSpec p.75. No declaration of resource-ref in web xml, but different in multiple web-fragments. Error. if (!type.equals(otherType) || !auth.equals(otherAuth) || !shared.equals(otherShared)) @@ -331,7 +333,11 @@ public void visitResourceRef(WebAppContext context, Descriptor descriptor, XmlPa } else throw new IllegalStateException("resource-ref." + jndiName + " not found in declaring descriptor " + otherFragment); + break; } + + default: + break; } } @@ -436,7 +442,10 @@ public void visitResourceEnvRef(WebAppContext context, Descriptor descriptor, Xm } else throw new IllegalStateException("resource-env-ref." + jndiName + " not found in declaring descriptor " + otherFragment); + break; } + default: + break; } } @@ -535,7 +544,10 @@ public void visitMessageDestinationRef(WebAppContext context, Descriptor descrip } else throw new IllegalStateException("message-destination-ref." + jndiName + " not found in declaring descriptor " + otherFragment); + break; } + default: + break; } } @@ -615,6 +627,8 @@ public void visitPostConstruct(WebAppContext context, Descriptor descriptor, Xml } break; } + default: + break; } } @@ -691,6 +705,8 @@ public void visitPreDestroy(WebAppContext context, Descriptor descriptor, XmlPar } break; } + default: + break; } } diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AsyncMiddleManServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AsyncMiddleManServlet.java index b885acc1b67c..56c18225c0f3 100644 --- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AsyncMiddleManServlet.java +++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AsyncMiddleManServlet.java @@ -452,7 +452,7 @@ public void onContent(final Response serverResponse, ByteBuffer content, final C hasContent = true; ProxyWriter proxyWriter = (ProxyWriter)clientRequest.getAttribute(WRITE_LISTENER_ATTRIBUTE); - boolean committed = proxyWriter != null; + final boolean committed = proxyWriter != null; if (proxyWriter == null) { proxyWriter = newProxyWriteListener(clientRequest, serverResponse); diff --git a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartConfiguration.java b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartConfiguration.java index 673faa438c09..2462ad4e326e 100644 --- a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartConfiguration.java +++ b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartConfiguration.java @@ -142,6 +142,9 @@ public void preConfigure(WebAppContext context) throws Exception else throw new IllegalStateException("No " + quickStartWebXml); break; + + default: + throw new IllegalStateException(_mode.toString()); } } @@ -161,18 +164,6 @@ else if (attr != null) generator.setQuickStartWebXml(Resource.newResource(attr.toString())); } - protected void quickStart(WebAppContext context, Resource quickStartWebXml) - throws Exception - { - _quickStart = true; - context.setConfigurations(context.getWebAppConfigurations().stream() - .filter(c -> !__replacedConfigurations.contains(c.replaces()) && !__replacedConfigurations.contains(c.getClass())) - .collect(Collectors.toList()).toArray(new Configuration[]{})); - context.getMetaData().setWebXml(quickStartWebXml); - context.getServletContext().setEffectiveMajorVersion(context.getMetaData().getWebXml().getMajorVersion()); - context.getServletContext().setEffectiveMinorVersion(context.getMetaData().getWebXml().getMinorVersion()); - } - /** * @see org.eclipse.jetty.webapp.AbstractConfiguration#configure(org.eclipse.jetty.webapp.WebAppContext) */ @@ -204,6 +195,18 @@ public void configure(WebAppContext context) throws Exception } } + protected void quickStart(WebAppContext context, Resource quickStartWebXml) + throws Exception + { + _quickStart = true; + context.setConfigurations(context.getWebAppConfigurations().stream() + .filter(c -> !__replacedConfigurations.contains(c.replaces()) && !__replacedConfigurations.contains(c.getClass())) + .collect(Collectors.toList()).toArray(new Configuration[]{})); + context.getMetaData().setWebXml(quickStartWebXml); + context.getServletContext().setEffectiveMajorVersion(context.getMetaData().getWebXml().getMajorVersion()); + context.getServletContext().setEffectiveMinorVersion(context.getMetaData().getWebXml().getMinorVersion()); + } + /** * Get the quickstart-web.xml file as a Resource. * diff --git a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartGeneratorConfiguration.java b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartGeneratorConfiguration.java index 3ad2a567ec67..20cfab4535b3 100644 --- a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartGeneratorConfiguration.java +++ b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartGeneratorConfiguration.java @@ -165,8 +165,6 @@ public void generateQuickStartWebXml(WebAppContext context, OutputStream stream) LOG.info("Quickstart generating"); - XmlAppendable out = new XmlAppendable(stream, "UTF-8"); - MetaData md = context.getMetaData(); Map webappAttr = new HashMap<>(); @@ -178,6 +176,7 @@ public void generateQuickStartWebXml(WebAppContext context, OutputStream stream) webappAttr.put("metadata-complete", "true"); webappAttr.put("version", major + "." + minor); + XmlAppendable out = new XmlAppendable(stream, "UTF-8"); out.openTag("web-app", webappAttr); if (context.getDisplayName() != null) out.tag("display-name", context.getDisplayName()); diff --git a/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java b/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java index 7175cf370af4..49160ff6e2f7 100644 --- a/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java +++ b/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java @@ -369,7 +369,7 @@ else if ("STOP.PORT".equals(sysProps[0])) statsContext.setSessionHandler(new SessionHandler()); if (_statsPropFile != null) { - HashLoginService loginService = new HashLoginService("StatsRealm", _statsPropFile); + final HashLoginService loginService = new HashLoginService("StatsRealm", _statsPropFile); Constraint constraint = new Constraint(); constraint.setName("Admin Only"); constraint.setRoles(new String[]{"admin"}); @@ -496,6 +496,9 @@ else if ("STOP.PORT".equals(sysProps[0])) monitor.setKey(stopKey); monitor.setExitVm(true); break; + + default: + break; } if (_logFile != null) diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/ConfigurableSpnegoLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/ConfigurableSpnegoLoginService.java index 8b8724d642cc..ab3008edd5c5 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/ConfigurableSpnegoLoginService.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/ConfigurableSpnegoLoginService.java @@ -289,7 +289,7 @@ private class SpnegoConfiguration extends Configuration @Override public AppConfigurationEntry[] getAppConfigurationEntry(String name) { - String principal = getServiceName() + "/" + getHostName(); + final String principal = getServiceName() + "/" + getHostName(); Map options = new HashMap<>(); if (LOG.isDebugEnabled()) options.put("debug", "true"); diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java index 212ebe4f5142..09be2a969851 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java @@ -123,16 +123,17 @@ protected void doStart() throws Exception _url = properties.getProperty("url"); _userName = properties.getProperty("username"); _password = properties.getProperty("password"); - String userTable = properties.getProperty("usertable"); _userTableKey = properties.getProperty("usertablekey"); - String userTableUserField = properties.getProperty("usertableuserfield"); _userTablePasswordField = properties.getProperty("usertablepasswordfield"); - String roleTable = properties.getProperty("roletable"); - String roleTableKey = properties.getProperty("roletablekey"); _roleTableRoleField = properties.getProperty("roletablerolefield"); - String userRoleTable = properties.getProperty("userroletable"); - String userRoleTableUserKey = properties.getProperty("userroletableuserkey"); - String userRoleTableRoleKey = properties.getProperty("userroletablerolekey"); + + final String userTable = properties.getProperty("usertable"); + final String userTableUserField = properties.getProperty("usertableuserfield"); + final String roleTable = properties.getProperty("roletable"); + final String roleTableKey = properties.getProperty("roletablekey"); + final String userRoleTable = properties.getProperty("userroletable"); + final String userRoleTableUserKey = properties.getProperty("userroletableuserkey"); + final String userRoleTableRoleKey = properties.getProperty("userroletablerolekey"); if (_jdbcDriver == null || _jdbcDriver.equals("") || _url == null || _url.equals("") || diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java index f6e9e4bd2a0a..ea913c476da1 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java @@ -244,10 +244,10 @@ public void prepareRequest(ServletRequest request) @Override public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException { - HttpServletRequest request = (HttpServletRequest)req; - HttpServletResponse response = (HttpServletResponse)res; - Request baseRequest = Request.getBaseRequest(request); - Response baseResponse = baseRequest.getResponse(); + final HttpServletRequest request = (HttpServletRequest)req; + final HttpServletResponse response = (HttpServletResponse)res; + final Request baseRequest = Request.getBaseRequest(request); + final Response baseResponse = baseRequest.getResponse(); String uri = request.getRequestURI(); if (uri == null) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java index 6f3aabd4a0ce..b12801147764 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java @@ -559,11 +559,6 @@ public boolean isPercentCode() } } - private MethodHandle updateLogHandle(MethodHandle logHandle, MethodHandle append, String literal) - { - return foldArguments(logHandle, dropArguments(dropArguments(append.bindTo(literal), 1, Request.class), 2, Response.class)); - } - //TODO use integer comparisons instead of strings private static boolean modify(List modifiers, Boolean negated, StringBuilder b, Request request, Response response) { @@ -578,6 +573,11 @@ private static boolean modify(List modifiers, Boolean negated, StringBui } } + private MethodHandle updateLogHandle(MethodHandle logHandle, MethodHandle append, String literal) + { + return foldArguments(logHandle, dropArguments(dropArguments(append.bindTo(literal), 1, Request.class), 2, Response.class)); + } + private MethodHandle updateLogHandle(MethodHandle logHandle, MethodHandle append, String code, String arg, List modifiers, boolean negated) throws NoSuchMethodException, IllegalAccessException { MethodType logType = methodType(Void.TYPE, StringBuilder.class, Request.class, Response.class); 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 bc67a9b1ee72..9d8088b4ef15 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 @@ -75,12 +75,6 @@ public Dispatcher(ContextHandler contextHandler, String name) throws IllegalStat _named = name; } - @Override - public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException - { - forward(request, response, DispatcherType.FORWARD); - } - public void error(ServletRequest request, ServletResponse response) throws ServletException, IOException { try @@ -142,6 +136,12 @@ public void include(ServletRequest request, ServletResponse response) throws Ser } } + @Override + public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException + { + forward(request, response, DispatcherType.FORWARD); + } + protected void forward(ServletRequest request, ServletResponse response, DispatcherType dispatch) throws ServletException, IOException { Request baseRequest = Request.getBaseRequest(request); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java index 11321f5a674e..92e7a1a52fc1 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java @@ -676,6 +676,8 @@ protected void parsedParam(StringBuffer buffer, int valueLength, int paramName, _proto = value; } break; + default: + break; } } } 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 528be71d7ad3..75e37a8763a0 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 @@ -470,6 +470,9 @@ protected Action unhandle() case IDLE: case REGISTERED: break; + + default: + throw new IllegalStateException(_asyncRead.toString()); } if (_asyncWritePossible) @@ -1184,6 +1187,8 @@ public void onReadUnready() case POSSIBLE: case PRODUCING: break; + default: + throw new IllegalStateException(_asyncRead.toString()); } } @@ -1227,7 +1232,7 @@ public boolean onContentAdded() } break; - case POSSIBLE: + default: throw new IllegalStateException(toStringLocked()); } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index 7f45120ef4e1..a010a69e9a75 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -219,37 +219,6 @@ protected Blocker acquireWriteBlockingCallback() throws IOException return _writeBlocker.acquire(); } - private void write(ByteBuffer content, boolean complete) throws IOException - { - try (Blocker blocker = _writeBlocker.acquire()) - { - write(content, complete, blocker); - blocker.block(); - } - catch (Exception failure) - { - if (LOG.isDebugEnabled()) - LOG.debug(failure); - abort(failure); - if (failure instanceof IOException) - throw failure; - throw new IOException(failure); - } - } - - protected void write(ByteBuffer content, boolean complete, Callback callback) - { - if (_firstByteTimeStamp == -1) - { - long minDataRate = getHttpChannel().getHttpConfiguration().getMinResponseDataRate(); - if (minDataRate > 0) - _firstByteTimeStamp = System.nanoTime(); - else - _firstByteTimeStamp = Long.MAX_VALUE; - } - _interceptor.write(content, complete, callback); - } - private void abort(Throwable failure) { closed(); @@ -435,6 +404,37 @@ public void flush() throws IOException } } + private void write(ByteBuffer content, boolean complete) throws IOException + { + try (Blocker blocker = _writeBlocker.acquire()) + { + write(content, complete, blocker); + blocker.block(); + } + catch (Exception failure) + { + if (LOG.isDebugEnabled()) + LOG.debug(failure); + abort(failure); + if (failure instanceof IOException) + throw failure; + throw new IOException(failure); + } + } + + protected void write(ByteBuffer content, boolean complete, Callback callback) + { + if (_firstByteTimeStamp == -1) + { + long minDataRate = getHttpChannel().getHttpConfiguration().getMinResponseDataRate(); + if (minDataRate > 0) + _firstByteTimeStamp = System.nanoTime(); + else + _firstByteTimeStamp = Long.MAX_VALUE; + } + _interceptor.write(content, complete, callback); + } + @Override public void write(byte[] b, int off, int len) throws IOException { @@ -540,8 +540,8 @@ public void write(byte[] b, int off, int len) throws IOException ByteBuffer view = ByteBuffer.wrap(b, off, len); while (len > getBufferSize()) { - int p = view.position(); - int l = p + getBufferSize(); + final int p = view.position(); + final int l = p + getBufferSize(); view.limit(p + getBufferSize()); write(view, false); len -= getBufferSize(); @@ -689,12 +689,6 @@ public void print(String s) throws IOException print(s, false); } - @Override - public void println(String s) throws IOException - { - print(s, true); - } - private void print(String s, boolean eoln) throws IOException { if (isClosed()) @@ -761,6 +755,12 @@ else if (crlf != null && crlf.hasRemaining()) getHttpChannel().getByteBufferPool().release(out); } + @Override + public void println(String s) throws IOException + { + print(s, true); + } + @Override public void println(boolean b) throws IOException { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java index e0cb9d78a8f5..90c12bddfdcc 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java @@ -765,7 +765,6 @@ public String toString() String mimetype = (content == null ? null : content.getContentTypeValue()); if (mimetype == null) LOG.warn("Unknown mimetype for " + request.getRequestURI()); - MultiPartOutputStream multi = new MultiPartOutputStream(out); response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); if (!response.containsHeader(HttpHeader.DATE.asString())) response.addDateHeader(HttpHeader.DATE.asString(), System.currentTimeMillis()); @@ -778,6 +777,7 @@ public String toString() ctp = "multipart/x-byteranges; boundary="; else ctp = "multipart/byteranges; boundary="; + MultiPartOutputStream multi = new MultiPartOutputStream(out); response.setContentType(ctp + multi.getBoundary()); InputStream in = content.getResource().getInputStream(); 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 372a27c1befb..fc8907f79572 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 @@ -176,6 +176,39 @@ public void addCookie(HttpCookie cookie) _fields.put(__EXPIRES_01JAN1970); } + @Override + public void addCookie(Cookie cookie) + { + if (StringUtil.isBlank(cookie.getName())) + throw new IllegalArgumentException("Cookie.name cannot be blank/null"); + + String comment = cookie.getComment(); + boolean httpOnly = cookie.isHttpOnly(); + + if (comment != null) + { + int i = comment.indexOf(HTTP_ONLY_COMMENT); + if (i >= 0) + { + httpOnly = true; + comment = StringUtil.strip(comment.trim(), HTTP_ONLY_COMMENT); + if (comment.length() == 0) + comment = null; + } + } + + addCookie(new HttpCookie( + cookie.getName(), + cookie.getValue(), + cookie.getDomain(), + cookie.getPath(), + (long)cookie.getMaxAge(), + httpOnly, + cookie.getSecure(), + comment, + cookie.getVersion())); + } + /** * Replace (or add) a cookie. * Using name, path and domain, look for a matching set-cookie header and replace it. @@ -190,7 +223,7 @@ public void replaceCookie(HttpCookie cookie) if (field.getHeader() == HttpHeader.SET_COOKIE) { - CookieCompliance compliance = getHttpChannel().getHttpConfiguration().getResponseCookieCompliance(); + final CookieCompliance compliance = getHttpChannel().getHttpConfiguration().getResponseCookieCompliance(); HttpCookie oldCookie; if (field instanceof SetCookieHttpField) @@ -226,39 +259,6 @@ else if (!cookie.getPath().equals(oldCookie.getPath())) addCookie(cookie); } - @Override - public void addCookie(Cookie cookie) - { - if (StringUtil.isBlank(cookie.getName())) - throw new IllegalArgumentException("Cookie.name cannot be blank/null"); - - String comment = cookie.getComment(); - boolean httpOnly = cookie.isHttpOnly(); - - if (comment != null) - { - int i = comment.indexOf(HTTP_ONLY_COMMENT); - if (i >= 0) - { - httpOnly = true; - comment = StringUtil.strip(comment.trim(), HTTP_ONLY_COMMENT); - if (comment.length() == 0) - comment = null; - } - } - - addCookie(new HttpCookie( - cookie.getName(), - cookie.getValue(), - cookie.getDomain(), - cookie.getPath(), - (long)cookie.getMaxAge(), - httpOnly, - cookie.getSecure(), - comment, - cookie.getVersion())); - } - @Override public boolean containsHeader(String name) { @@ -976,7 +976,10 @@ public void setContentType(String contentType) { _contentType = contentType + ";charset=" + _characterEncoding; _mimeType = null; + break; } + default: + throw new IllegalStateException(_encodingFrom.toString()); } } else if (isWriting() && !charset.equalsIgnoreCase(_characterEncoding)) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java index b634bb939177..92984e26a8b9 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java @@ -184,22 +184,6 @@ else if (endp instanceof ProxyConnectionFactory.ProxyEndPoint) customizeSecure(request); } - /** - * Customizes the request attributes for general secure settings. - * The default impl calls {@link Request#setSecure(boolean)} with true - * and sets a response header if the Strict-Transport-Security options - * are set. - * - * @param request the request being customized - */ - protected void customizeSecure(Request request) - { - request.setSecure(true); - - if (_stsField != null) - request.getResponse().getHttpFields().add(_stsField); - } - /** *

* Customizes the request attributes to be set for SSL requests. @@ -279,6 +263,22 @@ protected void customize(SSLEngine sslEngine, Request request) } } + /** + * Customizes the request attributes for general secure settings. + * The default impl calls {@link Request#setSecure(boolean)} with true + * and sets a response header if the Strict-Transport-Security options + * are set. + * + * @param request the request being customized + */ + protected void customizeSecure(Request request) + { + request.setSecure(true); + + if (_stsField != null) + request.getResponse().getHttpFields().add(_stsField); + } + private X509Certificate[] getCertChain(Request request, SSLSession sslSession) { // The in-use SslContextFactory should be present in the Connector's SslConnectionFactory diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/BufferedResponseHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/BufferedResponseHandler.java index 962c37c6f355..bbb24c536b01 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/BufferedResponseHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/BufferedResponseHandler.java @@ -106,8 +106,8 @@ public IncludeExclude getMimeIncludeExclude() @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - ServletContext context = baseRequest.getServletContext(); - String path = context == null ? baseRequest.getRequestURI() : URIUtil.addPaths(baseRequest.getServletPath(), baseRequest.getPathInfo()); + final ServletContext context = baseRequest.getServletContext(); + final String path = context == null ? baseRequest.getRequestURI() : URIUtil.addPaths(baseRequest.getServletPath(), baseRequest.getPathInfo()); LOG.debug("{} handle {} in {}", this, baseRequest, context); HttpOutput out = baseRequest.getResponse().getHttpOutput(); 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 b055afe8c04a..1e1bb82c6ee4 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 @@ -1734,7 +1734,7 @@ public void setCompactPath(boolean compactPath) @Override public String toString() { - String[] vhosts = getVirtualHosts(); + final String[] vhosts = getVirtualHosts(); StringBuilder b = new StringBuilder(); @@ -2726,23 +2726,23 @@ public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, } @Override - public ServletRegistration.Dynamic addJspFile(String servletName, String jspFile) + public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) { - // TODO new in 4.0 LOG.warn(__unimplmented); return null; } @Override - public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) + public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className) { LOG.warn(__unimplmented); return null; } @Override - public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className) + public ServletRegistration.Dynamic addJspFile(String servletName, String jspFile) { + // TODO new in 4.0 LOG.warn(__unimplmented); return null; } 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 2475add60ff6..cd0f164d2f3c 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 @@ -133,9 +133,6 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques writer.append("

No context on this server matched or handled this request.

\n"); writer.append("

Contexts known to this server are:

\n"); - Server server = getServer(); - Handler[] handlers = server == null ? null : server.getChildHandlersByClass(ContextHandler.class); - writer.append(""); writer.append(""); writer.append(""); @@ -143,6 +140,9 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques writer.append(""); writer.append("\n"); + Server server = getServer(); + Handler[] handlers = server == null ? null : server.getChildHandlersByClass(ContextHandler.class); + for (int i = 0; handlers != null && i < handlers.length; i++) { writer.append("
Context PathDisplay NameLifeCycle
"); 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 f18c2498e0ea..069f22bbbb04 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 @@ -183,6 +183,43 @@ protected void generateAcceptableResponse(Request baseRequest, HttpServletReques baseRequest.getResponse().closeOutput(); } + /** + * Generate an acceptable error response for a mime type. + *

This method is called for each mime type in the users agent's + * Accept header, until {@link Request#isHandled()} is true and a + * response of the appropriate type is generated. + * + * @param baseRequest The base request + * @param request The servlet request (may be wrapped) + * @param response The response (may be wrapped) + * @param code the http error code + * @param message the http error message + * @param mimeType The mimetype to generate (may be */*or other wildcard) + * @throws IOException if a response cannot be generated + */ + protected void generateAcceptableResponse(Request baseRequest, HttpServletRequest request, HttpServletResponse response, int code, String message, String mimeType) + throws IOException + { + switch (mimeType) + { + case "text/html": + case "text/*": + case "*/*": + { + baseRequest.setHandled(true); + Writer writer = getAcceptableWriter(baseRequest, request, response); + if (writer != null) + { + response.setContentType(MimeTypes.Type.TEXT_HTML.asString()); + handleErrorPage(request, writer, code, message); + } + break; + } + default: + break; + } + } + /** * Returns an acceptable writer for an error page. *

Uses the user-agent's Accept-Charset to get response @@ -229,40 +266,6 @@ protected Writer getAcceptableWriter(Request baseRequest, HttpServletRequest req return null; } - /** - * Generate an acceptable error response for a mime type. - *

This method is called for each mime type in the users agent's - * Accept header, until {@link Request#isHandled()} is true and a - * response of the appropriate type is generated. - * - * @param baseRequest The base request - * @param request The servlet request (may be wrapped) - * @param response The response (may be wrapped) - * @param code the http error code - * @param message the http error message - * @param mimeType The mimetype to generate (may be */*or other wildcard) - * @throws IOException if a response cannot be generated - */ - protected void generateAcceptableResponse(Request baseRequest, HttpServletRequest request, HttpServletResponse response, int code, String message, String mimeType) - throws IOException - { - switch (mimeType) - { - case "text/html": - case "text/*": - case "*/*": - { - baseRequest.setHandled(true); - Writer writer = getAcceptableWriter(baseRequest, request, response); - if (writer != null) - { - response.setContentType(MimeTypes.Type.TEXT_HTML.asString()); - handleErrorPage(request, writer, code, message); - } - } - } - } - protected void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java index ccaf09adaff9..0c5a9705aba7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java @@ -105,7 +105,7 @@ public void onComplete(AsyncEvent event) throws IOException Request request = state.getBaseRequest(); final long elapsed = System.currentTimeMillis() - request.getTimeStamp(); - long d = _requestStats.decrement(); + final long d = _requestStats.decrement(); _requestTimeStats.record(elapsed); updateResponse(request); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ThreadLimitHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ThreadLimitHandler.java index 6107087db224..7666bcb0641b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ThreadLimitHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ThreadLimitHandler.java @@ -126,6 +126,26 @@ public int getThreadLimit() return _threadLimit; } + protected int getThreadLimit(String ip) + { + if (!_includeExcludeSet.isEmpty()) + { + try + { + if (!_includeExcludeSet.test(InetAddress.getByName(ip))) + { + LOG.debug("excluded {}", ip); + return 0; + } + } + catch (Exception e) + { + LOG.ignore(e); + } + } + return _threadLimit; + } + public void setThreadLimit(int threadLimit) { if (threadLimit <= 0) @@ -221,26 +241,6 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques } } - protected int getThreadLimit(String ip) - { - if (!_includeExcludeSet.isEmpty()) - { - try - { - if (!_includeExcludeSet.test(InetAddress.getByName(ip))) - { - LOG.debug("excluded {}", ip); - return 0; - } - } - catch (Exception e) - { - LOG.ignore(e); - } - } - return _threadLimit; - } - protected Remote getRemote(Request baseRequest) { Remote remote = (Remote)baseRequest.getAttribute(REMOTE); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java index c273befb6cff..ac10d9b324cc 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java @@ -590,8 +590,8 @@ public void setInflateBufferSize(int size) @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - ServletContext context = baseRequest.getServletContext(); - String path = context == null ? baseRequest.getRequestURI() : URIUtil.addPaths(baseRequest.getServletPath(), baseRequest.getPathInfo()); + final ServletContext context = baseRequest.getServletContext(); + final String path = context == null ? baseRequest.getRequestURI() : URIUtil.addPaths(baseRequest.getServletPath(), baseRequest.getPathInfo()); LOG.debug("{} handle {} in {}", this, baseRequest, context); if (!_dispatchers.contains(baseRequest.getDispatcherType())) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java index 18ecfbaa66f1..62830cd60fe2 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java @@ -110,6 +110,28 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements */ public abstract Session newSession(HttpServletRequest request, SessionData data); + /** + * @see org.eclipse.jetty.server.session.SessionCache#newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long) + */ + @Override + public Session newSession(HttpServletRequest request, String id, long time, long maxInactiveMs) + { + if (LOG.isDebugEnabled()) + LOG.debug("Creating new session id=" + id); + Session session = newSession(request, _sessionDataStore.newSessionData(id, time, time, time, maxInactiveMs)); + session.getSessionData().setLastNode(_context.getWorkerName()); + try + { + if (isSaveOnCreate() && _sessionDataStore != null) + _sessionDataStore.store(id, session.getSessionData()); + } + catch (Exception e) + { + LOG.warn("Save of new session {} failed", id, e); + } + return session; + } + /** * Get the session matching the key * @@ -718,7 +740,7 @@ protected void renewSessionId(Session session, String newId, String newExtendedI try (Lock lock = session.lock()) { - String oldId = session.getId(); + final String oldId = session.getId(); session.checkValidForWrite(); //can't change id on invalid session session.getSessionData().setId(newId); session.getSessionData().setLastSaved(0); //pretend that the session has never been saved before to get a full save @@ -761,28 +783,6 @@ public boolean isSaveOnInactiveEviction() return _saveOnInactiveEviction; } - /** - * @see org.eclipse.jetty.server.session.SessionCache#newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long) - */ - @Override - public Session newSession(HttpServletRequest request, String id, long time, long maxInactiveMs) - { - if (LOG.isDebugEnabled()) - LOG.debug("Creating new session id=" + id); - Session session = newSession(request, _sessionDataStore.newSessionData(id, time, time, time, maxInactiveMs)); - session.getSessionData().setLastNode(_context.getWorkerName()); - try - { - if (isSaveOnCreate() && _sessionDataStore != null) - _sessionDataStore.store(id, session.getSessionData()); - } - catch (Exception e) - { - LOG.warn("Save of new session {} failed", id, e); - } - return session; - } - @Override public String toString() { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java index a23ac240a341..b0f9c7df8afa 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java @@ -601,15 +601,15 @@ protected SessionData load(InputStream is, String expectedId) DataInputStream di = new DataInputStream(is); id = di.readUTF(); - String contextPath = di.readUTF(); - String vhost = di.readUTF(); - String lastNode = di.readUTF(); - long created = di.readLong(); - long accessed = di.readLong(); - long lastAccessed = di.readLong(); - long cookieSet = di.readLong(); - long expiry = di.readLong(); - long maxIdle = di.readLong(); + final String contextPath = di.readUTF(); + final String vhost = di.readUTF(); + final String lastNode = di.readUTF(); + final long created = di.readLong(); + final long accessed = di.readLong(); + final long lastAccessed = di.readLong(); + final long cookieSet = di.readLong(); + final long expiry = di.readLong(); + final long maxIdle = di.readLong(); data = newSessionData(id, created, accessed, lastAccessed, maxIdle); data.setContextPath(contextPath); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java index 2f5a9d8cefd7..57a041c9ccc5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java @@ -234,6 +234,11 @@ public void setDirty(boolean dirty) _dirty = dirty; } + public void setDirty(String name) + { + setDirty(true); + } + /** * @param name the name of the attribute * @return the value of the attribute named @@ -261,11 +266,6 @@ public Object setAttribute(String name, Object value) return old; } - public void setDirty(String name) - { - setDirty(true); - } - public void putAllAttributes(Map attributes) { _attributes.putAll(attributes); 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 e5dbf1a3579d..92a2ee85e8b2 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 @@ -146,6 +146,8 @@ public String getErrorPage(HttpServletRequest request) dbg.append(" (from global default)"); LOG.debug(dbg.toString()); break; + default: + throw new IllegalStateException(pageSource.toString()); } } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java index 54fe628f0bd0..688b8785cbbc 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java @@ -85,8 +85,9 @@ public static int dispatch(DispatcherType type) return INCLUDE; case ERROR: return ERROR; + default: + throw new IllegalStateException(type.toString()); } - throw new IllegalArgumentException(type.toString()); } /** @@ -109,8 +110,9 @@ public static DispatcherType dispatch(int type) return DispatcherType.INCLUDE; case ERROR: return DispatcherType.ERROR; + default: + throw new IllegalArgumentException(Integer.toString(type)); } - throw new IllegalArgumentException(Integer.toString(type)); } private int _dispatches = DEFAULT; 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 99c413691e18..6875d45cd023 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 @@ -109,6 +109,16 @@ public static ServletContextHandler getServletContextHandler(ServletContext serv return (ServletContextHandler)contextHandler; } + public static ServletContextHandler getServletContextHandler(ServletContext context) + { + ContextHandler handler = getContextHandler(context); + if (handler == null) + return null; + if (handler instanceof ServletContextHandler) + return (ServletContextHandler)handler; + return null; + } + public interface ServletContainerInitializerCaller extends LifeCycle {} ; @@ -721,16 +731,6 @@ void destroyFilter(Filter filter) _objFactory.destroy(filter); } - public static ServletContextHandler getServletContextHandler(ServletContext context) - { - ContextHandler handler = getContextHandler(context); - if (handler == null) - return null; - if (handler instanceof ServletContextHandler) - return (ServletContextHandler)handler; - return null; - } - public static class JspPropertyGroup implements JspPropertyGroupDescriptor { private List _urlPatterns = new ArrayList(); diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java index 7a4fe6cc3039..091228801310 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java @@ -384,7 +384,7 @@ protected void doFilter(HttpServletRequest request, HttpServletResponse response long throttleMs = getThrottleMs(); if (!Boolean.TRUE.equals(throttled) && throttleMs > 0) { - int priority = getPriority(request, tracker); + final int priority = getPriority(request, tracker); request.setAttribute(__THROTTLED, Boolean.TRUE); if (isInsertHeaders()) response.addHeader("DoSFilter", "throttled"); diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java index a4ab6fe61506..5c9cc0db870d 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java @@ -77,12 +77,12 @@ public abstract class IncludeExcludeBasedFilter implements Filter @Override public void init(FilterConfig filterConfig) throws ServletException { - String includedPaths = filterConfig.getInitParameter("includedPaths"); - String excludedPaths = filterConfig.getInitParameter("excludedPaths"); - String includedMimeTypes = filterConfig.getInitParameter("includedMimeTypes"); - String excludedMimeTypes = filterConfig.getInitParameter("excludedMimeTypes"); - String includedHttpMethods = filterConfig.getInitParameter("includedHttpMethods"); - String excludedHttpMethods = filterConfig.getInitParameter("excludedHttpMethods"); + final String includedPaths = filterConfig.getInitParameter("includedPaths"); + final String excludedPaths = filterConfig.getInitParameter("excludedPaths"); + final String includedMimeTypes = filterConfig.getInitParameter("includedMimeTypes"); + final String excludedMimeTypes = filterConfig.getInitParameter("excludedMimeTypes"); + final String includedHttpMethods = filterConfig.getInitParameter("includedHttpMethods"); + final String excludedHttpMethods = filterConfig.getInitParameter("excludedHttpMethods"); if (includedPaths != null) { 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 a7856be8eda6..857d0183bda6 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 @@ -243,7 +243,7 @@ public void listConfig(StartArgs args) public void listModules(StartArgs args) { - List tags = args.getListModules(); + final List tags = args.getListModules(); StartLog.endStartLog(); System.out.println(); @@ -275,7 +275,6 @@ public StartArgs processCommandLine(List cmdLine) throws Exception public StartArgs processCommandLine(String[] cmdLine) throws Exception { // Processing Order is important! - // ------------------------------------------------------------ // 1) Configuration Locations CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine); baseHome = new BaseHome(cmdLineSource); @@ -283,7 +282,6 @@ public StartArgs processCommandLine(String[] cmdLine) throws Exception StartLog.debug("jetty.home=%s", baseHome.getHome()); StartLog.debug("jetty.base=%s", baseHome.getBase()); - // ------------------------------------------------------------ // 2) Parse everything provided. // This would be the directory information + // the various start inis @@ -306,13 +304,11 @@ public StartArgs processCommandLine(String[] cmdLine) throws Exception normalizeURI(baseHome.getBasePath().toUri().toString()), base.source); - // ------------------------------------------------------------ // 3) Module Registration Modules modules = new Modules(baseHome, args); StartLog.debug("Registering all modules"); modules.registerAll(); - // ------------------------------------------------------------ // 4) Active Module Resolution for (String enabledModule : args.getEnabledModules()) { @@ -343,21 +339,17 @@ public StartArgs processCommandLine(String[] cmdLine) throws Exception module.setSkipFilesValidation(true); } - // ------------------------------------------------------------ // 5) Lib & XML Expansion / Resolution args.expandSystemProperties(); args.expandLibs(); args.expandModules(activeModules); - // ------------------------------------------------------------ // 6) Resolve Extra XMLs args.resolveExtraXmls(); - // ------------------------------------------------------------ // 7) JPMS Expansion args.expandJPMS(activeModules); - // ------------------------------------------------------------ // 8) Resolve Property Files args.resolvePropertyFiles(); @@ -497,12 +489,18 @@ public void run() } } + /* implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) */ + public void start() throws Exception + { + start(jsvcStartArgs); + } + private void doStop(StartArgs args) { - Prop stopHostProp = args.getProperties().getProp("STOP.HOST", true); - Prop stopPortProp = args.getProperties().getProp("STOP.PORT", true); - Prop stopKeyProp = args.getProperties().getProp("STOP.KEY", true); - Prop stopWaitProp = args.getProperties().getProp("STOP.WAIT", true); + final Prop stopHostProp = args.getProperties().getProp("STOP.HOST", true); + final Prop stopPortProp = args.getProperties().getProp("STOP.PORT", true); + final Prop stopKeyProp = args.getProperties().getProp("STOP.KEY", true); + final Prop stopWaitProp = args.getProperties().getProp("STOP.WAIT", true); String stopHost = "127.0.0.1"; int stopPort = -1; @@ -611,6 +609,12 @@ public void stop(String host, int port, String key, int timeout) } } + /* implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) */ + public void stop() throws Exception + { + doStop(jsvcStartArgs); + } + public void usage(boolean exit) { StartLog.endStartLog(); @@ -655,8 +659,7 @@ public static boolean printTextResource(String resourceName) return resourcePrinted; } - // ------------------------------------------------------------ - // implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) + /* implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) */ public void init(String[] args) throws Exception { try @@ -674,22 +677,7 @@ public void init(String[] args) throws Exception } } - // ------------------------------------------------------------ - // implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) - public void start() throws Exception - { - start(jsvcStartArgs); - } - - // ------------------------------------------------------------ - // implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) - public void stop() throws Exception - { - doStop(jsvcStartArgs); - } - - // ------------------------------------------------------------ - // implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) + /* implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy) */ public void destroy() { } diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java index 549878b14278..6bd794d1d7b4 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java @@ -52,19 +52,19 @@ public static void debug(String format, Object... args) } } - public static void trace(String format, Object... args) + public static void debug(Throwable t) { - if (INSTANCE.trace) + if (INSTANCE.debug) { - out.printf("TRACE " + format + "%n", args); + t.printStackTrace(out); } } - public static void debug(Throwable t) + public static void trace(String format, Object... args) { - if (INSTANCE.debug) + if (INSTANCE.trace) { - t.printStackTrace(out); + out.printf("TRACE " + format + "%n", args); } } @@ -88,14 +88,14 @@ public static void info(String format, Object... args) log("INFO", format, args); } - public static void warn(String format, Object... args) + public static void error(String format, Object... args) { - log("WARN", format, args); + log("ERROR", format, args); } - public static void error(String format, Object... args) + public static void warn(String format, Object... args) { - log("ERROR", format, args); + log("WARN", format, args); } public static void warn(Throwable t) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java index ad9dddec79c7..2bb08154816e 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java @@ -252,6 +252,8 @@ else if (Character.isLetter(c)) update = val; } break; + default: + throw new IllegalStateException(state.toString()); } offset++; diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java index 93e5d8a7d1ce..18ebac7020c3 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java @@ -160,44 +160,9 @@ public static String toString(Object[] array) return buffer.toString(); } - /** - * @param s String containing JSON object or array. - * @return A Map, Object array or primitive array parsed from the JSON. - */ - public static Object parse(String s) - { - return DEFAULT.parse(new StringSource(s), false); - } - - /** - * @param s String containing JSON object or array. - * @param stripOuterComment If true, an outer comment around the JSON is ignored. - * @return A Map, Object array or primitive array parsed from the JSON. - */ - public static Object parse(String s, boolean stripOuterComment) - { - return DEFAULT.parse(new StringSource(s), stripOuterComment); - } - - /** - * @param in Reader containing JSON object or array. - * @return A Map, Object array or primitive array parsed from the JSON. - * @throws IOException if unable to parse - */ - public static Object parse(Reader in) throws IOException - { - return DEFAULT.parse(new ReaderSource(in), false); - } - - /** - * @param in Reader containing JSON object or array. - * @param stripOuterComment If true, an outer comment around the JSON is ignored. - * @return A Map, Object array or primitive array parsed from the JSON. - * @throws IOException if unable to parse - */ - public static Object parse(Reader in, boolean stripOuterComment) throws IOException + protected String toString(char[] buffer, int offset, int length) { - return DEFAULT.parse(new ReaderSource(in), stripOuterComment); + return new String(buffer, offset, length); } private void quotedEscape(Appendable buffer, String input) @@ -558,13 +523,6 @@ public void appendString(Appendable buffer, String string) quotedEscape(buffer, string); } - // Parsing utilities - - protected String toString(char[] buffer, int offset, int length) - { - return new String(buffer, offset, length); - } - protected Map newMap() { return new HashMap(); @@ -679,6 +637,46 @@ public Convertor getConvertorFor(String name) return convertor; } + /** + * @param in Reader containing JSON object or array. + * @param stripOuterComment If true, an outer comment around the JSON is ignored. + * @return A Map, Object array or primitive array parsed from the JSON. + * @throws IOException if unable to parse + */ + public static Object parse(Reader in, boolean stripOuterComment) throws IOException + { + return DEFAULT.parse(new ReaderSource(in), stripOuterComment); + } + + /** + * @param s String containing JSON object or array. + * @return A Map, Object array or primitive array parsed from the JSON. + */ + public static Object parse(String s) + { + return DEFAULT.parse(new StringSource(s), false); + } + + /** + * @param s String containing JSON object or array. + * @param stripOuterComment If true, an outer comment around the JSON is ignored. + * @return A Map, Object array or primitive array parsed from the JSON. + */ + public static Object parse(String s, boolean stripOuterComment) + { + return DEFAULT.parse(new StringSource(s), stripOuterComment); + } + + /** + * @param in Reader containing JSON object or array. + * @return A Map, Object array or primitive array parsed from the JSON. + * @throws IOException if unable to parse + */ + public static Object parse(Reader in) throws IOException + { + return DEFAULT.parse(new ReaderSource(in), false); + } + public Object parse(Source source, boolean stripOuterComment) { int commentState = 0; // 0=no comment, 1="/", 2="/*", 3="/* *" -1="//" @@ -707,6 +705,9 @@ public Object parse(Source source, boolean stripOuterComment) commentState = 0; stripState = 2; } + break; + default: + break; } } // handle /* C style */ comment @@ -785,6 +786,9 @@ public Object parse(Source source) break; case '*': commentState = 2; + break; + default: + break; } } // handle /* C Style */ comment @@ -1307,15 +1311,16 @@ public void add(Object obj) } @Override - public void addClass(Class type) + public void add(String name, Object value) { try { if (c == 0) throw new IllegalStateException(); _buffer.append(c); - _buffer.append("\"class\":"); - append(_buffer, type.getName()); + quotedEscape(_buffer, name); + _buffer.append(':'); + append(_buffer, value); c = ','; } catch (IOException e) @@ -1325,7 +1330,7 @@ public void addClass(Class type) } @Override - public void add(String name, Object value) + public void add(String name, double value) { try { @@ -1334,7 +1339,7 @@ public void add(String name, Object value) _buffer.append(c); quotedEscape(_buffer, name); _buffer.append(':'); - append(_buffer, value); + appendNumber(_buffer, value); c = ','; } catch (IOException e) @@ -1344,7 +1349,7 @@ public void add(String name, Object value) } @Override - public void add(String name, double value) + public void add(String name, long value) { try { @@ -1363,7 +1368,7 @@ public void add(String name, double value) } @Override - public void add(String name, long value) + public void add(String name, boolean value) { try { @@ -1372,7 +1377,7 @@ public void add(String name, long value) _buffer.append(c); quotedEscape(_buffer, name); _buffer.append(':'); - appendNumber(_buffer, value); + appendBoolean(_buffer, value ? Boolean.TRUE : Boolean.FALSE); c = ','; } catch (IOException e) @@ -1382,16 +1387,15 @@ public void add(String name, long value) } @Override - public void add(String name, boolean value) + public void addClass(Class type) { try { if (c == 0) throw new IllegalStateException(); _buffer.append(c); - quotedEscape(_buffer, name); - _buffer.append(':'); - appendBoolean(_buffer, value ? Boolean.TRUE : Boolean.FALSE); + _buffer.append("\"class\":"); + append(_buffer, type.getName()); c = ','; } catch (IOException e) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java index ab8361cfd0c5..6c2f41da55e2 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java @@ -119,7 +119,6 @@ protected void init() switch (m.getParameterCount()) { case 0: - if (m.getReturnType() != null) { if (name.startsWith("is") && name.length() > 2) @@ -140,6 +139,9 @@ else if (name.startsWith("get") && name.length() > 3) addSetter(name, m); } break; + + default: + break; } } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java index e4ca8a4bdbed..ac375695fd6c 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java @@ -572,12 +572,6 @@ public Growing(boolean insensitive, int capacity, int growby) _trie = new ArrayTernaryTrie<>(insensitive, capacity); } - @Override - public boolean put(V v) - { - return put(v.toString(), v); - } - @Override public int hashCode() { @@ -590,24 +584,6 @@ public V remove(String s) return _trie.remove(s); } - @Override - public V get(String s) - { - return _trie.get(s); - } - - @Override - public V get(ByteBuffer b) - { - return _trie.get(b); - } - - @Override - public V getBest(byte[] b, int offset, int len) - { - return _trie.getBest(b, offset, len); - } - @Override public boolean isCaseInsensitive() { @@ -626,6 +602,12 @@ public void clear() _trie.clear(); } + @Override + public boolean put(V v) + { + return put(v.toString(), v); + } + @Override public boolean put(String s, V v) { @@ -644,6 +626,18 @@ public boolean put(String s, V v) return added; } + @Override + public V get(String s) + { + return _trie.get(s); + } + + @Override + public V get(ByteBuffer b) + { + return _trie.get(b); + } + @Override public V get(String s, int offset, int len) { @@ -656,6 +650,12 @@ public V get(ByteBuffer b, int offset, int len) return _trie.get(b, offset, len); } + @Override + public V getBest(byte[] b, int offset, int len) + { + return _trie.getBest(b, offset, len); + } + @Override public V getBest(String s) { diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/AtomicBiInteger.java b/jetty-util/src/main/java/org/eclipse/jetty/util/AtomicBiInteger.java index 290f1dae0fc4..3670349a0ab7 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/AtomicBiInteger.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/AtomicBiInteger.java @@ -48,6 +48,17 @@ public int getHi() return getHi(get()); } + /** + * Gets a hi value from the given encoded value. + * + * @param encoded the encoded value + * @return the hi value + */ + public static int getHi(long encoded) + { + return (int)((encoded >> 32) & 0xFFFF_FFFFL); + } + /** * @return the lo value */ @@ -56,6 +67,17 @@ public int getLo() return getLo(get()); } + /** + * Gets a lo value from the given encoded value. + * + * @param encoded the encoded value + * @return the lo value + */ + public static int getLo(long encoded) + { + return (int)(encoded & 0xFFFF_FFFFL); + } + /** * Atomically sets the hi value without changing the lo value. * @@ -234,28 +256,6 @@ public void add(int deltaHi, int deltaLo) } } - /** - * Gets a hi value from the given encoded value. - * - * @param encoded the encoded value - * @return the hi value - */ - public static int getHi(long encoded) - { - return (int)((encoded >> 32) & 0xFFFF_FFFFL); - } - - /** - * Gets a lo value from the given encoded value. - * - * @param encoded the encoded value - * @return the lo value - */ - public static int getLo(long encoded) - { - return (int)(encoded & 0xFFFF_FFFFL); - } - /** * Encodes hi and lo values into a long. * diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Atomics.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Atomics.java index ffa1ace3cfd2..9589b79c808b 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Atomics.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Atomics.java @@ -39,26 +39,26 @@ public static boolean updateMin(AtomicLong currentMin, long newValue) return false; } - public static boolean updateMax(AtomicLong currentMax, long newValue) + public static boolean updateMin(AtomicInteger currentMin, int newValue) { - long oldValue = currentMax.get(); - while (newValue > oldValue) + int oldValue = currentMin.get(); + while (newValue < oldValue) { - if (currentMax.compareAndSet(oldValue, newValue)) + if (currentMin.compareAndSet(oldValue, newValue)) return true; - oldValue = currentMax.get(); + oldValue = currentMin.get(); } return false; } - public static boolean updateMin(AtomicInteger currentMin, int newValue) + public static boolean updateMax(AtomicLong currentMax, long newValue) { - int oldValue = currentMin.get(); - while (newValue < oldValue) + long oldValue = currentMax.get(); + while (newValue > oldValue) { - if (currentMin.compareAndSet(oldValue, newValue)) + if (currentMax.compareAndSet(oldValue, newValue)) return true; - oldValue = currentMin.get(); + oldValue = currentMax.get(); } return false; } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/BlockingArrayQueue.java b/jetty-util/src/main/java/org/eclipse/jetty/util/BlockingArrayQueue.java index a47b500157c3..0de21d962a7a 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/BlockingArrayQueue.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/BlockingArrayQueue.java @@ -205,6 +205,46 @@ public E poll() return e; } + @SuppressWarnings("unchecked") + @Override + public E poll(long time, TimeUnit unit) throws InterruptedException + { + long nanos = unit.toNanos(time); + E e = null; + + _headLock.lockInterruptibly(); // Size cannot shrink + try + { + try + { + while (_size.get() == 0) + { + if (nanos <= 0) + return null; + nanos = _notEmpty.awaitNanos(nanos); + } + } + catch (InterruptedException x) + { + _notEmpty.signal(); + throw x; + } + + int head = _indexes[HEAD_OFFSET]; + e = (E)_elements[head]; + _elements[head] = null; + _indexes[HEAD_OFFSET] = (head + 1) % _elements.length; + + if (_size.decrementAndGet() > 0) + _notEmpty.signal(); + } + finally + { + _headLock.unlock(); + } + return e; + } + @SuppressWarnings("unchecked") @Override public E peek() @@ -236,6 +276,108 @@ public E remove() return e; } + @SuppressWarnings("unchecked") + @Override + public E remove(int index) + { + + _tailLock.lock(); + try + { + + _headLock.lock(); + try + { + if (index < 0 || index >= _size.get()) + throw new IndexOutOfBoundsException("!(" + 0 + "<" + index + "<=" + _size + ")"); + + int i = _indexes[HEAD_OFFSET] + index; + int capacity = _elements.length; + if (i >= capacity) + i -= capacity; + E old = (E)_elements[i]; + + int tail = _indexes[TAIL_OFFSET]; + if (i < tail) + { + System.arraycopy(_elements, i + 1, _elements, i, tail - i); + --_indexes[TAIL_OFFSET]; + } + else + { + System.arraycopy(_elements, i + 1, _elements, i, capacity - i - 1); + _elements[capacity - 1] = _elements[0]; + if (tail > 0) + { + System.arraycopy(_elements, 1, _elements, 0, tail); + --_indexes[TAIL_OFFSET]; + } + else + { + _indexes[TAIL_OFFSET] = capacity - 1; + } + _elements[_indexes[TAIL_OFFSET]] = null; + } + + _size.decrementAndGet(); + + return old; + } + finally + { + _headLock.unlock(); + } + } + finally + { + _tailLock.unlock(); + } + } + + @Override + public boolean remove(Object o) + { + + _tailLock.lock(); + try + { + + _headLock.lock(); + try + { + if (isEmpty()) + return false; + + final int head = _indexes[HEAD_OFFSET]; + final int tail = _indexes[TAIL_OFFSET]; + final int capacity = _elements.length; + + int i = head; + while (true) + { + if (Objects.equals(_elements[i], o)) + { + remove(i >= head ? i - head : capacity - head + i); + return true; + } + ++i; + if (i == capacity) + i = 0; + if (i == tail) + return false; + } + } + finally + { + _headLock.unlock(); + } + } + finally + { + _tailLock.unlock(); + } + } + @Override public E element() { @@ -304,70 +446,100 @@ public boolean offer(E e) } @Override - public boolean add(E e) - { - if (offer(e)) - return true; - else - throw new IllegalStateException(); - } - - @Override - public void put(E o) throws InterruptedException + public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException { // The mechanism to await and signal when the queue is full is not implemented throw new UnsupportedOperationException(); } @Override - public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException + public boolean add(E e) { - // The mechanism to await and signal when the queue is full is not implemented - throw new UnsupportedOperationException(); + if (offer(e)) + return true; + else + throw new IllegalStateException(); } - @SuppressWarnings("unchecked") @Override - public E take() throws InterruptedException + public void add(int index, E e) { - E e = null; + if (e == null) + throw new NullPointerException(); - _headLock.lockInterruptibly(); // Size cannot shrink + _tailLock.lock(); try { + + _headLock.lock(); try { - while (_size.get() == 0) + final int size = _size.get(); + + if (index < 0 || index > size) + throw new IndexOutOfBoundsException("!(" + 0 + "<" + index + "<=" + _size + ")"); + + if (index == size) { - _notEmpty.await(); + add(e); + } + else + { + if (_indexes[TAIL_OFFSET] == _indexes[HEAD_OFFSET]) + if (!grow()) + throw new IllegalStateException("full"); + + // Re-read head and tail after a possible grow + int i = _indexes[HEAD_OFFSET] + index; + int capacity = _elements.length; + + if (i >= capacity) + i -= capacity; + + _size.incrementAndGet(); + int tail = _indexes[TAIL_OFFSET]; + _indexes[TAIL_OFFSET] = tail = (tail + 1) % capacity; + + if (i < tail) + { + System.arraycopy(_elements, i, _elements, i + 1, tail - i); + _elements[i] = e; + } + else + { + if (tail > 0) + { + System.arraycopy(_elements, 0, _elements, 1, tail); + _elements[0] = _elements[capacity - 1]; + } + + System.arraycopy(_elements, i, _elements, i + 1, capacity - i - 1); + _elements[i] = e; + } } } - catch (InterruptedException ex) + finally { - _notEmpty.signal(); - throw ex; + _headLock.unlock(); } - - final int head = _indexes[HEAD_OFFSET]; - e = (E)_elements[head]; - _elements[head] = null; - _indexes[HEAD_OFFSET] = (head + 1) % _elements.length; - - if (_size.decrementAndGet() > 0) - _notEmpty.signal(); } finally { - _headLock.unlock(); + _tailLock.unlock(); } - return e; + } + + @Override + public void put(E o) throws InterruptedException + { + // The mechanism to await and signal when the queue is full is not implemented + throw new UnsupportedOperationException(); } @SuppressWarnings("unchecked") @Override - public E poll(long time, TimeUnit unit) throws InterruptedException + public E take() throws InterruptedException { - long nanos = unit.toNanos(time); E e = null; _headLock.lockInterruptibly(); // Size cannot shrink @@ -377,18 +549,16 @@ public E poll(long time, TimeUnit unit) throws InterruptedException { while (_size.get() == 0) { - if (nanos <= 0) - return null; - nanos = _notEmpty.awaitNanos(nanos); + _notEmpty.await(); } } - catch (InterruptedException x) + catch (InterruptedException ex) { _notEmpty.signal(); - throw x; + throw ex; } - int head = _indexes[HEAD_OFFSET]; + final int head = _indexes[HEAD_OFFSET]; e = (E)_elements[head]; _elements[head] = null; _indexes[HEAD_OFFSET] = (head + 1) % _elements.length; @@ -403,50 +573,6 @@ public E poll(long time, TimeUnit unit) throws InterruptedException return e; } - @Override - public boolean remove(Object o) - { - - _tailLock.lock(); - try - { - - _headLock.lock(); - try - { - if (isEmpty()) - return false; - - final int head = _indexes[HEAD_OFFSET]; - final int tail = _indexes[TAIL_OFFSET]; - final int capacity = _elements.length; - - int i = head; - while (true) - { - if (Objects.equals(_elements[i], o)) - { - remove(i >= head ? i - head : capacity - head + i); - return true; - } - ++i; - if (i == capacity) - i = 0; - if (i == tail) - return false; - } - } - finally - { - _headLock.unlock(); - } - } - finally - { - _tailLock.unlock(); - } - } - @Override public int remainingCapacity() { @@ -558,74 +684,6 @@ public E get(int index) } } - @Override - public void add(int index, E e) - { - if (e == null) - throw new NullPointerException(); - - _tailLock.lock(); - try - { - - _headLock.lock(); - try - { - final int size = _size.get(); - - if (index < 0 || index > size) - throw new IndexOutOfBoundsException("!(" + 0 + "<" + index + "<=" + _size + ")"); - - if (index == size) - { - add(e); - } - else - { - if (_indexes[TAIL_OFFSET] == _indexes[HEAD_OFFSET]) - if (!grow()) - throw new IllegalStateException("full"); - - // Re-read head and tail after a possible grow - int i = _indexes[HEAD_OFFSET] + index; - int capacity = _elements.length; - - if (i >= capacity) - i -= capacity; - - _size.incrementAndGet(); - int tail = _indexes[TAIL_OFFSET]; - _indexes[TAIL_OFFSET] = tail = (tail + 1) % capacity; - - if (i < tail) - { - System.arraycopy(_elements, i, _elements, i + 1, tail - i); - _elements[i] = e; - } - else - { - if (tail > 0) - { - System.arraycopy(_elements, 0, _elements, 1, tail); - _elements[0] = _elements[capacity - 1]; - } - - System.arraycopy(_elements, i, _elements, i + 1, capacity - i - 1); - _elements[i] = e; - } - } - } - finally - { - _headLock.unlock(); - } - } - finally - { - _tailLock.unlock(); - } - } - @SuppressWarnings("unchecked") @Override public E set(int index, E e) @@ -661,64 +719,6 @@ public E set(int index, E e) } } - @SuppressWarnings("unchecked") - @Override - public E remove(int index) - { - - _tailLock.lock(); - try - { - - _headLock.lock(); - try - { - if (index < 0 || index >= _size.get()) - throw new IndexOutOfBoundsException("!(" + 0 + "<" + index + "<=" + _size + ")"); - - int i = _indexes[HEAD_OFFSET] + index; - int capacity = _elements.length; - if (i >= capacity) - i -= capacity; - E old = (E)_elements[i]; - - int tail = _indexes[TAIL_OFFSET]; - if (i < tail) - { - System.arraycopy(_elements, i + 1, _elements, i, tail - i); - --_indexes[TAIL_OFFSET]; - } - else - { - System.arraycopy(_elements, i + 1, _elements, i, capacity - i - 1); - _elements[capacity - 1] = _elements[0]; - if (tail > 0) - { - System.arraycopy(_elements, 1, _elements, 0, tail); - --_indexes[TAIL_OFFSET]; - } - else - { - _indexes[TAIL_OFFSET] = capacity - 1; - } - _elements[_indexes[TAIL_OFFSET]] = null; - } - - _size.decrementAndGet(); - - return old; - } - finally - { - _headLock.unlock(); - } - } - finally - { - _tailLock.unlock(); - } - } - @Override public ListIterator listIterator(int index) { 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 c91ffe85e916..2c87eb72f6b8 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 @@ -97,11 +97,11 @@ public class BufferUtil static final byte SPACE = 0x20; static final byte MINUS = '-'; static final byte[] DIGIT = - { - (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9', - (byte)'A', (byte)'B', (byte)'C', (byte)'D', - (byte)'E', (byte)'F' - }; + { + (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9', + (byte)'A', (byte)'B', (byte)'C', (byte)'D', + (byte)'E', (byte)'F' + }; public static final ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap(new byte[0]); @@ -589,17 +589,6 @@ public static String toString(ByteBuffer buffer) return toString(buffer, StandardCharsets.ISO_8859_1); } - /** - * Convert the buffer to an UTF-8 String - * - * @param buffer The buffer to convert in flush mode. The buffer is unchanged - * @return The buffer as a string. - */ - public static String toUTF8String(ByteBuffer buffer) - { - return toString(buffer, StandardCharsets.UTF_8); - } - /** * Convert the buffer to an ISO-8859-1 String * @@ -647,6 +636,17 @@ public static String toString(ByteBuffer buffer, int position, int length, Chars return new String(array, buffer.arrayOffset() + position, length, charset); } + /** + * Convert the buffer to an UTF-8 String + * + * @param buffer The buffer to convert in flush mode. The buffer is unchanged + * @return The buffer as a string. + */ + public static String toUTF8String(ByteBuffer buffer) + { + return toString(buffer, StandardCharsets.UTF_8); + } + /** * Convert buffer to an integer. Parses up to the first non-numeric character. If no number is found an IllegalArgumentException is thrown * @@ -964,6 +964,29 @@ public static ByteBuffer toBuffer(byte[] array, int offset, int length) return ByteBuffer.wrap(array, offset, length); } + public static ByteBuffer toBuffer(Resource resource, boolean direct) throws IOException + { + int len = (int)resource.length(); + if (len < 0) + throw new IllegalArgumentException("invalid resource: " + String.valueOf(resource) + " len=" + len); + + ByteBuffer buffer = direct ? BufferUtil.allocateDirect(len) : BufferUtil.allocate(len); + + int pos = BufferUtil.flipToFill(buffer); + if (resource.getFile() != null) + BufferUtil.readFrom(resource.getFile(), buffer); + else + { + try (InputStream is = resource.getInputStream();) + { + BufferUtil.readFrom(is, len, buffer); + } + } + BufferUtil.flipToFlush(buffer, pos); + + return buffer; + } + public static ByteBuffer toDirectBuffer(String s) { return toDirectBuffer(s, StandardCharsets.ISO_8859_1); @@ -988,29 +1011,6 @@ public static ByteBuffer toMappedBuffer(File file) throws IOException } } - public static ByteBuffer toBuffer(Resource resource, boolean direct) throws IOException - { - int len = (int)resource.length(); - if (len < 0) - throw new IllegalArgumentException("invalid resource: " + String.valueOf(resource) + " len=" + len); - - ByteBuffer buffer = direct ? BufferUtil.allocateDirect(len) : BufferUtil.allocate(len); - - int pos = BufferUtil.flipToFill(buffer); - if (resource.getFile() != null) - BufferUtil.readFrom(resource.getFile(), buffer); - else - { - try (InputStream is = resource.getInputStream();) - { - BufferUtil.readFrom(is, len, buffer); - } - } - BufferUtil.flipToFlush(buffer, pos); - - return buffer; - } - public static String toSummaryString(ByteBuffer buffer) { if (buffer == null) @@ -1042,6 +1042,36 @@ public static String toDetailString(ByteBuffer[] buffer) return builder.toString(); } + /** + * Convert Buffer to a detail debug string of pointers and content + * + * @param buffer the buffer to generate a detail string from + * @return A string showing the pointers and content of the buffer + */ + public static String toDetailString(ByteBuffer buffer) + { + if (buffer == null) + return "null"; + + StringBuilder buf = new StringBuilder(); + idString(buffer, buf); + buf.append("[p="); + buf.append(buffer.position()); + buf.append(",l="); + buf.append(buffer.limit()); + buf.append(",c="); + buf.append(buffer.capacity()); + buf.append(",r="); + buf.append(buffer.remaining()); + buf.append("]={"); + + appendDebugString(buf, buffer); + + buf.append("}"); + + return buf.toString(); + } + /** * Convert Buffer to string ID independent of content */ @@ -1075,36 +1105,6 @@ public static String toIDString(ByteBuffer buffer) return buf.toString(); } - /** - * Convert Buffer to a detail debug string of pointers and content - * - * @param buffer the buffer to generate a detail string from - * @return A string showing the pointers and content of the buffer - */ - public static String toDetailString(ByteBuffer buffer) - { - if (buffer == null) - return "null"; - - StringBuilder buf = new StringBuilder(); - idString(buffer, buf); - buf.append("[p="); - buf.append(buffer.position()); - buf.append(",l="); - buf.append(buffer.limit()); - buf.append(",c="); - buf.append(buffer.capacity()); - buf.append(",r="); - buf.append(buffer.remaining()); - buf.append("]={"); - - appendDebugString(buf, buffer); - - buf.append("}"); - - return buf.toString(); - } - private static void appendDebugString(StringBuilder buf, ByteBuffer buffer) { // Take a readonly copy so we can adjust the limit @@ -1206,17 +1206,21 @@ public static String toHexString(ByteBuffer buffer) } private static final int[] decDivisors = - {1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1}; + { + 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1 + }; private static final int[] hexDivisors = - {0x10000000, 0x1000000, 0x100000, 0x10000, 0x1000, 0x100, 0x10, 0x1}; + { + 0x10000000, 0x1000000, 0x100000, 0x10000, 0x1000, 0x100, 0x10, 0x1 + }; private static final long[] decDivisorsL = - { - 1000000000000000000L, 100000000000000000L, 10000000000000000L, 1000000000000000L, 100000000000000L, 10000000000000L, - 1000000000000L, 100000000000L, - 10000000000L, 1000000000L, 100000000L, 10000000L, 1000000L, 100000L, 10000L, 1000L, 100L, 10L, 1L - }; + { + 1000000000000000000L, 100000000000000000L, 10000000000000000L, 1000000000000000L, 100000000000000L, 10000000000000L, + 1000000000000L, 100000000000L, + 10000000000L, 1000000000L, 100000000L, 10000000L, 1000000L, 100000L, 10000L, 1000L, 100L, 10L, 1L + }; public static void putCRLF(ByteBuffer buffer) { diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Callback.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Callback.java index b036a75abb84..e50799fa12f4 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Callback.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Callback.java @@ -269,7 +269,6 @@ public void failed(Throwable x) }; } - class Completing implements Callback { @Override diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java b/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java index 9ef616b617bc..7d2b1d66cec9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java @@ -104,8 +104,8 @@ public DateCache(String format, Locale l, TimeZone tz) int zIndex = _formatString.indexOf("ZZZ"); if (zIndex >= 0) { - String ss1 = _formatString.substring(0, zIndex); - String ss2 = _formatString.substring(zIndex + 3); + final String ss1 = _formatString.substring(0, zIndex); + final String ss2 = _formatString.substring(zIndex + 3); int tzOffset = tz.getRawOffset(); StringBuilder sb = new StringBuilder(_formatString.length() + 10); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartWriter.java b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartWriter.java index d029c14e57e2..160671734122 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartWriter.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartWriter.java @@ -99,19 +99,6 @@ public void startPart(String contentType) inPart = true; } - /** - * end creation of the next Content. - * - * @throws IOException if unable to write the part - */ - public void endPart() - throws IOException - { - if (inPart) - out.write(__CRLF); - inPart = false; - } - /** * Start creation of the next Content. * @@ -138,6 +125,19 @@ public void startPart(String contentType, String[] headers) out.write(__CRLF); inPart = true; } + + /** + * end creation of the next Content. + * + * @throws IOException if unable to write the part + */ + public void endPart() + throws IOException + { + if (inPart) + out.write(__CRLF); + inPart = false; + } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/PathWatcher.java b/jetty-util/src/main/java/org/eclipse/jetty/util/PathWatcher.java index d824bfbc10ce..9a7a21678901 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/PathWatcher.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/PathWatcher.java @@ -1276,6 +1276,9 @@ public void handleWatchEvent(Path path, PathWatchEvent event) pending.remove(path); events.add(event); break; + + default: + throw new IllegalStateException(event.toString()); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java b/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java index 3abfff1bc1de..da2d3da67e5c 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java @@ -207,6 +207,9 @@ else if (c == '\\') _token.append(c); } break; + + default: + throw new IllegalStateException(); } } @@ -358,12 +361,12 @@ public static String quote(String s) /** * Quote a string into an Appendable. - * Only quotes and backslash are escaped. + * The characters ", \, \n, \r, \t, \f and \b are escaped * * @param buffer The Appendable * @param input The String to quote. */ - public static void quoteOnly(Appendable buffer, String input) + public static void quote(Appendable buffer, String input) { if (input == null) return; @@ -374,9 +377,28 @@ public static void quoteOnly(Appendable buffer, String input) for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); - if (c == '"' || c == '\\') - buffer.append('\\'); - buffer.append(c); + if (c >= 32) + { + if (c == '"' || c == '\\') + buffer.append('\\'); + buffer.append(c); + } + else + { + char escape = escapes[c]; + if (escape == 0xFFFF) + { + // Unicode escape + buffer.append('\\').append('u').append('0').append('0'); + if (c < 0x10) + buffer.append('0'); + buffer.append(Integer.toString(c, 16)); + } + else + { + buffer.append('\\').append(escape); + } + } } buffer.append('"'); } @@ -388,12 +410,12 @@ public static void quoteOnly(Appendable buffer, String input) /** * Quote a string into an Appendable. - * The characters ", \, \n, \r, \t, \f and \b are escaped + * Only quotes and backslash are escaped. * * @param buffer The Appendable * @param input The String to quote. */ - public static void quote(Appendable buffer, String input) + public static void quoteOnly(Appendable buffer, String input) { if (input == null) return; @@ -404,28 +426,9 @@ public static void quote(Appendable buffer, String input) for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); - if (c >= 32) - { - if (c == '"' || c == '\\') - buffer.append('\\'); - buffer.append(c); - } - else - { - char escape = escapes[c]; - if (escape == 0xFFFF) - { - // Unicode escape - buffer.append('\\').append('u').append('0').append('0'); - if (c < 0x10) - buffer.append('0'); - buffer.append(Integer.toString(c, 16)); - } - else - { - buffer.append('\\').append(escape); - } - } + if (c == '"' || c == '\\') + buffer.append('\\'); + buffer.append(c); } buffer.append('"'); } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java index a3a7d0961299..81e94d01d379 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java @@ -475,6 +475,9 @@ public synchronized void reportDifferences(Map currentScan, M case REMOVED: case CHANGED: _notifications.put(file, Notification.CHANGED); + break; + default: + break; } } } @@ -487,6 +490,9 @@ else if (!oldScan.get(file).equals(currentScan.get(file))) { case ADDED: _notifications.put(file, Notification.ADDED); + break; + default: + break; } } } @@ -504,6 +510,9 @@ else if (!oldScan.get(file).equals(currentScan.get(file))) { case ADDED: _notifications.remove(file); + break; + default: + break; } } } @@ -544,6 +553,8 @@ else if (currentScan.containsKey(file)) case REMOVED: reportRemoval(file); break; + default: + break; } } if (!bulkChanges.isEmpty()) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java index 7bba48705e73..51ec5e98d61b 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java @@ -88,24 +88,24 @@ public static String normalizeCharset(String s, int offset, int length) // @checkstyle-disable-check : IllegalTokenTextCheck public static final char[] lowercases = - { - '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', - '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', - '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', - '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', - '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', - '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', - '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', - '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', - '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', - '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177' - }; + { + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177' + }; // @checkstyle-enable-check : IllegalTokenTextCheck @@ -671,11 +671,6 @@ public static byte[] getBytes(String s) return s.getBytes(StandardCharsets.ISO_8859_1); } - public static byte[] getUtf8Bytes(String s) - { - return s.getBytes(StandardCharsets.UTF_8); - } - public static byte[] getBytes(String s, String charset) { try @@ -689,6 +684,11 @@ public static byte[] getBytes(String s, String charset) } } + public static byte[] getUtf8Bytes(String s) + { + return s.getBytes(StandardCharsets.UTF_8); + } + /** * Convert String to an integer. Parses up to the first non-numeric character. If no number is found an IllegalArgumentException is thrown * @@ -883,6 +883,7 @@ public static List csvSplit(List list, String s, int off, int le state = CsvSplitState.DATA; out.append(ch); continue; + case DATA: if (Character.isWhitespace(ch)) { @@ -922,6 +923,7 @@ public static List csvSplit(List list, String s, int off, int le out.append(ch); last = -1; continue; + case QUOTE: if ('\\' == ch) { @@ -950,6 +952,9 @@ public static List csvSplit(List list, String s, int off, int le continue; } continue; + + default: + throw new IllegalStateException(state.toString()); } } switch (state) @@ -957,6 +962,7 @@ public static List csvSplit(List list, String s, int off, int le case PRE_DATA: case POST_DATA: break; + case DATA: case QUOTE: case SLOSH: @@ -967,6 +973,9 @@ public static List csvSplit(List list, String s, int off, int le out.setLength(last); list.add(out.toString()); break; + + default: + throw new IllegalStateException(state.toString()); } return list; 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 bd40716fdcfb..738c3879afc0 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 @@ -622,14 +622,14 @@ public static URI getLocationOfClass(Class clazz) return null; } - public static URI getClassLoaderLocation(Class clazz) + public static URI getSystemClassLoaderLocation(Class clazz) { - return getClassLoaderLocation(clazz, clazz.getClassLoader()); + return getClassLoaderLocation(clazz, ClassLoader.getSystemClassLoader()); } - public static URI getSystemClassLoaderLocation(Class clazz) + public static URI getClassLoaderLocation(Class clazz) { - return getClassLoaderLocation(clazz, ClassLoader.getSystemClassLoader()); + return getClassLoaderLocation(clazz, clazz.getClassLoader()); } public static URI getClassLoaderLocation(Class clazz, ClassLoader loader) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Uptime.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Uptime.java index 2c925769ab1d..ed1b19656fff 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Uptime.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Uptime.java @@ -43,10 +43,10 @@ public DefaultImpl() ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { - Class mgmtFactory = Class.forName("java.lang.management.ManagementFactory", true, cl); - Class runtimeClass = Class.forName("java.lang.management.RuntimeMXBean", true, cl); - Class[] noParams = new Class[0]; - Method mxBeanMethod = mgmtFactory.getMethod("getRuntimeMXBean", noParams); + final Class mgmtFactory = Class.forName("java.lang.management.ManagementFactory", true, cl); + final Class runtimeClass = Class.forName("java.lang.management.RuntimeMXBean", true, cl); + final Class[] noParams = new Class[0]; + final Method mxBeanMethod = mgmtFactory.getMethod("getRuntimeMXBean", noParams); if (mxBeanMethod == null) { throw new UnsupportedOperationException("method getRuntimeMXBean() not found"); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java index 3e31f12d38fd..ab6877d58d1b 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java @@ -269,6 +269,8 @@ else if (value != null && value.length() > 0) case '%': encoded = true; break; + default: + break; } } @@ -291,6 +293,146 @@ else if (mark < content.length()) } } + /** + * Decoded parameters to Map. + * + * @param in the stream containing the encoded parameters + * @param map the MultiMap to decode into + * @param charset the charset to use for decoding + * @param maxLength the maximum length of the form to decode + * @param maxKeys the maximum number of keys to decode + * @throws IOException if unable to decode input stream + */ + public static void decodeTo(InputStream in, MultiMap map, String charset, int maxLength, int maxKeys) + throws IOException + { + if (charset == null) + { + if (ENCODING.equals(StandardCharsets.UTF_8)) + decodeUtf8To(in, map, maxLength, maxKeys); + else + decodeTo(in, map, ENCODING, maxLength, maxKeys); + } + else if (StringUtil.__UTF8.equalsIgnoreCase(charset)) + decodeUtf8To(in, map, maxLength, maxKeys); + else if (StringUtil.__ISO_8859_1.equalsIgnoreCase(charset)) + decode88591To(in, map, maxLength, maxKeys); + else if (StringUtil.__UTF16.equalsIgnoreCase(charset)) + decodeUtf16To(in, map, maxLength, maxKeys); + else + decodeTo(in, map, Charset.forName(charset), maxLength, maxKeys); + } + + /** + * Decoded parameters to Map. + * + * @param in the stream containing the encoded parameters + * @param map the MultiMap to decode into + * @param charset the charset to use for decoding + * @param maxLength the maximum length of the form to decode + * @param maxKeys the maximum number of keys to decode + * @throws IOException if unable to decode input stream + */ + public static void decodeTo(InputStream in, MultiMap map, Charset charset, int maxLength, int maxKeys) + throws IOException + { + //no charset present, use the configured default + if (charset == null) + charset = ENCODING; + + if (StandardCharsets.UTF_8.equals(charset)) + { + decodeUtf8To(in, map, maxLength, maxKeys); + return; + } + + if (StandardCharsets.ISO_8859_1.equals(charset)) + { + decode88591To(in, map, maxLength, maxKeys); + return; + } + + if (StandardCharsets.UTF_16.equals(charset)) // Should be all 2 byte encodings + { + decodeUtf16To(in, map, maxLength, maxKeys); + return; + } + + synchronized (map) + { + String key = null; + String value = null; + + int c; + + int totalLength = 0; + + try (ByteArrayOutputStream2 output = new ByteArrayOutputStream2();) + { + int size = 0; + + while ((c = in.read()) > 0) + { + switch ((char)c) + { + case '&': + size = output.size(); + value = size == 0 ? "" : output.toString(charset); + output.setCount(0); + if (key != null) + { + map.add(key, value); + } + else if (value != null && value.length() > 0) + { + map.add(value, ""); + } + key = null; + value = null; + if (maxKeys > 0 && map.size() > maxKeys) + throw new IllegalStateException(String.format("Form with too many keys [%d > %d]", map.size(), maxKeys)); + break; + case '=': + if (key != null) + { + output.write(c); + break; + } + size = output.size(); + key = size == 0 ? "" : output.toString(charset); + output.setCount(0); + break; + case '+': + output.write(' '); + break; + case '%': + int code0 = in.read(); + int code1 = in.read(); + output.write(decodeHexChar(code0, code1)); + break; + default: + output.write(c); + break; + } + + totalLength++; + if (maxLength >= 0 && totalLength > maxLength) + throw new IllegalStateException("Form is too large"); + } + + size = output.size(); + if (key != null) + { + value = size == 0 ? "" : output.toString(charset); + output.setCount(0); + map.add(key, value); + } + else if (size > 0) + map.add(output.toString(charset), ""); + } + } + } + public static void decodeUtf8To(String query, MultiMap map) { decodeUtf8To(query, 0, query.length(), map); @@ -380,20 +522,20 @@ else if (buffer.length() > 0) } /** - * Decoded parameters to MultiMap, using ISO8859-1 encodings. + * Decoded parameters to Map. * * @param in InputSteam to read * @param map MultiMap to add parameters to - * @param maxLength maximum length of form to read - * @param maxKeys maximum number of keys to read or -1 for no limit - * @throws IOException if unable to decode inputstream as ISO8859-1 + * @param maxLength maximum form length to decode + * @param maxKeys the maximum number of keys to read or -1 for no limit + * @throws IOException if unable to decode input stream */ - public static void decode88591To(InputStream in, MultiMap map, int maxLength, int maxKeys) + public static void decodeUtf8To(InputStream in, MultiMap map, int maxLength, int maxKeys) throws IOException { synchronized (map) { - StringBuffer buffer = new StringBuffer(); + Utf8StringBuilder buffer = new Utf8StringBuilder(); String key = null; String value = null; @@ -405,8 +547,8 @@ public static void decode88591To(InputStream in, MultiMap map, int maxLe switch ((char)b) { case '&': - value = buffer.length() == 0 ? "" : buffer.toString(); - buffer.setLength(0); + value = buffer.toReplacedString(); + buffer.reset(); if (key != null) { map.add(key, value); @@ -424,59 +566,69 @@ else if (value != null && value.length() > 0) case '=': if (key != null) { - buffer.append((char)b); + buffer.append((byte)b); break; } - key = buffer.toString(); - buffer.setLength(0); + key = buffer.toReplacedString(); + buffer.reset(); break; case '+': - buffer.append(' '); + buffer.append((byte)' '); break; case '%': - int code0 = in.read(); - int code1 = in.read(); - buffer.append(decodeHexChar(code0, code1)); + char code0 = (char)in.read(); + char code1 = (char)in.read(); + buffer.append(decodeHexByte(code0, code1)); break; default: - buffer.append((char)b); + buffer.append((byte)b); break; } if (maxLength >= 0 && (++totalLength > maxLength)) - throw new IllegalStateException(String.format("Form with too many keys [%d > %d]", map.size(), maxKeys)); + throw new IllegalStateException("Form is too large"); } if (key != null) { - value = buffer.length() == 0 ? "" : buffer.toString(); - buffer.setLength(0); + value = buffer.toReplacedString(); + buffer.reset(); map.add(key, value); } else if (buffer.length() > 0) { - map.add(buffer.toString(), ""); + map.add(buffer.toReplacedString(), ""); } } } + public static void decodeUtf16To(InputStream in, MultiMap map, int maxLength, int maxKeys) throws IOException + { + InputStreamReader input = new InputStreamReader(in, StandardCharsets.UTF_16); + StringWriter buf = new StringWriter(8192); + IO.copy(input, buf, maxLength); + + // TODO implement maxKeys + decodeTo(buf.getBuffer().toString(), map, StandardCharsets.UTF_16); + } + /** - * Decoded parameters to Map. + * Decoded parameters to MultiMap, using ISO8859-1 encodings. * * @param in InputSteam to read * @param map MultiMap to add parameters to - * @param maxLength maximum form length to decode - * @param maxKeys the maximum number of keys to read or -1 for no limit - * @throws IOException if unable to decode input stream + * @param maxLength maximum length of form to read + * @param maxKeys maximum number of keys to read or -1 for no limit + * @throws IOException if unable to decode inputstream as ISO8859-1 */ - public static void decodeUtf8To(InputStream in, MultiMap map, int maxLength, int maxKeys) + public static void decode88591To(InputStream in, MultiMap map, int maxLength, int maxKeys) throws IOException { synchronized (map) { - Utf8StringBuilder buffer = new Utf8StringBuilder(); + StringBuffer buffer = new StringBuffer(); String key = null; String value = null; @@ -488,8 +640,8 @@ public static void decodeUtf8To(InputStream in, MultiMap map, int maxLen switch ((char)b) { case '&': - value = buffer.toReplacedString(); - buffer.reset(); + value = buffer.length() == 0 ? "" : buffer.toString(); + buffer.setLength(0); if (key != null) { map.add(key, value); @@ -507,190 +659,40 @@ else if (value != null && value.length() > 0) case '=': if (key != null) { - buffer.append((byte)b); + buffer.append((char)b); break; } - key = buffer.toReplacedString(); - buffer.reset(); + key = buffer.toString(); + buffer.setLength(0); break; case '+': - buffer.append((byte)' '); + buffer.append(' '); break; case '%': - char code0 = (char)in.read(); - char code1 = (char)in.read(); - buffer.append(decodeHexByte(code0, code1)); + int code0 = in.read(); + int code1 = in.read(); + buffer.append(decodeHexChar(code0, code1)); break; default: - buffer.append((byte)b); + buffer.append((char)b); break; } if (maxLength >= 0 && (++totalLength > maxLength)) - throw new IllegalStateException("Form is too large"); + throw new IllegalStateException(String.format("Form with too many keys [%d > %d]", map.size(), maxKeys)); } if (key != null) { - value = buffer.toReplacedString(); - buffer.reset(); + value = buffer.length() == 0 ? "" : buffer.toString(); + buffer.setLength(0); map.add(key, value); } else if (buffer.length() > 0) { - map.add(buffer.toReplacedString(), ""); - } - } - } - - public static void decodeUtf16To(InputStream in, MultiMap map, int maxLength, int maxKeys) throws IOException - { - InputStreamReader input = new InputStreamReader(in, StandardCharsets.UTF_16); - StringWriter buf = new StringWriter(8192); - IO.copy(input, buf, maxLength); - - // TODO implement maxKeys - decodeTo(buf.getBuffer().toString(), map, StandardCharsets.UTF_16); - } - - /** - * Decoded parameters to Map. - * - * @param in the stream containing the encoded parameters - * @param map the MultiMap to decode into - * @param charset the charset to use for decoding - * @param maxLength the maximum length of the form to decode - * @param maxKeys the maximum number of keys to decode - * @throws IOException if unable to decode input stream - */ - public static void decodeTo(InputStream in, MultiMap map, String charset, int maxLength, int maxKeys) - throws IOException - { - if (charset == null) - { - if (ENCODING.equals(StandardCharsets.UTF_8)) - decodeUtf8To(in, map, maxLength, maxKeys); - else - decodeTo(in, map, ENCODING, maxLength, maxKeys); - } - else if (StringUtil.__UTF8.equalsIgnoreCase(charset)) - decodeUtf8To(in, map, maxLength, maxKeys); - else if (StringUtil.__ISO_8859_1.equalsIgnoreCase(charset)) - decode88591To(in, map, maxLength, maxKeys); - else if (StringUtil.__UTF16.equalsIgnoreCase(charset)) - decodeUtf16To(in, map, maxLength, maxKeys); - else - decodeTo(in, map, Charset.forName(charset), maxLength, maxKeys); - } - - /** - * Decoded parameters to Map. - * - * @param in the stream containing the encoded parameters - * @param map the MultiMap to decode into - * @param charset the charset to use for decoding - * @param maxLength the maximum length of the form to decode - * @param maxKeys the maximum number of keys to decode - * @throws IOException if unable to decode input stream - */ - public static void decodeTo(InputStream in, MultiMap map, Charset charset, int maxLength, int maxKeys) - throws IOException - { - //no charset present, use the configured default - if (charset == null) - charset = ENCODING; - - if (StandardCharsets.UTF_8.equals(charset)) - { - decodeUtf8To(in, map, maxLength, maxKeys); - return; - } - - if (StandardCharsets.ISO_8859_1.equals(charset)) - { - decode88591To(in, map, maxLength, maxKeys); - return; - } - - if (StandardCharsets.UTF_16.equals(charset)) // Should be all 2 byte encodings - { - decodeUtf16To(in, map, maxLength, maxKeys); - return; - } - - synchronized (map) - { - String key = null; - String value = null; - - int c; - - int totalLength = 0; - - try (ByteArrayOutputStream2 output = new ByteArrayOutputStream2();) - { - int size = 0; - - while ((c = in.read()) > 0) - { - switch ((char)c) - { - case '&': - size = output.size(); - value = size == 0 ? "" : output.toString(charset); - output.setCount(0); - if (key != null) - { - map.add(key, value); - } - else if (value != null && value.length() > 0) - { - map.add(value, ""); - } - key = null; - value = null; - if (maxKeys > 0 && map.size() > maxKeys) - throw new IllegalStateException(String.format("Form with too many keys [%d > %d]", map.size(), maxKeys)); - break; - case '=': - if (key != null) - { - output.write(c); - break; - } - size = output.size(); - key = size == 0 ? "" : output.toString(charset); - output.setCount(0); - break; - case '+': - output.write(' '); - break; - case '%': - int code0 = in.read(); - int code1 = in.read(); - output.write(decodeHexChar(code0, code1)); - break; - default: - output.write(c); - break; - } - - totalLength++; - if (maxLength >= 0 && totalLength > maxLength) - throw new IllegalStateException("Form is too large"); - } - - size = output.size(); - if (key != null) - { - value = size == 0 ? "" : output.toString(charset); - output.setCount(0); - map.add(key, value); - } - else if (size > 0) - map.add(output.toString(charset), ""); + map.add(buffer.toString(), ""); } } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java index d7f059839ccd..2c44105a3bc0 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java @@ -61,29 +61,29 @@ public abstract class Utf8Appendable protected int _state = UTF8_ACCEPT; private static final byte[] BYTE_TABLE = - { - // The first part of the table maps bytes to character classes that - // to reduce the size of the transition table and create bitmasks. - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 - }; + { + // The first part of the table maps bytes to character classes that + // to reduce the size of the transition table and create bitmasks. + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 + }; private static final byte[] TRANS_TABLE = - { - // The second part is a transition table that maps a combination - // of a state of the automaton and a character class to a state. - 0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 24, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, - 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 - }; + { + // The second part is a transition table that maps a combination + // of a state of the automaton and a character class to a state. + 0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 24, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, + 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 + }; private int _codep; @@ -248,7 +248,7 @@ protected void appendByte(byte b) throws IOException break; case UTF8_REJECT: - String reason = "byte " + TypeUtil.toHexString(b) + " in state " + (_state / 12); + final String reason = "byte " + TypeUtil.toHexString(b) + " in state " + (_state / 12); _codep = 0; _state = UTF8_ACCEPT; _appendable.append(REPLACEMENT); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8LineParser.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8LineParser.java index c132ae8c040c..d54197f88f56 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8LineParser.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8LineParser.java @@ -76,6 +76,7 @@ private boolean parseByte(byte b) utf = new Utf8StringBuilder(); state = State.PARSE; return parseByte(b); + case PARSE: // not waiting on more UTF sequence parts. if (utf.isUtf8SequenceComplete() && ((b == '\r') || (b == '\n'))) @@ -84,7 +85,8 @@ private boolean parseByte(byte b) return parseByte(b); } utf.append(b); - break; + return false; + case END: if (b == '\n') { @@ -92,8 +94,10 @@ private boolean parseByte(byte b) state = State.START; return true; } - break; + return false; + + default: + throw new IllegalStateException(); } - return false; } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java index e9fcce47b7fd..a8626a2bc27d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java @@ -166,8 +166,9 @@ public String getState() return STOPPING; case STATE_STOPPED: return STOPPED; + default: + return null; } - return null; } public static String getState(LifeCycle lc) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java index 8ebbb1671ff0..f348e95dc789 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java @@ -34,6 +34,15 @@ public interface Container */ public boolean addBean(Object o); + /** + * Adds the given bean, explicitly managing it or not. + * + * @param o The bean object to add + * @param managed whether to managed the lifecycle of the bean + * @return true if the bean was added, false if it was already present + */ + boolean addBean(Object o, boolean managed); + /** * @return the list of beans known to this aggregate * @see #getBean(Class) @@ -105,15 +114,6 @@ public interface Container */ boolean isManaged(Object bean); - /** - * Adds the given bean, explicitly managing it or not. - * - * @param o The bean object to add - * @param managed whether to managed the lifecycle of the bean - * @return true if the bean was added, false if it was already present - */ - boolean addBean(Object o, boolean managed); - /** * A listener for Container events. * If an added bean implements this interface it will receive the events diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java index 1eb91aafbfdd..835534f2d19f 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java @@ -395,6 +395,10 @@ else if (isStarted()) case POJO: newBean._managed = Managed.POJO; + break; + + default: + throw new IllegalStateException(managed.toString()); } } catch (RuntimeException | Error e) @@ -546,12 +550,6 @@ private void unmanage(Bean bean) } } - @Override - public Collection getBeans() - { - return getBeans(Object.class); - } - public void setBeans(Collection beans) { for (Object bean : beans) @@ -560,6 +558,12 @@ public void setBeans(Collection beans) } } + @Override + public Collection getBeans() + { + return getBeans(Object.class); + } + @Override public Collection getBeans(Class clazz) { @@ -587,6 +591,16 @@ public T getBean(Class clazz) return null; } + private Bean getBean(Object o) + { + for (Bean b : _beans) + { + if (b._bean == o) + return b; + } + return null; + } + /** * Removes all bean */ @@ -599,16 +613,6 @@ public void removeBeans() } } - private Bean getBean(Object o) - { - for (Bean b : _beans) - { - if (b._bean == o) - return b; - } - return null; - } - @Override public boolean removeBean(Object o) { @@ -620,7 +624,7 @@ private boolean remove(Bean bean) { if (_beans.remove(bean)) { - boolean wasManaged = bean.isManaged(); + final boolean wasManaged = bean.isManaged(); unmanage(bean); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/LifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/LifeCycle.java index 36cb406d4eb1..58f4b9b83976 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/LifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/LifeCycle.java @@ -32,7 +32,6 @@ @ManagedObject("Lifecycle Interface for startable components") public interface LifeCycle { - /** * Starts the component. * @@ -42,9 +41,31 @@ public interface LifeCycle * @see #isFailed() */ @ManagedOperation(value = "Starts the instance", impact = "ACTION") - public void start() + void start() throws Exception; + /** + * Utility to start an object if it is a LifeCycle and to convert + * any exception thrown to a {@link RuntimeException} + * + * @param object The instance to start. + * @throws RuntimeException if the call to start throws an exception. + */ + static void start(Object object) + { + if (object instanceof LifeCycle) + { + try + { + ((LifeCycle)object).start(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + } + /** * Stops the component. * The component may wait for current activities to complete @@ -56,54 +77,76 @@ public void start() * @see #isFailed() */ @ManagedOperation(value = "Stops the instance", impact = "ACTION") - public void stop() + void stop() throws Exception; + /** + * Utility to stop an object if it is a LifeCycle and to convert + * any exception thrown to a {@link RuntimeException} + * + * @param object The instance to stop. + * @throws RuntimeException if the call to stop throws an exception. + */ + static void stop(Object object) + { + if (object instanceof LifeCycle) + { + try + { + ((LifeCycle)object).stop(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + } + /** * @return true if the component is starting or has been started. */ - public boolean isRunning(); + boolean isRunning(); /** * @return true if the component has been started. * @see #start() * @see #isStarting() */ - public boolean isStarted(); + boolean isStarted(); /** * @return true if the component is starting. * @see #isStarted() */ - public boolean isStarting(); + boolean isStarting(); /** * @return true if the component is stopping. * @see #isStopped() */ - public boolean isStopping(); + boolean isStopping(); /** * @return true if the component has been stopped. * @see #stop() * @see #isStopping() */ - public boolean isStopped(); + boolean isStopped(); /** * @return true if the component has failed to start or has failed to stop. */ - public boolean isFailed(); + boolean isFailed(); - public void addLifeCycleListener(LifeCycle.Listener listener); + void addLifeCycleListener(LifeCycle.Listener listener); - public void removeLifeCycleListener(LifeCycle.Listener listener); + void removeLifeCycleListener(LifeCycle.Listener listener); /** * Listener. * A listener for Lifecycle events. */ - public interface Listener extends EventListener + interface Listener extends EventListener { default void lifeCycleStarting(LifeCycle event) { @@ -125,48 +168,4 @@ default void lifeCycleStopped(LifeCycle event) { } } - - /** - * Utility to start an object if it is a LifeCycle and to convert - * any exception thrown to a {@link RuntimeException} - * - * @param object The instance to start. - * @throws RuntimeException if the call to start throws an exception. - */ - public static void start(Object object) - { - if (object instanceof LifeCycle) - { - try - { - ((LifeCycle)object).start(); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - } - - /** - * Utility to stop an object if it is a LifeCycle and to convert - * any exception thrown to a {@link RuntimeException} - * - * @param object The instance to stop. - * @throws RuntimeException if the call to stop throws an exception. - */ - public static void stop(Object object) - { - if (object instanceof LifeCycle) - { - try - { - ((LifeCycle)object).stop(); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java index 20834dabd1a1..b7dc11807bf2 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java @@ -45,558 +45,558 @@ public JettyAwareLogger(org.slf4j.spi.LocationAwareLogger logger) } /** - * @see org.slf4j.Logger#getName() + * @see org.slf4j.Logger#debug(java.lang.String) */ @Override - public String getName() + public void debug(String msg) { - return _logger.getName(); + log(null, DEBUG, msg, null, null); } /** - * @see org.slf4j.Logger#isTraceEnabled() + * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object) */ @Override - public boolean isTraceEnabled() + public void debug(String format, Object arg) { - return _logger.isTraceEnabled(); + log(null, DEBUG, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#trace(java.lang.String) + * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public void trace(String msg) + public void debug(String format, Object arg1, Object arg2) { - log(null, TRACE, msg, null, null); + log(null, DEBUG, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object[]) */ @Override - public void trace(String format, Object arg) + public void debug(String format, Object[] argArray) { - log(null, TRACE, format, new Object[]{arg}, null); + log(null, DEBUG, format, argArray, null); } /** - * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Throwable) */ @Override - public void trace(String format, Object arg1, Object arg2) + public void debug(String msg, Throwable t) { - log(null, TRACE, format, new Object[]{arg1, arg2}, null); + log(null, DEBUG, msg, null, t); } /** - * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String) */ @Override - public void trace(String format, Object[] argArray) + public void debug(Marker marker, String msg) { - log(null, TRACE, format, argArray, null); + log(marker, DEBUG, msg, null, null); } /** - * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Object) */ @Override - public void trace(String msg, Throwable t) + public void debug(Marker marker, String format, Object arg) { - log(null, TRACE, msg, null, t); + log(marker, DEBUG, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#isTraceEnabled(org.slf4j.Marker) + * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public boolean isTraceEnabled(Marker marker) + public void debug(Marker marker, String format, Object arg1, Object arg2) { - return _logger.isTraceEnabled(marker); + log(marker, DEBUG, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String) + * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Object[]) */ @Override - public void trace(Marker marker, String msg) + public void debug(Marker marker, String format, Object[] argArray) { - log(marker, TRACE, msg, null, null); + log(marker, DEBUG, format, argArray, null); } /** - * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Throwable) */ @Override - public void trace(Marker marker, String format, Object arg) + public void debug(Marker marker, String msg, Throwable t) { - log(marker, TRACE, format, new Object[]{arg}, null); + log(marker, DEBUG, msg, null, t); } /** - * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#error(java.lang.String) */ @Override - public void trace(Marker marker, String format, Object arg1, Object arg2) + public void error(String msg) { - log(marker, TRACE, format, new Object[]{arg1, arg2}, null); + log(null, ERROR, msg, null, null); } /** - * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object) */ @Override - public void trace(Marker marker, String format, Object[] argArray) + public void error(String format, Object arg) { - log(marker, TRACE, format, argArray, null); + log(null, ERROR, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public void trace(Marker marker, String msg, Throwable t) + public void error(String format, Object arg1, Object arg2) { - log(marker, TRACE, msg, null, t); + log(null, ERROR, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#isDebugEnabled() + * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object[]) */ @Override - public boolean isDebugEnabled() + public void error(String format, Object[] argArray) { - return _logger.isDebugEnabled(); + log(null, ERROR, format, argArray, null); } /** - * @see org.slf4j.Logger#debug(java.lang.String) + * @see org.slf4j.Logger#error(java.lang.String, java.lang.Throwable) */ @Override - public void debug(String msg) + public void error(String msg, Throwable t) { - log(null, DEBUG, msg, null, null); + log(null, ERROR, msg, null, t); } /** - * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String) */ @Override - public void debug(String format, Object arg) + public void error(Marker marker, String msg) { - log(null, DEBUG, format, new Object[]{arg}, null); + log(marker, ERROR, msg, null, null); } /** - * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Object) */ @Override - public void debug(String format, Object arg1, Object arg2) + public void error(Marker marker, String format, Object arg) { - log(null, DEBUG, format, new Object[]{arg1, arg2}, null); + log(marker, ERROR, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public void debug(String format, Object[] argArray) + public void error(Marker marker, String format, Object arg1, Object arg2) { - log(null, DEBUG, format, argArray, null); + log(marker, ERROR, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#debug(java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Object[]) */ @Override - public void debug(String msg, Throwable t) + public void error(Marker marker, String format, Object[] argArray) { - log(null, DEBUG, msg, null, t); + log(marker, ERROR, format, argArray, null); } /** - * @see org.slf4j.Logger#isDebugEnabled(org.slf4j.Marker) + * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Throwable) */ @Override - public boolean isDebugEnabled(Marker marker) + public void error(Marker marker, String msg, Throwable t) { - return _logger.isDebugEnabled(marker); + log(marker, ERROR, msg, null, t); } /** - * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String) + * @see org.slf4j.Logger#getName() */ @Override - public void debug(Marker marker, String msg) + public String getName() { - log(marker, DEBUG, msg, null, null); + return _logger.getName(); } /** - * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#info(java.lang.String) */ @Override - public void debug(Marker marker, String format, Object arg) + public void info(String msg) { - log(marker, DEBUG, format, new Object[]{arg}, null); + log(null, INFO, msg, null, null); } /** - * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object) */ @Override - public void debug(Marker marker, String format, Object arg1, Object arg2) + public void info(String format, Object arg) { - log(marker, DEBUG, format, new Object[]{arg1, arg2}, null); + log(null, INFO, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public void debug(Marker marker, String format, Object[] argArray) + public void info(String format, Object arg1, Object arg2) { - log(marker, DEBUG, format, argArray, null); + log(null, INFO, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#debug(org.slf4j.Marker, java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object[]) */ @Override - public void debug(Marker marker, String msg, Throwable t) + public void info(String format, Object[] argArray) { - log(marker, DEBUG, msg, null, t); + log(null, INFO, format, argArray, null); } /** - * @see org.slf4j.Logger#isInfoEnabled() + * @see org.slf4j.Logger#info(java.lang.String, java.lang.Throwable) */ @Override - public boolean isInfoEnabled() + public void info(String msg, Throwable t) { - return _logger.isInfoEnabled(); + log(null, INFO, msg, null, t); } /** - * @see org.slf4j.Logger#info(java.lang.String) + * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String) */ @Override - public void info(String msg) + public void info(Marker marker, String msg) { - log(null, INFO, msg, null, null); + log(marker, INFO, msg, null, null); } /** - * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Object) */ @Override - public void info(String format, Object arg) + public void info(Marker marker, String format, Object arg) { - log(null, INFO, format, new Object[]{arg}, null); + log(marker, INFO, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public void info(String format, Object arg1, Object arg2) + public void info(Marker marker, String format, Object arg1, Object arg2) { - log(null, INFO, format, new Object[]{arg1, arg2}, null); + log(marker, INFO, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#info(java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Object[]) */ @Override - public void info(String format, Object[] argArray) + public void info(Marker marker, String format, Object[] argArray) { - log(null, INFO, format, argArray, null); + log(marker, INFO, format, argArray, null); } /** - * @see org.slf4j.Logger#info(java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Throwable) */ @Override - public void info(String msg, Throwable t) + public void info(Marker marker, String msg, Throwable t) { - log(null, INFO, msg, null, t); + log(marker, INFO, msg, null, t); } /** - * @see org.slf4j.Logger#isInfoEnabled(org.slf4j.Marker) + * @see org.slf4j.Logger#isDebugEnabled() */ @Override - public boolean isInfoEnabled(Marker marker) + public boolean isDebugEnabled() { - return _logger.isInfoEnabled(marker); + return _logger.isDebugEnabled(); } /** - * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String) + * @see org.slf4j.Logger#isDebugEnabled(org.slf4j.Marker) */ @Override - public void info(Marker marker, String msg) + public boolean isDebugEnabled(Marker marker) { - log(marker, INFO, msg, null, null); + return _logger.isDebugEnabled(marker); } /** - * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#isErrorEnabled() */ @Override - public void info(Marker marker, String format, Object arg) + public boolean isErrorEnabled() { - log(marker, INFO, format, new Object[]{arg}, null); + return _logger.isErrorEnabled(); } /** - * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#isErrorEnabled(org.slf4j.Marker) */ @Override - public void info(Marker marker, String format, Object arg1, Object arg2) + public boolean isErrorEnabled(Marker marker) { - log(marker, INFO, format, new Object[]{arg1, arg2}, null); + return _logger.isErrorEnabled(marker); } /** - * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#isInfoEnabled() */ @Override - public void info(Marker marker, String format, Object[] argArray) + public boolean isInfoEnabled() { - log(marker, INFO, format, argArray, null); + return _logger.isInfoEnabled(); } /** - * @see org.slf4j.Logger#info(org.slf4j.Marker, java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#isInfoEnabled(org.slf4j.Marker) */ @Override - public void info(Marker marker, String msg, Throwable t) + public boolean isInfoEnabled(Marker marker) { - log(marker, INFO, msg, null, t); + return _logger.isInfoEnabled(marker); } /** - * @see org.slf4j.Logger#isWarnEnabled() + * @see org.slf4j.Logger#isTraceEnabled() */ @Override - public boolean isWarnEnabled() + public boolean isTraceEnabled() { - return _logger.isWarnEnabled(); + return _logger.isTraceEnabled(); } /** - * @see org.slf4j.Logger#warn(java.lang.String) + * @see org.slf4j.Logger#isTraceEnabled(org.slf4j.Marker) */ @Override - public void warn(String msg) + public boolean isTraceEnabled(Marker marker) { - log(null, WARN, msg, null, null); + return _logger.isTraceEnabled(marker); } /** - * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#isWarnEnabled() */ @Override - public void warn(String format, Object arg) + public boolean isWarnEnabled() { - log(null, WARN, format, new Object[]{arg}, null); + return _logger.isWarnEnabled(); } /** - * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#isWarnEnabled(org.slf4j.Marker) */ @Override - public void warn(String format, Object[] argArray) + public boolean isWarnEnabled(Marker marker) { - log(null, WARN, format, argArray, null); + return _logger.isWarnEnabled(marker); } - /** - * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object, java.lang.Object) - */ @Override - public void warn(String format, Object arg1, Object arg2) + public String toString() { - log(null, WARN, format, new Object[]{arg1, arg2}, null); + return _logger.toString(); } /** - * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#trace(java.lang.String) */ @Override - public void warn(String msg, Throwable t) + public void trace(String msg) { - log(null, WARN, msg, null, t); + log(null, TRACE, msg, null, null); } /** - * @see org.slf4j.Logger#isWarnEnabled(org.slf4j.Marker) + * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object) */ @Override - public boolean isWarnEnabled(Marker marker) + public void trace(String format, Object arg) { - return _logger.isWarnEnabled(marker); + log(null, TRACE, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String) + * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public void warn(Marker marker, String msg) + public void trace(String format, Object arg1, Object arg2) { - log(marker, WARN, msg, null, null); + log(null, TRACE, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Object[]) */ @Override - public void warn(Marker marker, String format, Object arg) + public void trace(String format, Object[] argArray) { - log(marker, WARN, format, new Object[]{arg}, null); + log(null, TRACE, format, argArray, null); } /** - * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#trace(java.lang.String, java.lang.Throwable) */ @Override - public void warn(Marker marker, String format, Object arg1, Object arg2) + public void trace(String msg, Throwable t) { - log(marker, WARN, format, new Object[]{arg1, arg2}, null); + log(null, TRACE, msg, null, t); } /** - * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String) */ @Override - public void warn(Marker marker, String format, Object[] argArray) + public void trace(Marker marker, String msg) { - log(marker, WARN, format, argArray, null); + log(marker, TRACE, msg, null, null); } /** - * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Object) */ @Override - public void warn(Marker marker, String msg, Throwable t) + public void trace(Marker marker, String format, Object arg) { - log(marker, WARN, msg, null, t); + log(marker, TRACE, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#isErrorEnabled() + * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public boolean isErrorEnabled() + public void trace(Marker marker, String format, Object arg1, Object arg2) { - return _logger.isErrorEnabled(); + log(marker, TRACE, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#error(java.lang.String) + * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Object[]) */ @Override - public void error(String msg) + public void trace(Marker marker, String format, Object[] argArray) { - log(null, ERROR, msg, null, null); + log(marker, TRACE, format, argArray, null); } /** - * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#trace(org.slf4j.Marker, java.lang.String, java.lang.Throwable) */ @Override - public void error(String format, Object arg) + public void trace(Marker marker, String msg, Throwable t) { - log(null, ERROR, format, new Object[]{arg}, null); + log(marker, TRACE, msg, null, t); } /** - * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#warn(java.lang.String) */ @Override - public void error(String format, Object arg1, Object arg2) + public void warn(String msg) { - log(null, ERROR, format, new Object[]{arg1, arg2}, null); + log(null, WARN, msg, null, null); } /** - * @see org.slf4j.Logger#error(java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object) */ @Override - public void error(String format, Object[] argArray) + public void warn(String format, Object arg) { - log(null, ERROR, format, argArray, null); + log(null, WARN, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#error(java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object[]) */ @Override - public void error(String msg, Throwable t) + public void warn(String format, Object[] argArray) { - log(null, ERROR, msg, null, t); + log(null, WARN, format, argArray, null); } /** - * @see org.slf4j.Logger#isErrorEnabled(org.slf4j.Marker) + * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public boolean isErrorEnabled(Marker marker) + public void warn(String format, Object arg1, Object arg2) { - return _logger.isErrorEnabled(marker); + log(null, WARN, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String) + * @see org.slf4j.Logger#warn(java.lang.String, java.lang.Throwable) */ @Override - public void error(Marker marker, String msg) + public void warn(String msg, Throwable t) { - log(marker, ERROR, msg, null, null); + log(null, WARN, msg, null, t); } /** - * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Object) + * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String) */ @Override - public void error(Marker marker, String format, Object arg) + public void warn(Marker marker, String msg) { - log(marker, ERROR, format, new Object[]{arg}, null); + log(marker, WARN, msg, null, null); } /** - * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) + * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Object) */ @Override - public void error(Marker marker, String format, Object arg1, Object arg2) + public void warn(Marker marker, String format, Object arg) { - log(marker, ERROR, format, new Object[]{arg1, arg2}, null); + log(marker, WARN, format, new Object[]{arg}, null); } /** - * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Object[]) + * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public void error(Marker marker, String format, Object[] argArray) + public void warn(Marker marker, String format, Object arg1, Object arg2) { - log(marker, ERROR, format, argArray, null); + log(marker, WARN, format, new Object[]{arg1, arg2}, null); } /** - * @see org.slf4j.Logger#error(org.slf4j.Marker, java.lang.String, java.lang.Throwable) + * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Object[]) */ @Override - public void error(Marker marker, String msg, Throwable t) + public void warn(Marker marker, String format, Object[] argArray) { - log(marker, ERROR, msg, null, t); + log(marker, WARN, format, argArray, null); } + /** + * @see org.slf4j.Logger#warn(org.slf4j.Marker, java.lang.String, java.lang.Throwable) + */ @Override - public String toString() + public void warn(Marker marker, String msg, Throwable t) { - return _logger.toString(); + log(marker, WARN, msg, null, t); } private void log(Marker marker, int level, String msg, Object[] argArray, Throwable t) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/LoggerLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/LoggerLog.java index c3e9696e6e23..e4fe961daa29 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/LoggerLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/LoggerLog.java @@ -42,14 +42,14 @@ public LoggerLog(Object logger) try { _logger = logger; - Class lc = logger.getClass(); + final Class lc = logger.getClass(); _debugMT = lc.getMethod("debug", new Class[]{String.class, Throwable.class}); _debugMAA = lc.getMethod("debug", new Class[]{String.class, Object[].class}); _infoMT = lc.getMethod("info", new Class[]{String.class, Throwable.class}); _infoMAA = lc.getMethod("info", new Class[]{String.class, Object[].class}); _warnMT = lc.getMethod("warn", new Class[]{String.class, Throwable.class}); _warnMAA = lc.getMethod("warn", new Class[]{String.class, Object[].class}); - Method isDebugEnabled = lc.getMethod("isDebugEnabled"); + final Method isDebugEnabled = lc.getMethod("isDebugEnabled"); _setDebugEnabledE = lc.getMethod("setDebugEnabled", new Class[]{Boolean.TYPE}); _getLoggerN = lc.getMethod("getLogger", new Class[]{String.class}); _getName = lc.getMethod("getName"); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java index c3fdb5e4482a..be9ddc11d3d1 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java @@ -456,76 +456,6 @@ private void format(StringBuilder buffer, String level, String msg, Throwable th } } - private void tag(StringBuilder buffer, String d, int ms, String tag) - { - buffer.setLength(0); - buffer.append(d); - if (ms > 99) - { - buffer.append('.'); - } - else if (ms > 9) - { - buffer.append(".0"); - } - else - { - buffer.append(".00"); - } - buffer.append(ms).append(tag); - - String name = _printLongNames ? _name : _abbrevname; - String tname = Thread.currentThread().getName(); - - int p = __tagpad > 0 ? (name.length() + tname.length() - __tagpad) : 0; - - if (p < 0) - { - buffer - .append(name) - .append(':') - .append(" ", 0, -p) - .append(tname); - } - else if (p == 0) - { - buffer.append(name).append(':').append(tname); - } - buffer.append(':'); - - if (_source) - { - Throwable source = new Throwable(); - StackTraceElement[] frames = source.getStackTrace(); - for (int i = 0; i < frames.length; i++) - { - final StackTraceElement frame = frames[i]; - String clazz = frame.getClassName(); - if (clazz.equals(StdErrLog.class.getName()) || clazz.equals(Log.class.getName())) - { - continue; - } - if (!_printLongNames && clazz.startsWith("org.eclipse.jetty.")) - { - buffer.append(condensePackageString(clazz)); - } - else - { - buffer.append(clazz); - } - buffer.append('#').append(frame.getMethodName()); - if (frame.getFileName() != null) - { - buffer.append('(').append(frame.getFileName()).append(':').append(frame.getLineNumber()).append(')'); - } - buffer.append(':'); - break; - } - } - - buffer.append(' '); - } - private void format(StringBuilder builder, String msg, Object... args) { if (msg == null) @@ -558,6 +488,43 @@ private void format(StringBuilder builder, String msg, Object... args) escape(builder, msg.substring(start)); } + protected void format(StringBuilder buffer, Throwable thrown) + { + format(buffer, thrown, ""); + } + + protected void format(StringBuilder buffer, Throwable thrown, String indent) + { + if (thrown == null) + { + buffer.append("null"); + } + else + { + buffer.append(EOL).append(indent); + format(buffer, thrown.toString()); + StackTraceElement[] elements = thrown.getStackTrace(); + for (int i = 0; elements != null && i < elements.length; i++) + { + buffer.append(EOL).append(indent).append("\tat "); + format(buffer, elements[i].toString()); + } + + for (Throwable suppressed : thrown.getSuppressed()) + { + buffer.append(EOL).append(indent).append("Suppressed: "); + format(buffer, suppressed, "\t|" + indent); + } + + Throwable cause = thrown.getCause(); + if (cause != null && cause != thrown) + { + buffer.append(EOL).append(indent).append("Caused by: "); + format(buffer, cause, indent); + } + } + } + private void escape(StringBuilder builder, String string) { if (__escape) @@ -590,41 +557,74 @@ else if (c == '\r') builder.append(string); } - protected void format(StringBuilder buffer, Throwable thrown) - { - format(buffer, thrown, ""); - } - - protected void format(StringBuilder buffer, Throwable thrown, String indent) + private void tag(StringBuilder buffer, String d, int ms, String tag) { - if (thrown == null) + buffer.setLength(0); + buffer.append(d); + if (ms > 99) { - buffer.append("null"); + buffer.append('.'); + } + else if (ms > 9) + { + buffer.append(".0"); } else { - buffer.append(EOL).append(indent); - format(buffer, thrown.toString()); - StackTraceElement[] elements = thrown.getStackTrace(); - for (int i = 0; elements != null && i < elements.length; i++) - { - buffer.append(EOL).append(indent).append("\tat "); - format(buffer, elements[i].toString()); - } + buffer.append(".00"); + } + buffer.append(ms).append(tag); - for (Throwable suppressed : thrown.getSuppressed()) - { - buffer.append(EOL).append(indent).append("Suppressed: "); - format(buffer, suppressed, "\t|" + indent); - } + String name = _printLongNames ? _name : _abbrevname; + String tname = Thread.currentThread().getName(); - Throwable cause = thrown.getCause(); - if (cause != null && cause != thrown) + int p = __tagpad > 0 ? (name.length() + tname.length() - __tagpad) : 0; + + if (p < 0) + { + buffer + .append(name) + .append(':') + .append(" ", 0, -p) + .append(tname); + } + else if (p == 0) + { + buffer.append(name).append(':').append(tname); + } + buffer.append(':'); + + if (_source) + { + Throwable source = new Throwable(); + StackTraceElement[] frames = source.getStackTrace(); + for (int i = 0; i < frames.length; i++) { - buffer.append(EOL).append(indent).append("Caused by: "); - format(buffer, cause, indent); + final StackTraceElement frame = frames[i]; + String clazz = frame.getClassName(); + if (clazz.equals(StdErrLog.class.getName()) || clazz.equals(Log.class.getName())) + { + continue; + } + if (!_printLongNames && clazz.startsWith("org.eclipse.jetty.")) + { + buffer.append(condensePackageString(clazz)); + } + else + { + buffer.append(clazz); + } + buffer.append('#').append(frame.getMethodName()); + if (frame.getFileName() != null) + { + buffer.append('(').append(frame.getFileName()).append(':').append(frame.getLineNumber()).append(')'); + } + buffer.append(':'); + break; } } + + buffer.append(' '); } /** diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java index bdf112a61a99..186b6cdad3c9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java @@ -308,9 +308,6 @@ public static boolean isContainedIn(Resource r, Resource containingResource) thr return r.isContainedIn(containingResource); } - - //@checkstyle-disable-check : NoFinalizer - //@checkstyle-enable-check : NoFinalizer public abstract boolean isContainedIn(Resource r) throws MalformedURLException; /** @@ -576,14 +573,12 @@ else if (sortColumn.equals("S")) // HTML Table final String ARROW_DOWN = "  ⇩"; final String ARROW_UP = "  ⇧"; - String arrow; - String order; buf.append("\n"); buf.append("\n"); - arrow = ""; - order = "A"; + String arrow = ""; + String order = "A"; if (sortColumn.equals("N")) { if (sortOrderAscending) @@ -784,6 +779,8 @@ private static String hrefEncodeURI(String raw) case '>': buf = new StringBuffer(raw.length() << 1); break loop; + default: + break; } } if (buf == null) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/security/UnixCrypt.java b/jetty-util/src/main/java/org/eclipse/jetty/util/security/UnixCrypt.java index ca7688d691c6..28be08f727f7 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/security/UnixCrypt.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/security/UnixCrypt.java @@ -428,14 +428,10 @@ private static long des_cipher(long in, int salt, int num_iter, long[] KS) { for (int loop_count = 0; loop_count < 8; loop_count++) { - long kp; - long B; - long k; - - kp = KS[(loop_count << 1)]; - k = ((R >> 32) ^ R) & salt & 0xffffffffL; + long kp = KS[(loop_count << 1)]; + long k = ((R >> 32) ^ R) & salt & 0xffffffffL; k |= (k << 32); - B = (k ^ R ^ kp); + long B = (k ^ R ^ kp); L ^= (SPE[0][(int)((B >> 58) & 0x3f)] ^ SPE[1][(int)((B >> 50) & 0x3f)] ^ SPE[2][(int)((B >> 42) & 0x3f)] @@ -499,8 +495,6 @@ private static void init_perm(long[][] perm, byte[] p, int chars_out) */ public static String crypt(String key, String setting) { - long constdatablock = 0L; /* encryption constant */ - byte[] cryptresult = new byte[13]; /* encrypted result */ long keyword = 0L; /* invalid parameters! */ if (key == null || setting == null) @@ -517,6 +511,8 @@ public static String crypt(String key, String setting) long[] KS = des_setkey(keyword); int salt = 0; + /* encrypted result */ + byte[] cryptresult = new byte[13]; for (int i = 2; --i >= 0; ) { char c = (i < setting.length()) ? setting.charAt(i) : '.'; @@ -524,7 +520,8 @@ public static String crypt(String key, String setting) salt = (salt << 6) | (0x00ff & A64TOI[c]); } - long rsltblock = des_cipher(constdatablock, salt, 25, KS); + /* encryption constant */ + long rsltblock = des_cipher(0L, salt, 25, KS); cryptresult[12] = ITOA64[(((int)rsltblock) << 2) & 0x3f]; rsltblock >>= 4; 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 63f7c052a1ae..3f3c7646b6f9 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 @@ -1206,7 +1206,9 @@ protected TrustManager[] getTrustManagers(KeyStore trustStore, Collection crls) throws Exception + // @checkstyle-enable-check : AbbreviationAsWordInNameCheck { PKIXBuilderParameters pbParams = new PKIXBuilderParameters(trustStore, new X509CertSelector()); @@ -1886,27 +1888,27 @@ public void reload(Consumer consumer) throws Exception } /** - * Obtain the X509 Certificate Chain from the provided SSLSession using this - * SslContextFactory's optional Provider specific {@link CertificateFactory}. + * Obtain the X509 Certificate Chain from the provided SSLSession using the + * default {@link CertificateFactory} behaviors * * @param sslSession the session to use for active peer certificates * @return the certificate chain */ - public X509Certificate[] getX509CertChain(SSLSession sslSession) + public static X509Certificate[] getCertChain(SSLSession sslSession) { - return getX509CertChain(this, sslSession); + return getX509CertChain(null, sslSession); } /** - * Obtain the X509 Certificate Chain from the provided SSLSession using the - * default {@link CertificateFactory} behaviors + * Obtain the X509 Certificate Chain from the provided SSLSession using this + * SslContextFactory's optional Provider specific {@link CertificateFactory}. * * @param sslSession the session to use for active peer certificates * @return the certificate chain */ - public static X509Certificate[] getCertChain(SSLSession sslSession) + public X509Certificate[] getX509CertChain(SSLSession sslSession) { - return getX509CertChain(null, sslSession); + return getX509CertChain(this, sslSession); } private static X509Certificate[] getX509CertChain(SslContextFactory sslContextFactory, SSLSession sslSession) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceConsume.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceConsume.java index b648db36fd3d..f37a94a40cfb 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceConsume.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceConsume.java @@ -54,11 +54,12 @@ public void produce() case IDLE: _state = State.PRODUCE; break; - case PRODUCE: case EXECUTE: _state = State.EXECUTE; return; + default: + throw new IllegalStateException(_state.toString()); } } @@ -84,6 +85,8 @@ public void produce() case EXECUTE: _state = State.PRODUCE; continue; + default: + throw new IllegalStateException(_state.toString()); } } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java index 3e97cd415c39..0b7dc16c7bf8 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java @@ -62,6 +62,8 @@ public void produce() case EXECUTE: _state = State.EXECUTE; return; + default: + throw new IllegalStateException(_state.toString()); } } @@ -87,6 +89,8 @@ public void produce() case EXECUTE: _state = State.PRODUCE; continue; + default: + throw new IllegalStateException(_state.toString()); } } } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClassMatcher.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClassMatcher.java index 975aa01648a9..3a695cf4ac6a 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClassMatcher.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClassMatcher.java @@ -571,26 +571,6 @@ public boolean add(String... pattern) return added; } - protected Entry newEntry(String pattern) - { - if (pattern.startsWith("-")) - return newEntry(pattern.substring(1), false); - return newEntry(pattern, true); - } - - protected Entry newEntry(String name, boolean inclusive) - { - if (name.startsWith("-")) - throw new IllegalStateException(name); - if (name.startsWith("file:")) - return new LocationEntry(name, inclusive); - if (name.startsWith("jrt:")) - return new ModuleEntry(name, inclusive); - if (name.endsWith(".")) - return new PackageEntry(name, inclusive); - return new ClassEntry(name, inclusive); - } - protected boolean add(Entry entry) { if (_entries.containsKey(entry.getPattern())) @@ -614,6 +594,26 @@ protected boolean add(Entry entry) return true; } + protected Entry newEntry(String pattern) + { + if (pattern.startsWith("-")) + return newEntry(pattern.substring(1), false); + return newEntry(pattern, true); + } + + protected Entry newEntry(String name, boolean inclusive) + { + if (name.startsWith("-")) + throw new IllegalStateException(name); + if (name.startsWith("file:")) + return new LocationEntry(name, inclusive); + if (name.startsWith("jrt:")) + return new ModuleEntry(name, inclusive); + if (name.endsWith(".")) + return new PackageEntry(name, inclusive); + return new ClassEntry(name, inclusive); + } + @Override public boolean remove(Object o) { diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java index 758331127b43..0758e4416168 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java @@ -228,7 +228,7 @@ public void addOverride(Resource override) case False: _metaDataComplete = false; break; - case NotSet: + default: break; } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java index e124975500ad..476f863edb15 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java @@ -309,6 +309,26 @@ protected List getAllContainerJars(final WebAppContext context) throws URIS return uris; } + @Override + public void configure(WebAppContext context) throws Exception + { + + // Look for extra resource + @SuppressWarnings("unchecked") + Set resources = (Set)context.getAttribute(RESOURCE_DIRS); + if (resources != null && !resources.isEmpty()) + { + Resource[] collection = new Resource[resources.size() + 1]; + int i = 0; + collection[i++] = context.getBaseResource(); + for (Resource resource : resources) + { + collection[i++] = resource; + } + context.setBaseResource(new ResourceCollection(collection)); + } + } + protected void scanJars(WebAppContext context) throws Exception { boolean useContainerCache = DEFAULT_USE_CONTAINER_METAINF_CACHE; @@ -355,26 +375,6 @@ public void scanJars(final WebAppContext context, Collection jars, boo scanJars(context, jars, useCaches, __allScanTypes); } - @Override - public void configure(WebAppContext context) throws Exception - { - - // Look for extra resource - @SuppressWarnings("unchecked") - Set resources = (Set)context.getAttribute(RESOURCE_DIRS); - if (resources != null && !resources.isEmpty()) - { - Resource[] collection = new Resource[resources.size() + 1]; - int i = 0; - collection[i++] = context.getBaseResource(); - for (Resource resource : resources) - { - collection[i++] = resource; - } - context.setBaseResource(new ResourceCollection(collection)); - } - } - /** * Look into the jars to discover info in META-INF. If useCaches == true, then we will * cache the info discovered indexed by the jar in which it was discovered: this speeds diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/RelativeOrdering.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/RelativeOrdering.java index 8798c6d3b387..79263bcb7720 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/RelativeOrdering.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/RelativeOrdering.java @@ -69,6 +69,8 @@ public List order(List jars) case After: afterOthers.add(jar); break; + default: + throw new IllegalStateException(fragment.toString()); } } } @@ -131,6 +133,8 @@ public List order(List jars) beforeOthers.forEach(addAfter); others.forEach(addAfter); break; + default: + throw new IllegalStateException(fragment.toString()); } } referenced.clear(); diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java index 39c817b1e116..89a9fc04122b 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java @@ -203,10 +203,8 @@ public void visitDisplayName(WebAppContext context, Descriptor descriptor, XmlPa public void visitServlet(WebAppContext context, Descriptor descriptor, XmlParser.Node node) { - String id = node.getAttribute("id"); - - // initialize holder - String name = node.getString("servlet-name", false, true); + final String id = node.getAttribute("id"); + final String name = node.getString("servlet-name", false, true); ServletHolder holder = _servletHolderMap.get(name); //If servlet of that name does not already exist, create it. 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 6692aae9d3fd..0b53e1de0b47 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 @@ -158,32 +158,30 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL public static final String TEMPDIR = "javax.servlet.context.tempdir"; public static final String BASETEMPDIR = "org.eclipse.jetty.webapp.basetempdir"; - public final static String WEB_DEFAULTS_XML = "org/eclipse/jetty/webapp/webdefault.xml"; - public final static String ERROR_PAGE = "org.eclipse.jetty.server.error_page"; - public final static String SERVER_SYS_CLASSES = "org.eclipse.jetty.webapp.systemClasses"; - public final static String SERVER_SRV_CLASSES = "org.eclipse.jetty.webapp.serverClasses"; + public static final String WEB_DEFAULTS_XML = "org/eclipse/jetty/webapp/webdefault.xml"; + public static final String ERROR_PAGE = "org.eclipse.jetty.server.error_page"; + public static final String SERVER_SYS_CLASSES = "org.eclipse.jetty.webapp.systemClasses"; + public static final String SERVER_SRV_CLASSES = "org.eclipse.jetty.webapp.serverClasses"; - private String[] __dftProtectedTargets = {"/web-inf", "/meta-inf"}; + private static String[] __dftProtectedTargets = {"/web-inf", "/meta-inf"}; // System classes are classes that cannot be replaced by // the web application, and they are *always* loaded via // system classloader. - public final static ClassMatcher __dftSystemClasses = new ClassMatcher - ( - "java.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) - "javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) - "org.xml.", // javax.xml - "org.w3c." // javax.xml - ); + public static final ClassMatcher __dftSystemClasses = new ClassMatcher( + "java.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) + "javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) + "org.xml.", // javax.xml + "org.w3c." // javax.xml + ); // Server classes are classes that are hidden from being // loaded by the web application using system classloader, // so if web application needs to load any of such classes, // it has to include them in its distribution. - public final static ClassMatcher __dftServerClasses = new ClassMatcher - ( - "org.eclipse.jetty." // hide jetty classes - ); + public static final ClassMatcher __dftServerClasses = new ClassMatcher( + "org.eclipse.jetty." // hide jetty classes + ); private final Configurations _configurations = new Configurations(); private final ClassMatcher _systemClasses = new ClassMatcher(__dftSystemClasses); @@ -229,14 +227,11 @@ public static WebAppContext getCurrentWebAppContext() return null; } - /* ------------------------------------------------------------ */ public WebAppContext() { this(null, null, null, null, null, new ErrorPageErrorHandler(), SESSIONS | SECURITY); } - /* ------------------------------------------------------------ */ - /** * @param contextPath The context path * @param webApp The URL or filename of the webapp directory or war file. @@ -247,8 +242,6 @@ public WebAppContext(String webApp, String contextPath) setWar(webApp); } - /* ------------------------------------------------------------ */ - /** * @param contextPath The context path * @param webApp The URL or filename of the webapp directory or war file. @@ -259,8 +252,6 @@ public WebAppContext(Resource webApp, String contextPath) setWarResource(webApp); } - /* ------------------------------------------------------------ */ - /** * @param parent The parent HandlerContainer. * @param contextPath The context path @@ -272,8 +263,6 @@ public WebAppContext(HandlerContainer parent, String webApp, String contextPath) setWar(webApp); } - /* ------------------------------------------------------------ */ - /** * @param parent The parent HandlerContainer. * @param contextPath The context path @@ -285,8 +274,6 @@ public WebAppContext(HandlerContainer parent, Resource webApp, String contextPat setWarResource(webApp); } - /* ------------------------------------------------------------ */ - /** * This constructor is used in the geronimo integration. * @@ -300,8 +287,6 @@ public WebAppContext(SessionHandler sessionHandler, SecurityHandler securityHand this(null, null, sessionHandler, securityHandler, servletHandler, errorHandler, 0); } - /* ------------------------------------------------------------ */ - /** * This constructor is used in the geronimo integration. * @@ -325,8 +310,6 @@ public WebAppContext(HandlerContainer parent, String contextPath, SessionHandler setParent(parent); } - /* ------------------------------------------------------------ */ - /** * @param servletContextName The servletContextName to set. */ @@ -339,8 +322,6 @@ public void setDisplayName(String servletContextName) ((WebAppClassLoader)cl).setName(servletContextName); } - /* ------------------------------------------------------------ */ - /** * Get an exception that caused the webapp to be unavailable * @@ -351,8 +332,6 @@ public Throwable getUnavailableException() return _unavailableException; } - /* ------------------------------------------------------------ */ - /** * Set Resource Alias. * Resource aliases map resource uri's within a context. @@ -369,7 +348,6 @@ public void setResourceAlias(String alias, String uri) _resourceAliases.put(alias, uri); } - /* ------------------------------------------------------------ */ public Map getResourceAliases() { if (_resourceAliases == null) @@ -377,13 +355,11 @@ public Map getResourceAliases() return _resourceAliases; } - /* ------------------------------------------------------------ */ public void setResourceAliases(Map map) { _resourceAliases = map; } - /* ------------------------------------------------------------ */ public String getResourceAlias(String path) { if (_resourceAliases == null) @@ -403,7 +379,6 @@ public String getResourceAlias(String path) return alias; } - /* ------------------------------------------------------------ */ public String removeResourceAlias(String alias) { if (_resourceAliases == null) @@ -411,7 +386,6 @@ public String removeResourceAlias(String alias) return _resourceAliases.remove(alias); } - /* ------------------------------------------------------------ */ /* (non-Javadoc) * @see org.eclipse.jetty.server.server.handler.ContextHandler#setClassLoader(java.lang.ClassLoader) */ @@ -428,7 +402,6 @@ public void setClassLoader(ClassLoader classLoader) ((WebAppClassLoader)classLoader).setName(name); } - /* ------------------------------------------------------------ */ @Override public Resource getResource(String uriInContext) throws MalformedURLException { @@ -462,9 +435,6 @@ public Resource getResource(String uriInContext) throws MalformedURLException return resource; } - - /* ------------------------------------------------------------ */ - /** * Is the context Automatically configured. * @@ -475,8 +445,6 @@ public boolean isConfigurationDiscovered() return _configurationDiscovered; } - /* ------------------------------------------------------------ */ - /** * Set the configuration discovery mode. * If configuration discovery is set to true, then the JSR315 @@ -493,8 +461,6 @@ public void setConfigurationDiscovered(boolean discovered) _configurationDiscovered = discovered; } - /* ------------------------------------------------------------ */ - /** * Pre configure the web application. *

@@ -551,19 +517,16 @@ public void preConfigure() throws Exception _configurations.preConfigure(this); } - /* ------------------------------------------------------------ */ public boolean configure() throws Exception { return _configurations.configure(this); } - /* ------------------------------------------------------------ */ public void postConfigure() throws Exception { _configurations.postConfigure(this); } - /* ------------------------------------------------------------ */ /* * @see org.eclipse.thread.AbstractLifeCycle#doStart() */ @@ -593,7 +556,6 @@ protected void doStart() throws Exception } } - /* ------------------------------------------------------------ */ /* * @see org.eclipse.thread.AbstractLifeCycle#doStop() */ @@ -603,7 +565,6 @@ protected void doStop() throws Exception super.doStop(); } - /* ------------------------------------------------------------ */ @Override public void destroy() { @@ -625,7 +586,6 @@ public void destroy() mx.ifExceptionThrowRuntime(); } - /* ------------------------------------------------------------ */ /* * Dumps the current web app name and URL to the log */ @@ -642,8 +602,6 @@ private void dumpUrl() } } - /* ------------------------------------------------------------ */ - /** * @return Returns the configurations. */ @@ -654,8 +612,6 @@ public String[] getConfigurationClasses() return _configurations.toArray(); } - /* ------------------------------------------------------------ */ - /** * @return Returns the configurations. */ @@ -666,8 +622,6 @@ public Configurations getWebAppConfigurations() return _configurations; } - /* ------------------------------------------------------------ */ - /** * The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml * @@ -679,8 +633,6 @@ public String getDefaultsDescriptor() return _defaultsDescriptor; } - /* ------------------------------------------------------------ */ - /** * The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml * @@ -693,8 +645,6 @@ public String getOverrideDescriptor() return _overrideDescriptors.get(0); } - /* ------------------------------------------------------------ */ - /** * An override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml * @@ -706,8 +656,6 @@ public List getOverrideDescriptors() return Collections.unmodifiableList(_overrideDescriptors); } - /* ------------------------------------------------------------ */ - /** * @return Returns the permissions. */ @@ -717,8 +665,6 @@ public PermissionCollection getPermissions() return _permissions; } - /* ------------------------------------------------------------ */ - /** * Set the server classes patterns. *

@@ -734,8 +680,6 @@ public void setServerClassMatcher(ClassMatcher serverClasses) _serverClasses.add(serverClasses.getPatterns()); } - /* ------------------------------------------------------------ */ - /** * Set the system classes patterns. *

@@ -757,7 +701,6 @@ public void setSystemClassMatcher(ClassMatcher systemClasses) * * @param serverClasses The class matcher of patterns to add to the server ClassMatcher */ - /* ------------------------------------------------------------ */ public void addServerClassMatcher(ClassMatcher serverClasses) { _serverClasses.add(serverClasses.getPatterns()); @@ -769,14 +712,11 @@ public void addServerClassMatcher(ClassMatcher serverClasses) * * @param systemClasses The class matcher of patterns to add to the system ClassMatcher */ - /* ------------------------------------------------------------ */ public void addSystemClassMatcher(ClassMatcher systemClasses) { _systemClasses.add(systemClasses.getPatterns()); } - /* ------------------------------------------------------------ */ - /** * @return The ClassMatcher used to match System (protected) classes */ @@ -785,8 +725,6 @@ public ClassMatcher getSystemClassMatcher() return _systemClasses; } - /* ------------------------------------------------------------ */ - /** * @return The ClassMatcher used to match Server (hidden) classes */ @@ -795,21 +733,18 @@ public ClassMatcher getServerClassMatcher() return _serverClasses; } - /* ------------------------------------------------------------ */ @ManagedAttribute(value = "classes and packages protected by context classloader", readonly = true) public String[] getSystemClasses() { return _systemClasses.getPatterns(); } - /* ------------------------------------------------------------ */ @ManagedAttribute(value = "classes and packages hidden by the context classloader", readonly = true) public String[] getServerClasses() { return _serverClasses.getPatterns(); } - /* ------------------------------------------------------------ */ @Override public boolean isServerClass(Class clazz) { @@ -819,7 +754,6 @@ public boolean isServerClass(Class clazz) return result; } - /* ------------------------------------------------------------ */ @Override public boolean isSystemClass(Class clazz) { @@ -829,7 +763,6 @@ public boolean isSystemClass(Class clazz) return result; } - /* ------------------------------------------------------------ */ @Override public boolean isServerResource(String name, URL url) { @@ -839,7 +772,6 @@ public boolean isServerResource(String name, URL url) return result; } - /* ------------------------------------------------------------ */ @Override public boolean isSystemResource(String name, URL url) { @@ -849,7 +781,6 @@ public boolean isSystemResource(String name, URL url) return result; } - /* ------------------------------------------------------------ */ @Override public void setServer(Server server) { @@ -876,8 +807,6 @@ public void setServer(Server server) } } - /* ------------------------------------------------------------ */ - /** * @return Returns the war as a file or URL string (Resource). * The war may be different to the @link {@link #getResourceBase()} @@ -891,22 +820,19 @@ public String getWar() return _war; } - /* ------------------------------------------------------------ */ public Resource getWebInf() throws IOException { if (super.getBaseResource() == null) return null; // Iw there a WEB-INF directory? - Resource web_inf = super.getBaseResource().addPath("WEB-INF/"); - if (!web_inf.exists() || !web_inf.isDirectory()) + Resource webInf = super.getBaseResource().addPath("WEB-INF/"); + if (!webInf.exists() || !webInf.isDirectory()) return null; - return web_inf; + return webInf; } - /* ------------------------------------------------------------ */ - /** * @return Returns the distributable. */ @@ -916,8 +842,6 @@ public boolean isDistributable() return _distributable; } - /* ------------------------------------------------------------ */ - /** * @return Returns the extractWAR. */ @@ -927,8 +851,6 @@ public boolean isExtractWAR() return _extractWAR; } - /* ------------------------------------------------------------ */ - /** * @return True if the webdir is copied (to allow hot replacement of jars on windows) */ @@ -938,8 +860,6 @@ public boolean isCopyWebDir() return _copyDir; } - /* ------------------------------------------------------------ */ - /** * @return True if the web-inf lib and classes directories are copied (to allow hot replacement of jars on windows) */ @@ -948,8 +868,6 @@ public boolean isCopyWebInf() return _copyWebInf; } - /* ------------------------------------------------------------ */ - /** * @return True if the classloader should delegate first to the parent * classloader (standard java behaviour) or false if the classloader @@ -964,7 +882,6 @@ public boolean isParentLoaderPriority() return _parentLoaderPriority; } - /* ------------------------------------------------------------ */ protected void loadConfigurations() { //if the configuration instances have been set explicitly, use them @@ -974,7 +891,6 @@ protected void loadConfigurations() _configurations.add(Configurations.getServerDefault(getServer()).toArray()); } - /* ------------------------------------------------------------ */ @Override public String toString() { @@ -983,22 +899,21 @@ public String toString() return super.toString(); } - /* ------------------------------------------------------------ */ @Override public void dump(Appendable out, String indent) throws IOException { - List system_classes = null; + List systemClasses = null; if (_systemClasses != null) { - system_classes = new ArrayList<>(_systemClasses); - Collections.sort(system_classes); + systemClasses = new ArrayList<>(_systemClasses); + Collections.sort(systemClasses); } - List server_classes = null; + List serverClasses = null; if (_serverClasses != null) { - server_classes = new ArrayList<>(_serverClasses); - Collections.sort(server_classes); + serverClasses = new ArrayList<>(_serverClasses); + Collections.sort(serverClasses); } String name = getDisplayName(); @@ -1027,8 +942,8 @@ else if (getResourceBase() != null) dumpObjects(out, indent, new ClassLoaderDump(getClassLoader()), - new DumpableCollection("Systemclasses " + name, system_classes), - new DumpableCollection("Serverclasses " + name, server_classes), + new DumpableCollection("Systemclasses " + name, systemClasses), + new DumpableCollection("Serverclasses " + name, serverClasses), new DumpableCollection("Configurations " + name, _configurations), new DumpableCollection("Handler attributes " + name, ((AttributesMap)getAttributes()).getAttributeEntrySet()), new DumpableCollection("Context attributes " + name, ((Context)getServletContext()).getAttributeEntrySet()), @@ -1036,8 +951,6 @@ else if (getResourceBase() != null) ); } - /* ------------------------------------------------------------ */ - /** * @param configurations The configuration class names. If setConfigurations is not called * these classes are used to create a configurations array. @@ -1049,14 +962,11 @@ public void setConfigurationClasses(String[] configurations) _configurations.set(configurations); } - /* ------------------------------------------------------------ */ public void setConfigurationClasses(List configurations) { setConfigurationClasses(configurations.toArray(new String[configurations.size()])); } - /* ------------------------------------------------------------ */ - /** * @param configurations The configurations to set. */ @@ -1067,7 +977,6 @@ public void setConfigurations(Configuration[] configurations) _configurations.set(configurations); } - /* ------------------------------------------------------------ */ public void addConfiguration(Configuration... configuration) { if (isStarted()) @@ -1076,7 +985,6 @@ public void addConfiguration(Configuration... configuration) _configurations.add(configuration); } - /* ------------------------------------------------------------ */ public T getConfiguration(Class configClass) { loadConfigurations(); @@ -1088,8 +996,6 @@ public T getConfiguration(Class configClass) return null; } - /* ------------------------------------------------------------ */ - /** * The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml * @@ -1100,8 +1006,6 @@ public void setDefaultsDescriptor(String defaultsDescriptor) _defaultsDescriptor = defaultsDescriptor; } - /* ------------------------------------------------------------ */ - /** * The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml * @@ -1113,8 +1017,6 @@ public void setOverrideDescriptor(String overrideDescriptor) _overrideDescriptors.add(overrideDescriptor); } - /* ------------------------------------------------------------ */ - /** * The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml * @@ -1126,8 +1028,6 @@ public void setOverrideDescriptors(List overrideDescriptors) _overrideDescriptors.addAll(overrideDescriptors); } - /* ------------------------------------------------------------ */ - /** * The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml * @@ -1138,8 +1038,6 @@ public void addOverrideDescriptor(String overrideDescriptor) _overrideDescriptors.add(overrideDescriptor); } - /* ------------------------------------------------------------ */ - /** * @return the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists. */ @@ -1149,8 +1047,6 @@ public String getDescriptor() return _descriptor; } - /* ------------------------------------------------------------ */ - /** * @param descriptor the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists. */ @@ -1159,8 +1055,6 @@ public void setDescriptor(String descriptor) _descriptor = descriptor; } - /* ------------------------------------------------------------ */ - /** * @param distributable The distributable to set. */ @@ -1169,7 +1063,6 @@ public void setDistributable(boolean distributable) this._distributable = distributable; } - /* ------------------------------------------------------------ */ @Override public void setEventListeners(EventListener[] eventListeners) { @@ -1183,20 +1076,17 @@ public void setEventListeners(EventListener[] eventListeners) public void removeEventListener(EventListener listener) { super.removeEventListener(listener); - if ((listener instanceof HttpSessionActivationListener) - || (listener instanceof HttpSessionAttributeListener) - || (listener instanceof HttpSessionBindingListener) - || (listener instanceof HttpSessionListener) - || (listener instanceof HttpSessionIdListener)) + if ((listener instanceof HttpSessionActivationListener) || + (listener instanceof HttpSessionAttributeListener) || + (listener instanceof HttpSessionBindingListener) || + (listener instanceof HttpSessionListener) || + (listener instanceof HttpSessionIdListener)) { if (_sessionHandler != null) _sessionHandler.removeEventListener(listener); } } - - /* ------------------------------------------------------------ */ - /** * @param extractWAR True if war files are extracted */ @@ -1205,8 +1095,6 @@ public void setExtractWAR(boolean extractWAR) _extractWAR = extractWAR; } - /* ------------------------------------------------------------ */ - /** * @param copy True if the webdir is copied (to allow hot replacement of jars) */ @@ -1215,8 +1103,6 @@ public void setCopyWebDir(boolean copy) _copyDir = copy; } - /* ------------------------------------------------------------ */ - /** * @param copyWebInf True if the web-inf lib and classes directories are copied (to allow hot replacement of jars on windows) */ @@ -1225,8 +1111,6 @@ public void setCopyWebInf(boolean copyWebInf) _copyWebInf = copyWebInf; } - /* ------------------------------------------------------------ */ - /** * @param java2compliant True if the classloader should delegate first to the parent * classloader (standard java behaviour) or false if the classloader @@ -1239,8 +1123,6 @@ public void setParentLoaderPriority(boolean java2compliant) _parentLoaderPriority = java2compliant; } - /* ------------------------------------------------------------ */ - /** * @param permissions The permissions to set. */ @@ -1249,8 +1131,6 @@ public void setPermissions(PermissionCollection permissions) _permissions = permissions; } - /* ------------------------------------------------------------ */ - /** * Set the context white list * @@ -1266,9 +1146,6 @@ public void setContextWhiteList(String... contextWhiteList) _contextWhiteList = contextWhiteList; } - - /* ------------------------------------------------------------ */ - /** * Set temporary directory for context. * The javax.servlet.context.tempdir attribute is also set. @@ -1296,7 +1173,6 @@ public void setTempDirectory(File dir) setAttribute(TEMPDIR, _tmpDir); } - /* ------------------------------------------------------------ */ @ManagedAttribute(value = "temporary directory location", readonly = true) public File getTempDirectory() { @@ -1323,9 +1199,6 @@ public boolean isPersistTempDirectory() return _persistTmpDir; } - - /* ------------------------------------------------------------ */ - /** * Set the war of the webapp. From this value a {@link #setResourceBase(String)} * value is computed by {@link WebInfConfiguration}, which may be changed from @@ -1338,8 +1211,6 @@ public void setWar(String war) _war = war; } - /* ------------------------------------------------------------ */ - /** * Set the war of the webapp as a {@link Resource}. * @@ -1351,8 +1222,6 @@ public void setWarResource(Resource war) setWar(war == null ? null : war.toString()); } - /* ------------------------------------------------------------ */ - /** * @return Comma or semicolon separated path of filenames or URLs * pointing to directories or jar files. Directories should end @@ -1365,8 +1234,6 @@ public String getExtraClasspath() return _extraClasspath; } - /* ------------------------------------------------------------ */ - /** * @param extraClasspath Comma or semicolon separated path of filenames or URLs * pointing to directories or jar files. Directories should end @@ -1377,14 +1244,11 @@ public void setExtraClasspath(String extraClasspath) _extraClasspath = extraClasspath; } - /* ------------------------------------------------------------ */ public boolean isLogUrlOnStart() { return _logUrlOnStart; } - /* ------------------------------------------------------------ */ - /** * Sets whether or not the web app name and URL is logged on startup * @@ -1395,31 +1259,26 @@ public void setLogUrlOnStart(boolean logOnStart) this._logUrlOnStart = logOnStart; } - /* ------------------------------------------------------------ */ public boolean isAllowDuplicateFragmentNames() { return _allowDuplicateFragmentNames; } - /* ------------------------------------------------------------ */ public void setAllowDuplicateFragmentNames(boolean allowDuplicateFragmentNames) { _allowDuplicateFragmentNames = allowDuplicateFragmentNames; } - /* ------------------------------------------------------------ */ public void setThrowUnavailableOnStartupException(boolean throwIfStartupException) { _throwUnavailableOnStartupException = throwIfStartupException; } - /* ------------------------------------------------------------ */ public boolean isThrowUnavailableOnStartupException() { return _throwUnavailableOnStartupException; } - /* ------------------------------------------------------------ */ @Override protected void startContext() throws Exception @@ -1432,7 +1291,6 @@ protected void startContext() } } - /* ------------------------------------------------------------ */ @Override protected void stopContext() throws Exception { @@ -1463,7 +1321,6 @@ protected void stopContext() throws Exception } } - /* ------------------------------------------------------------ */ @Override public Set setServletSecurity(Dynamic registration, ServletSecurityElement servletSecurityElement) { @@ -1530,6 +1387,8 @@ public Set setServletSecurity(Dynamic registration, ServletSecurityEleme ((ConstraintAware)getSecurityHandler()).checkPathsWithUncoveredHttpMethods(); break; } + default: + throw new IllegalStateException(origin.toString()); } } } @@ -1537,11 +1396,9 @@ public Set setServletSecurity(Dynamic registration, ServletSecurityEleme return unchangedURLMappings; } - /* ------------------------------------------------------------ */ public class Context extends ServletContextHandler.Context { - /* ------------------------------------------------------------ */ @Override public void checkListener(Class listener) throws IllegalStateException { @@ -1566,7 +1423,6 @@ public void checkListener(Class listener) throws Illega } } - /* ------------------------------------------------------------ */ @Override public URL getResource(String path) throws MalformedURLException { @@ -1588,7 +1444,6 @@ public URL getResource(String path) throws MalformedURLException return resource.getURI().toURL(); } - /* ------------------------------------------------------------ */ @Override public ServletContext getContext(String uripath) { @@ -1613,25 +1468,21 @@ public ServletContext getContext(String uripath) } } - /* ------------------------------------------------------------ */ public MetaData getMetaData() { return _metadata; } - /* ------------------------------------------------------------ */ public static void addServerClasses(Server server, String... pattern) { addClasses(__dftServerClasses, SERVER_SRV_CLASSES, server, pattern); } - /* ------------------------------------------------------------ */ public static void addSystemClasses(Server server, String... pattern) { addClasses(__dftSystemClasses, SERVER_SYS_CLASSES, server, pattern); } - /* ------------------------------------------------------------ */ private static void addClasses(ClassMatcher matcher, String attribute, Server server, String... pattern) { if (pattern == null || pattern.length == 0) diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java index d85135cb5cf3..a1d2ccc5dd1c 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java @@ -85,35 +85,35 @@ protected InputSource resolveEntity(String pid, String sid) void mapResources() { //set up cache of DTDs and schemas locally - URL dtd22 = Loader.getResource("javax/servlet/resources/web-app_2_2.dtd"); - URL dtd23 = Loader.getResource("javax/servlet/resources/web-app_2_3.dtd"); - URL j2ee14xsd = Loader.getResource("javax/servlet/resources/j2ee_1_4.xsd"); - URL javaee5 = Loader.getResource("javax/servlet/resources/javaee_5.xsd"); - URL javaee6 = Loader.getResource("javax/servlet/resources/javaee_6.xsd"); - URL javaee7 = Loader.getResource("javax/servlet/resources/javaee_7.xsd"); - URL javaee8 = Loader.getResource("javax/servlet/resources/javaee_8.xsd"); - - URL webapp24xsd = Loader.getResource("javax/servlet/resources/web-app_2_4.xsd"); - URL webapp25xsd = Loader.getResource("javax/servlet/resources/web-app_2_5.xsd"); - URL webapp30xsd = Loader.getResource("javax/servlet/resources/web-app_3_0.xsd"); - URL webapp31xsd = Loader.getResource("javax/servlet/resources/web-app_3_1.xsd"); - URL webapp40xsd = Loader.getResource("javax/servlet/resources/web-app_4_0.xsd"); - - URL webcommon30xsd = Loader.getResource("javax/servlet/resources/web-common_3_0.xsd"); - URL webcommon31xsd = Loader.getResource("javax/servlet/resources/web-common_3_1.xsd"); - URL webcommon40xsd = Loader.getResource("javax/servlet/resources/web-common_4_0.xsd"); - - URL webfragment30xsd = Loader.getResource("javax/servlet/resources/web-fragment_3_0.xsd"); - URL webfragment31xsd = Loader.getResource("javax/servlet/resources/web-fragment_3_1.xsd"); - URL webfragment40xsd = Loader.getResource("javax/servlet/resources/web-fragment_4_0.xsd"); - - URL schemadtd = Loader.getResource("javax/servlet/resources/XMLSchema.dtd"); - URL xmlxsd = Loader.getResource("javax/servlet/resources/xml.xsd"); - URL webservice11xsd = Loader.getResource("javax/servlet/resources/j2ee_web_services_client_1_1.xsd"); - URL webservice12xsd = Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_2.xsd"); - URL webservice13xsd = Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_3.xsd"); - URL webservice14xsd = Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_4.xsd"); - URL datatypesdtd = Loader.getResource("javax/servlet/resources/datatypes.dtd"); + final URL dtd22 = Loader.getResource("javax/servlet/resources/web-app_2_2.dtd"); + final URL dtd23 = Loader.getResource("javax/servlet/resources/web-app_2_3.dtd"); + final URL j2ee14xsd = Loader.getResource("javax/servlet/resources/j2ee_1_4.xsd"); + final URL javaee5 = Loader.getResource("javax/servlet/resources/javaee_5.xsd"); + final URL javaee6 = Loader.getResource("javax/servlet/resources/javaee_6.xsd"); + final URL javaee7 = Loader.getResource("javax/servlet/resources/javaee_7.xsd"); + final URL javaee8 = Loader.getResource("javax/servlet/resources/javaee_8.xsd"); + + final URL webapp24xsd = Loader.getResource("javax/servlet/resources/web-app_2_4.xsd"); + final URL webapp25xsd = Loader.getResource("javax/servlet/resources/web-app_2_5.xsd"); + final URL webapp30xsd = Loader.getResource("javax/servlet/resources/web-app_3_0.xsd"); + final URL webapp31xsd = Loader.getResource("javax/servlet/resources/web-app_3_1.xsd"); + final URL webapp40xsd = Loader.getResource("javax/servlet/resources/web-app_4_0.xsd"); + + final URL webcommon30xsd = Loader.getResource("javax/servlet/resources/web-common_3_0.xsd"); + final URL webcommon31xsd = Loader.getResource("javax/servlet/resources/web-common_3_1.xsd"); + final URL webcommon40xsd = Loader.getResource("javax/servlet/resources/web-common_4_0.xsd"); + + final URL webfragment30xsd = Loader.getResource("javax/servlet/resources/web-fragment_3_0.xsd"); + final URL webfragment31xsd = Loader.getResource("javax/servlet/resources/web-fragment_3_1.xsd"); + final URL webfragment40xsd = Loader.getResource("javax/servlet/resources/web-fragment_4_0.xsd"); + + final URL schemadtd = Loader.getResource("javax/servlet/resources/XMLSchema.dtd"); + final URL xmlxsd = Loader.getResource("javax/servlet/resources/xml.xsd"); + final URL webservice11xsd = Loader.getResource("javax/servlet/resources/j2ee_web_services_client_1_1.xsd"); + final URL webservice12xsd = Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_2.xsd"); + final URL webservice13xsd = Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_3.xsd"); + final URL webservice14xsd = Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_4.xsd"); + final URL datatypesdtd = Loader.getResource("javax/servlet/resources/datatypes.dtd"); URL jsp20xsd = null; URL jsp21xsd = null; diff --git a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java index e44baef08c75..033cc270aa20 100644 --- a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java +++ b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java @@ -231,6 +231,8 @@ public void onFrame(Frame frame, Callback callback) case OpCode.CLOSE: onClose(frame, callback); break; + default: + callback.failed(new IllegalStateException()); } if (frame.isFin() && !frame.isControlFrame()) @@ -496,6 +498,8 @@ public void removeMessageHandler(MessageHandler handler) this.binaryMetadata = null; this.binarySink = null; break; + default: + break; // TODO ISE? } } } diff --git a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java index 0c60798336c0..08399e924209 100644 --- a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java +++ b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageOutputStream.java @@ -104,26 +104,6 @@ public void flush() throws IOException } } - @Override - public void close() throws IOException - { - try - { - flush(true); - bufferPool.release(buffer); - if (LOG.isDebugEnabled()) - LOG.debug("Stream closed, {} frames ({} bytes) sent", frameCount, bytesSent); - // Notify without holding locks. - notifySuccess(); - } - catch (Throwable x) - { - // Notify without holding locks. - notifyFailure(x); - throw x; - } - } - private void flush(boolean fin) throws IOException { synchronized (this) @@ -183,6 +163,26 @@ private void send(byte[] bytes, final int offset, final int length) throws IOExc } } + @Override + public void close() throws IOException + { + try + { + flush(true); + bufferPool.release(buffer); + if (LOG.isDebugEnabled()) + LOG.debug("Stream closed, {} frames ({} bytes) sent", frameCount, bytesSent); + // Notify without holding locks. + notifySuccess(); + } + catch (Throwable x) + { + // Notify without holding locks. + notifyFailure(x); + throw x; + } + } + public void setCallback(Callback callback) { synchronized (this) diff --git a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java index 45691da1242a..33916a756c70 100644 --- a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java +++ b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/MessageWriter.java @@ -110,25 +110,6 @@ public void flush() throws IOException } } - @Override - public void close() throws IOException - { - try - { - flush(true); - if (LOG.isDebugEnabled()) - LOG.debug("Stream closed, {} frames sent", frameCount); - // Notify without holding locks. - notifySuccess(); - } - catch (Throwable x) - { - // Notify without holding locks. - notifyFailure(x); - throw x; - } - } - private void flush(boolean fin) throws IOException { synchronized (this) @@ -190,6 +171,25 @@ private void send(char[] chars, int offset, int length) throws IOException } } + @Override + public void close() throws IOException + { + try + { + flush(true); + if (LOG.isDebugEnabled()) + LOG.debug("Stream closed, {} frames sent", frameCount); + // Notify without holding locks. + notifySuccess(); + } + catch (Throwable x) + { + // Notify without holding locks. + notifyFailure(x); + throw x; + } + } + public void setCallback(Callback callback) { synchronized (this) diff --git a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtils.java b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtils.java index ad705eb29a40..fa160723fdd2 100644 --- a/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtils.java +++ b/jetty-websocket/javax-websocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtils.java @@ -209,31 +209,6 @@ public static MethodHandle mutatedInvoker(Class targetClass, Method method, P return mutatedInvoker(targetClass, true, method, paramIdentifier, namedVariables, callingArgs); } - /** - * Create an optional MethodHandle that performs the following layers. - *

    - *
  1. {@link MethodHandles#permuteArguments(MethodHandle, MethodType, int...)} - moving calling Args around - * to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwords
  2. - *
  3. {@link MethodHandles#dropArguments(MethodHandle, int, Class[])} - to drop the unused calling args
  4. - *
  5. {@link MethodHandle#invoke(Object...)} - to call the specific method
  6. - *
- * - * @param targetClass the target class for invocations of the resulting MethodHandle (also known as parameter 0) - * @param method the method to invoke - * @param paramIdentifier the mechanism to identify parameters in method - * @param namedVariables the array of named variables. This is the array of named arguments that the target method might have. - * The resulting MethodHandle will include all of these namedVariables as the first non-object arguments in the {@link MethodType} - * found on the returned {@link MethodHandle#type()} - * @param callingArgs the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. - * They will be present in the {@link MethodHandle#type()} in the order specified in this array. - * @return the MethodHandle for this set of CallingArgs, or null if not possible to create MethodHandle with CallingArgs to provided method - */ - public static MethodHandle optionalMutatedInvoker(Class targetClass, Method method, ParamIdentifier paramIdentifier, String[] namedVariables, - Arg... callingArgs) - { - return mutatedInvoker(targetClass, false, method, paramIdentifier, namedVariables, callingArgs); - } - @SuppressWarnings("Duplicates") private static MethodHandle mutatedInvoker(Class targetClass, boolean throwOnFailure, Method method, ParamIdentifier paramIdentifier, String[] namedVariables, Arg... rawCallingArgs) @@ -460,6 +435,31 @@ private static MethodHandle mutatedInvoker(Class targetClass, boolean throwOn } } + /** + * Create an optional MethodHandle that performs the following layers. + *
    + *
  1. {@link MethodHandles#permuteArguments(MethodHandle, MethodType, int...)} - moving calling Args around + * to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwords
  2. + *
  3. {@link MethodHandles#dropArguments(MethodHandle, int, Class[])} - to drop the unused calling args
  4. + *
  5. {@link MethodHandle#invoke(Object...)} - to call the specific method
  6. + *
+ * + * @param targetClass the target class for invocations of the resulting MethodHandle (also known as parameter 0) + * @param method the method to invoke + * @param paramIdentifier the mechanism to identify parameters in method + * @param namedVariables the array of named variables. This is the array of named arguments that the target method might have. + * The resulting MethodHandle will include all of these namedVariables as the first non-object arguments in the {@link MethodType} + * found on the returned {@link MethodHandle#type()} + * @param callingArgs the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. + * They will be present in the {@link MethodHandle#type()} in the order specified in this array. + * @return the MethodHandle for this set of CallingArgs, or null if not possible to create MethodHandle with CallingArgs to provided method + */ + public static MethodHandle optionalMutatedInvoker(Class targetClass, Method method, ParamIdentifier paramIdentifier, String[] namedVariables, + Arg... callingArgs) + { + return mutatedInvoker(targetClass, false, method, paramIdentifier, namedVariables, callingArgs); + } + private static void appendTypeList(StringBuilder str, Arg[] args) { str.append("("); diff --git a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java index ea32f0a811d7..2a536077e300 100644 --- a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java +++ b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java @@ -62,8 +62,8 @@ public JavaxWebSocketCreator(JavaxWebSocketContainer containerScope, ServerEndpo @Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { - JsrHandshakeRequest jsrHandshakeRequest = new JsrHandshakeRequest(req); - JsrHandshakeResponse jsrHandshakeResponse = new JsrHandshakeResponse(resp); + final JsrHandshakeRequest jsrHandshakeRequest = new JsrHandshakeRequest(req); + final JsrHandshakeResponse jsrHandshakeResponse = new JsrHandshakeResponse(resp); // Establish a copy of the config, so that the UserProperties are unique // per upgrade request. diff --git a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/Sha1Sum.java b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/Sha1Sum.java index 452e8a2abb2a..ebd9b2dcdd60 100644 --- a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/Sha1Sum.java +++ b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/Sha1Sum.java @@ -54,17 +54,17 @@ public void write(byte[] b, int off, int len) throws IOException } @Override - public void flush() throws IOException + public void write(int b) throws IOException { } @Override - public void close() throws IOException + public void flush() throws IOException { } @Override - public void write(int b) throws IOException + public void close() throws IOException { } } diff --git a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java index ebc0fd45eaa6..3ad84670e971 100644 --- a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java +++ b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java @@ -53,6 +53,8 @@ public void describeTo(Description description) case PONG: description.appendText(PongMessage.class.getName()).appendText(" argument"); break; + default: + throw new IllegalStateException(expectedType.toString()); } } @@ -92,9 +94,9 @@ else if (MessageHandler.Partial.class.isAssignableFrom(handlerClass)) case TEXT: return (Decoder.Text.class.isAssignableFrom(registeredDecoder.interfaceType) || Decoder.TextStream.class.isAssignableFrom(registeredDecoder.interfaceType)); + default: + return false; } - - return false; } public static IsMessageHandlerType isMessageHandlerType(JavaxWebSocketSession session, MessageType messageType) diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java index d1a6bdad3235..14cb4a8e9b0e 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java @@ -242,6 +242,16 @@ public void setSubProtocols(String... protocols) Collections.addAll(subProtocols, protocols); } + @Override + public void setSubProtocols(List subProtocols) + { + this.subProtocols.clear(); + if (subProtocols != null) + { + this.subProtocols.addAll(subProtocols); + } + } + @Override public boolean hasSubProtocol(String test) { @@ -312,16 +322,6 @@ public void setSession(Object session) throw new UnsupportedOperationException("HttpSession not available on Client request"); } - @Override - public void setSubProtocols(List subProtocols) - { - this.subProtocols.clear(); - if (subProtocols != null) - { - this.subProtocols.addAll(subProtocols); - } - } - /** * ABNF from RFC 2616, RFC 822, and RFC 6455 specified characters requiring quoting. */ diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java index 9df6187f8ae5..88516af8589a 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java @@ -80,6 +80,12 @@ public List getHeaders(String name) return delegate.getHeaders().getValuesList(name); } + @Override + public Map> getHeaders() + { + return null; + } + @Override public String getHost() { @@ -173,12 +179,6 @@ public void addExtensions(String... configs) // TODO } - @Override - public Map> getHeaders() - { - return null; - } - @Override public Object getSession() { diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java index 44bc2a3563d8..79c385491fd2 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java +++ b/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java @@ -68,21 +68,21 @@ public List getHeaders(String name) } @Override - public int getStatusCode() + public Map> getHeaders() { - return this.delegate.getStatus(); + return null; } @Override - public void addHeader(String name, String value) + public int getStatusCode() { - + return this.delegate.getStatus(); } @Override - public Map> getHeaders() + public void addHeader(String name, String value) { - return null; + } @Override diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java index b82d0209276a..1970d1334e39 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java @@ -248,6 +248,8 @@ public void onFrame(Frame frame, Callback callback) case OpCode.CONTINUATION: onContinuationFrame(frame, demandingCallback); break; + default: + callback.failed(new IllegalStateException()); } } diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java index f774b0dd03db..c1f0e138accd 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java @@ -120,27 +120,18 @@ public JettyWebSocketFrameHandler newJettyFrameHandler(Object endpointInstance) { JettyWebSocketFrameHandlerMetadata metadata = getMetadata(endpointInstance.getClass()); - MethodHandle openHandle = metadata.getOpenHandle(); - MethodHandle closeHandle = metadata.getCloseHandle(); - MethodHandle errorHandle = metadata.getErrorHandle(); - MethodHandle textHandle = metadata.getTextHandle(); - MethodHandle binaryHandle = metadata.getBinaryHandle(); - Class textSinkClass = metadata.getTextSink(); - Class binarySinkClass = metadata.getBinarySink(); - MethodHandle frameHandle = metadata.getFrameHandle(); - MethodHandle pingHandle = metadata.getPingHandle(); - MethodHandle pongHandle = metadata.getPongHandle(); + final MethodHandle openHandle = bindTo(metadata.getOpenHandle(), endpointInstance); + final MethodHandle closeHandle = bindTo(metadata.getCloseHandle(), endpointInstance); + final MethodHandle errorHandle = bindTo(metadata.getErrorHandle(), endpointInstance); + final MethodHandle textHandle = bindTo(metadata.getTextHandle(), endpointInstance); + final MethodHandle binaryHandle = bindTo(metadata.getBinaryHandle(), endpointInstance); + final Class textSinkClass = metadata.getTextSink(); + final Class binarySinkClass = metadata.getBinarySink(); + final MethodHandle frameHandle = bindTo(metadata.getFrameHandle(), endpointInstance); + final MethodHandle pingHandle = bindTo(metadata.getPingHandle(), endpointInstance); + final MethodHandle pongHandle = bindTo(metadata.getPongHandle(), endpointInstance); BatchMode batchMode = metadata.getBatchMode(); - openHandle = bindTo(openHandle, endpointInstance); - closeHandle = bindTo(closeHandle, endpointInstance); - errorHandle = bindTo(errorHandle, endpointInstance); - textHandle = bindTo(textHandle, endpointInstance); - binaryHandle = bindTo(binaryHandle, endpointInstance); - frameHandle = bindTo(frameHandle, endpointInstance); - pingHandle = bindTo(pingHandle, endpointInstance); - pongHandle = bindTo(pongHandle, endpointInstance); - JettyWebSocketFrameHandler frameHandler = new JettyWebSocketFrameHandler( container, endpointInstance, diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java index b4a76dbeb3c2..e69bc7010a12 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java @@ -84,6 +84,19 @@ public void close(int statusCode, String reason) } } + @Override + public void sendString(String text) throws IOException + { + sendBlocking(new Frame(OpCode.TEXT).setPayload(text)); + } + + @Override + public void sendString(String text, WriteCallback callback) + { + Callback cb = callback == null ? Callback.NOOP : Callback.from(callback::writeSuccess, callback::writeFailed); + coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload(text), cb, isBatch()); + } + @Override public void sendBytes(ByteBuffer data) throws IOException { @@ -114,17 +127,32 @@ public void sendPartialBytes(ByteBuffer fragment, boolean isLast, WriteCallback sendPartialBytes(fragment, isLast, Callback.from(callback::writeSuccess, callback::writeFailed)); } - @Override - public void sendString(String text) throws IOException + private void sendPartialBytes(ByteBuffer fragment, boolean isLast, Callback callback) { - sendBlocking(new Frame(OpCode.TEXT).setPayload(text)); - } + Frame frame; + switch (messageType) + { + case -1: // new message + frame = new Frame(OpCode.BINARY); + messageType = OpCode.BINARY; + break; + case OpCode.BINARY: + frame = new Frame(OpCode.CONTINUATION); + break; + default: + callback.failed(new ProtocolException("Attempt to send Partial Binary during active opcode " + messageType)); + return; + } - @Override - public void sendString(String text, WriteCallback callback) - { - Callback cb = callback == null ? Callback.NOOP : Callback.from(callback::writeSuccess, callback::writeFailed); - coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload(text), cb, isBatch()); + frame.setPayload(fragment); + frame.setFin(isLast); + + coreSession.sendFrame(frame, callback, isBatch()); + + if (isLast) + { + messageType = -1; + } } @Override @@ -169,34 +197,6 @@ public void sendPong(ByteBuffer applicationData, WriteCallback callback) Callback.from(callback::writeSuccess, callback::writeFailed), false); } - private void sendPartialBytes(ByteBuffer fragment, boolean isLast, Callback callback) - { - Frame frame; - switch (messageType) - { - case -1: // new message - frame = new Frame(OpCode.BINARY); - messageType = OpCode.BINARY; - break; - case OpCode.BINARY: - frame = new Frame(OpCode.CONTINUATION); - break; - default: - callback.failed(new ProtocolException("Attempt to send Partial Binary during active opcode " + messageType)); - return; - } - - frame.setPayload(fragment); - frame.setFin(isLast); - - coreSession.sendFrame(frame, callback, isBatch()); - - if (isLast) - { - messageType = -1; - } - } - private void sendPartialText(String fragment, boolean isLast, Callback callback) { Frame frame; diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtils.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtils.java index ed0c39152e8a..f533f5c6ec74 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtils.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtils.java @@ -136,26 +136,6 @@ public static MethodHandle mutatedInvoker(Class targetClass, Method method, P return mutatedInvoker(targetClass, true, method, paramIdentifier, callingArgs); } - /** - * Create an optional MethodHandle that performs the following layers. - *
    - *
  1. {@link MethodHandles#permuteArguments(MethodHandle, MethodType, int...)} - moving calling Args around - * to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwords
  2. - *
  3. {@link MethodHandles#dropArguments(MethodHandle, int, Class[])} - to drop the unused calling args
  4. - *
  5. {@link MethodHandle#invoke(Object...)} - to call the specific method
  6. - *
- * - * @param targetClass the target class for invocations of the resulting MethodHandle (also known as parameter 0) - * @param method the method to invoke - * @param paramIdentifier the mechanism to identify parameters in method - * @param callingArgs the calling arguments - * @return the MethodHandle for this set of CallingArgs, or null if not possible to create MethodHandle with CallingArgs to provided method - */ - public static MethodHandle optionalMutatedInvoker(Class targetClass, Method method, ParamIdentifier paramIdentifier, Arg... callingArgs) - { - return mutatedInvoker(targetClass, false, method, paramIdentifier, callingArgs); - } - private static MethodHandle mutatedInvoker(Class targetClass, boolean throwOnFailure, Method method, ParamIdentifier paramIdentifier, Arg... callingArgs) { Class[] parameterTypes = method.getParameterTypes(); @@ -339,6 +319,26 @@ private static MethodHandle mutatedInvoker(Class targetClass, boolean throwOn } } + /** + * Create an optional MethodHandle that performs the following layers. + *
    + *
  1. {@link MethodHandles#permuteArguments(MethodHandle, MethodType, int...)} - moving calling Args around + * to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwords
  2. + *
  3. {@link MethodHandles#dropArguments(MethodHandle, int, Class[])} - to drop the unused calling args
  4. + *
  5. {@link MethodHandle#invoke(Object...)} - to call the specific method
  6. + *
+ * + * @param targetClass the target class for invocations of the resulting MethodHandle (also known as parameter 0) + * @param method the method to invoke + * @param paramIdentifier the mechanism to identify parameters in method + * @param callingArgs the calling arguments + * @return the MethodHandle for this set of CallingArgs, or null if not possible to create MethodHandle with CallingArgs to provided method + */ + public static MethodHandle optionalMutatedInvoker(Class targetClass, Method method, ParamIdentifier paramIdentifier, Arg... callingArgs) + { + return mutatedInvoker(targetClass, false, method, paramIdentifier, callingArgs); + } + private static void appendTypeList(StringBuilder str, Arg[] args) { str.append("("); diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java index de82c5aa462c..0275496e9db3 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageOutputStream.java @@ -104,26 +104,6 @@ public void flush() throws IOException } } - @Override - public void close() throws IOException - { - try - { - flush(true); - bufferPool.release(buffer); - if (LOG.isDebugEnabled()) - LOG.debug("Stream closed, {} frames ({} bytes) sent", frameCount, bytesSent); - // Notify without holding locks. - notifySuccess(); - } - catch (Throwable x) - { - // Notify without holding locks. - notifyFailure(x); - throw x; - } - } - private void flush(boolean fin) throws IOException { synchronized (this) @@ -182,6 +162,26 @@ private void send(byte[] bytes, final int offset, final int length) throws IOExc } } + @Override + public void close() throws IOException + { + try + { + flush(true); + bufferPool.release(buffer); + if (LOG.isDebugEnabled()) + LOG.debug("Stream closed, {} frames ({} bytes) sent", frameCount, bytesSent); + // Notify without holding locks. + notifySuccess(); + } + catch (Throwable x) + { + // Notify without holding locks. + notifyFailure(x); + throw x; + } + } + public void setCallback(Callback callback) { synchronized (this) diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java index 7a7395ab5533..534a71940399 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java @@ -110,25 +110,6 @@ public void flush() throws IOException } } - @Override - public void close() throws IOException - { - try - { - flush(true); - if (LOG.isDebugEnabled()) - LOG.debug("Stream closed, {} frames sent", frameCount); - // Notify without holding locks. - notifySuccess(); - } - catch (Throwable x) - { - // Notify without holding locks. - notifyFailure(x); - throw x; - } - } - private void flush(boolean fin) throws IOException { synchronized (this) @@ -190,6 +171,25 @@ private void send(char[] chars, int offset, int length) throws IOException } } + @Override + public void close() throws IOException + { + try + { + flush(true); + if (LOG.isDebugEnabled()) + LOG.debug("Stream closed, {} frames sent", frameCount); + // Notify without holding locks. + notifySuccess(); + } + catch (Throwable x) + { + // Notify without holding locks. + notifyFailure(x); + throw x; + } + } + public void setCallback(Callback callback) { synchronized (this) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Frame.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Frame.java index 4512be9d12af..3aea6897147a 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Frame.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Frame.java @@ -149,7 +149,7 @@ public boolean isDataFrame() protected void copyHeaders(Frame frame) { - byte opCode = (byte)(finRsvOp & 0x0F); + final byte opCode = (byte)(finRsvOp & 0x0F); finRsvOp = 0x00; finRsvOp |= frame.isFin() ? 0x80 : 0x00; finRsvOp |= frame.isRsv1() ? 0x40 : 0x00; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java index 61e81b744d71..86d962b5f2e9 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java @@ -151,6 +151,8 @@ public void onFrame(Frame frame, Callback callback) if (frame.isFin()) dataType = OpCode.UNDEFINED; break; + default: + callback.failed(new IllegalStateException()); } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java index fbb79bbb2106..f53331d4b881 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java @@ -149,8 +149,10 @@ public boolean enqueue(Frame frame, Callback callback, boolean batch) if (failedEntries != null) { - WebSocketException failure = new WebSocketException("Flusher received abnormal CloseFrame: " - + CloseStatus.codeString(closeStatus.getCode()), closeStatus.getCause()); + WebSocketException failure = + new WebSocketException( + "Flusher received abnormal CloseFrame: " + + CloseStatus.codeString(closeStatus.getCode()), closeStatus.getCause()); for (Entry e : failedEntries) { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java index 37e9b31827c5..176adf382dde 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java @@ -221,6 +221,9 @@ else if (payloadLength == 0) LOG.debug("{} parsed {}", this, frame); return frame; } + + default: + throw new IllegalStateException(); } } } @@ -307,7 +310,7 @@ private ParsedFrame parsePayload(ByteBuffer buffer) nextMask[2] = mask[(2 + shift) % 4]; nextMask[3] = mask[(3 + shift) % 4]; } - ParsedFrame frame = newFrame((byte)(firstByte & 0x7F), mask, buffer.slice(), false); + final ParsedFrame frame = newFrame((byte)(firstByte & 0x7F), mask, buffer.slice(), false); buffer.position(buffer.limit()); mask = nextMask; firstByte = (byte)((firstByte & 0x80) | OpCode.CONTINUATION); @@ -335,7 +338,7 @@ private ParsedFrame parsePayload(ByteBuffer buffer) int limit = buffer.limit(); int end = buffer.position() + payloadLength; buffer.limit(end); - ParsedFrame frame = newFrame(firstByte, mask, buffer.slice(), false); + final ParsedFrame frame = newFrame(firstByte, mask, buffer.slice(), false); buffer.position(end); buffer.limit(limit); state = State.START; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java index 12e8ef7ea54d..b4cb554d2cdd 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java @@ -114,6 +114,9 @@ public void assertValidIncoming(Frame frame) if (frame.isMasked()) throw new ProtocolException("Server MUST NOT mask any frames (RFC-6455: Section 5.1)"); break; + + default: + throw new IllegalStateException(behavior.toString()); } /* @@ -140,7 +143,7 @@ public void assertValidOutgoing(Frame frame) throws CloseException if (!(frame instanceof ParsedFrame)) // already check in parser { CloseStatus closeStatus = CloseStatus.getCloseStatus(frame); - if (!CloseStatus.isTransmittableStatusCode(closeStatus.getCode()) && (closeStatus.getCode()!=CloseStatus.NO_CODE)) + if (!CloseStatus.isTransmittableStatusCode(closeStatus.getCode()) && (closeStatus.getCode() != CloseStatus.NO_CODE)) { throw new ProtocolException("Frame has non-transmittable status code"); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/CompressExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/CompressExtension.java index 912fabbfe8f8..d40a78799656 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/CompressExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/CompressExtension.java @@ -497,7 +497,7 @@ private void compress(FrameEntry entry, boolean first) { // Handle tail bytes generated by SYNC_FLUSH. if (LOG.isDebugEnabled()) - LOG.debug("compressed bytes[] = {}", BufferUtil.toDetailString(payload)); + LOG.debug("compressed[] bytes = {}", BufferUtil.toDetailString(payload)); if (tailDrop == TAIL_DROP_ALWAYS) { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/PerMessageDeflateExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/PerMessageDeflateExtension.java index c09e2777dbd3..9304ab28436d 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/PerMessageDeflateExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/compress/PerMessageDeflateExtension.java @@ -74,6 +74,8 @@ public void onFrame(Frame frame, Callback callback) if (frame.isRsv1()) callback.failed(new ProtocolException("Invalid RSV1 set on permessage-deflate CONTINUATION frame")); break; + default: + break; } if (OpCode.isControlFrame(frame.getOpCode()) || !incomingCompressed) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java index 62766e01d54f..010f43bf30f7 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java @@ -67,9 +67,9 @@ public final class RFC6455Handshaker implements Handshaker public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, FrameHandler.Customizer defaultCustomizer) throws IOException { - Request baseRequest = Request.getBaseRequest(request); - HttpChannel httpChannel = baseRequest.getHttpChannel(); - Connector connector = httpChannel.getConnector(); + final Request baseRequest = Request.getBaseRequest(request); + final HttpChannel httpChannel = baseRequest.getHttpChannel(); + final Connector connector = httpChannel.getConnector(); if (negotiator == null) { diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java index d6238b474841..0d340ed8da75 100644 --- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketMapping.java @@ -75,6 +75,12 @@ public static WebSocketMapping getMapping(ServletContext servletContext, String return null; } + public WebSocketCreator getMapping(PathSpec pathSpec) + { + Negotiator cn = mappings.get(pathSpec); + return cn == null ? null : cn.getWebSocketCreator(); + } + public static WebSocketMapping ensureMapping(ServletContext servletContext, String mappingKey) { WebSocketMapping mapping = getMapping(servletContext, mappingKey); @@ -185,12 +191,6 @@ public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandler mappings.put(pathSpec, new Negotiator(creator, factory, customizer)); } - public WebSocketCreator getMapping(PathSpec pathSpec) - { - Negotiator cn = mappings.get(pathSpec); - return cn == null ? null : cn.getWebSocketCreator(); - } - public boolean removeMapping(PathSpec pathSpec) { return mappings.remove(pathSpec); diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java index 629567174a34..af5c385e75f0 100644 --- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java @@ -109,16 +109,15 @@ public static FilterHolder ensureFilter(ServletContext servletContext) if (existingFilter != null) return existingFilter; - String name = "WebSocketUpgradeFilter"; - String pathSpec = "/*"; - EnumSet dispatcherTypes = EnumSet.of(DispatcherType.REQUEST); + final String name = "WebSocketUpgradeFilter"; + final String pathSpec = "/*"; FilterHolder holder = new FilterHolder(new WebSocketUpgradeFilter()); holder.setName(name); holder.setInitParameter(MAPPING_ATTRIBUTE_INIT_PARAM, WebSocketMapping.DEFAULT_KEY); holder.setAsyncSupported(true); ServletHandler servletHandler = ContextHandler.getContextHandler(servletContext).getChildHandlerByClass(ServletHandler.class); - servletHandler.addFilterWithMapping(holder, pathSpec, dispatcherTypes); + servletHandler.addFilterWithMapping(holder, pathSpec, EnumSet.of(DispatcherType.REQUEST)); if (LOG.isDebugEnabled()) LOG.debug("Adding {} mapped to {} in {}", holder, pathSpec, servletContext); return holder; diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/internal/UpgradeHttpServletRequest.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/internal/UpgradeHttpServletRequest.java index 9e31c2b7604c..85fa5b968e6b 100644 --- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/internal/UpgradeHttpServletRequest.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/internal/UpgradeHttpServletRequest.java @@ -172,15 +172,15 @@ public Enumeration getHeaders(String name) return Collections.enumeration(values); } - @Override - public Enumeration getHeaderNames() + public Map> getHeaders() { - return Collections.enumeration(headers.keySet()); + return Collections.unmodifiableMap(headers); } - public Map> getHeaders() + @Override + public Enumeration getHeaderNames() { - return Collections.unmodifiableMap(headers); + return Collections.enumeration(headers.keySet()); } @Override diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlAppendable.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlAppendable.java index 9d848b3b8a30..56c990f2592e 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlAppendable.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlAppendable.java @@ -117,16 +117,6 @@ public XmlAppendable tag(String tag, String content) throws IOException return this; } - // @checkstyle-disable-check : AbbreviationAsWordInNameCheck - public XmlAppendable tagCDATA(String tag, String data) throws IOException - { - _out.append(_space).append('<').append(tag).append('>'); - cdata(data); - _out.append("\n"); - return this; - } - // @checkstyle-enable-check : AbbreviationAsWordInNameCheck - public XmlAppendable tag(String tag, Map attributes, String content) throws IOException { _out.append(_space).append('<').append(tag); @@ -137,6 +127,16 @@ public XmlAppendable tag(String tag, Map attributes, String cont return this; } + // @checkstyle-disable-check : AbbreviationAsWordInNameCheck + public XmlAppendable tagCDATA(String tag, String data) throws IOException + { + _out.append(_space).append('<').append(tag).append('>'); + cdata(data); + _out.append("\n"); + return this; + } + // @checkstyle-enable-check : AbbreviationAsWordInNameCheck + public XmlAppendable closeTag() throws IOException { if (_tags.isEmpty()) diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index 33bc54fdc6c2..dd4000c758fb 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -82,18 +82,18 @@ public class XmlConfiguration { private static final Logger LOG = Log.getLogger(XmlConfiguration.class); private static final Class[] __primitives = - { - Boolean.TYPE, Character.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, Void.TYPE - }; + { + Boolean.TYPE, Character.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, Void.TYPE + }; private static final Class[] __boxedPrimitives = - { - Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, - Void.class - }; + { + Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, + Void.class + }; private static final Class[] __supportedCollections = - { - ArrayList.class, HashSet.class, Queue.class, List.class, Set.class, Collection.class - }; + { + ArrayList.class, HashSet.class, Queue.class, List.class, Set.class, Collection.class + }; private static final Iterable __factoryLoader = ServiceLoader.load(ConfigurationProcessorFactory.class); private static final XmlParser __parser = initParser(); @@ -398,14 +398,6 @@ public Object configure() throws Exception return obj; } - private static Class nodeClass(XmlParser.Node node) throws ClassNotFoundException - { - String className = node.getAttribute("class"); - if (className == null) - return null; - return Loader.loadClass(className); - } - /** * Recursive configuration routine. * This method applies the nested Set, Put, Call, etc. elements to the given object. @@ -490,6 +482,14 @@ public void configure(Object obj, XmlParser.Node cfg, int i) throws Exception } } + private static Class nodeClass(XmlParser.Node node) throws ClassNotFoundException + { + String className = node.getAttribute("class"); + if (className == null) + return null; + return Loader.loadClass(className); + } + /** *

Call a setter method.

*

This method makes a best effort to find a matching set method. @@ -579,31 +579,31 @@ private void set(Object obj, XmlParser.Node node) throws Exception Field field = oClass.getField(attr); if (Modifier.isPublic(field.getModifiers())) { - try - { - setField(field, obj, value); - return; - } - catch (IllegalArgumentException e) - { - // try to convert String value to field value - if (value instanceof String) + try { - try - { - value = TypeUtil.valueOf(field.getType(), ((String)value).trim()); - setField(field, obj, value); - return; - } - catch (Exception e2) + setField(field, obj, value); + return; + } + catch (IllegalArgumentException e) + { + // try to convert String value to field value + if (value instanceof String) { - e.addSuppressed(e2); - throw e; + try + { + value = TypeUtil.valueOf(field.getType(), ((String)value).trim()); + setField(field, obj, value); + return; + } + catch (Exception e2) + { + e.addSuppressed(e2); + throw e; + } } } } } - } catch (NoSuchFieldException e) { LOG.ignore(e); @@ -963,10 +963,10 @@ private Object call(Class oClass, String methodName, Object obj, Object[] arg */ private Object newObj(Object obj, XmlParser.Node node) throws Exception { - AttrOrElementNode aoeNode = new AttrOrElementNode(obj, node, "Id", "Class", "Arg"); - String id = aoeNode.getString("Id"); - String clazz = aoeNode.getString("Class"); - List argNodes = aoeNode.getNodes("Arg"); + final AttrOrElementNode aoeNode = new AttrOrElementNode(obj, node, "Id", "Class", "Arg"); + final String id = aoeNode.getString("Id"); + final String clazz = aoeNode.getString("Class"); + final List argNodes = aoeNode.getNodes("Arg"); if (LOG.isDebugEnabled()) LOG.debug("XML new " + clazz); @@ -1227,11 +1227,11 @@ private Object newMap(Object obj, XmlParser.Node node) throws Exception */ private Object propertyObj(XmlParser.Node node) throws Exception { - AttrOrElementNode aoeNode = new AttrOrElementNode(node, "Id", "Name", "Deprecated", "Default"); - String id = aoeNode.getString("Id"); - String name = aoeNode.getString("Name", true); - List deprecated = aoeNode.getList("Deprecated"); - String dftValue = aoeNode.getString("Default"); + final AttrOrElementNode aoeNode = new AttrOrElementNode(node, "Id", "Name", "Deprecated", "Default"); + final String id = aoeNode.getString("Id"); + final String name = aoeNode.getString("Name", true); + final List deprecated = aoeNode.getList("Deprecated"); + final String dftValue = aoeNode.getString("Default"); // Look for a value Map properties = _configuration.getProperties(); @@ -1278,11 +1278,11 @@ private Object propertyObj(XmlParser.Node node) throws Exception */ private Object systemPropertyObj(XmlParser.Node node) throws Exception { - AttrOrElementNode aoeNode = new AttrOrElementNode(node, "Id", "Name", "Deprecated", "Default"); - String id = aoeNode.getString("Id"); - String name = aoeNode.getString("Name", true); - List deprecated = aoeNode.getList("Deprecated"); - String dftValue = aoeNode.getString("Default"); + final AttrOrElementNode aoeNode = new AttrOrElementNode(node, "Id", "Name", "Deprecated", "Default"); + final String id = aoeNode.getString("Id"); + final String name = aoeNode.getString("Name", true); + final List deprecated = aoeNode.getList("Deprecated"); + final String dftValue = aoeNode.getString("Default"); // Look for a value String value = System.getProperty(name); diff --git a/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/HttpTester.java b/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/HttpTester.java index 75a4945285fe..c7b847541e74 100644 --- a/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/HttpTester.java +++ b/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/HttpTester.java @@ -72,77 +72,6 @@ public class HttpTester { private static final Logger LOG = Log.getLogger(HttpTester.class); - private HttpTester() - { - } - - public static Request newRequest() - { - Request r = new Request(); - r.setMethod(HttpMethod.GET.asString()); - r.setURI("/"); - r.setVersion(HttpVersion.HTTP_1_1); - return r; - } - - public static Request parseRequest(String request) - { - Request r = new Request(); - HttpParser parser = new HttpParser(r); - parser.parseNext(BufferUtil.toBuffer(request)); - return r; - } - - public static Request parseRequest(ByteBuffer request) - { - Request r = new Request(); - HttpParser parser = new HttpParser(r); - parser.parseNext(request); - return r; - } - - public static Response parseResponse(String response) - { - Response r = new Response(); - HttpParser parser = new HttpParser(r); - parser.parseNext(BufferUtil.toBuffer(response)); - return r; - } - - public static Response parseResponse(ByteBuffer response) - { - Response r = new Response(); - HttpParser parser = new HttpParser(r); - parser.parseNext(response); - return r; - } - - public static Response parseResponse(InputStream responseStream) throws IOException - { - Response r = new Response(); - HttpParser parser = new HttpParser(r); - - // Read and parse a character at a time so we never can read more than we should. - byte[] array = new byte[1]; - ByteBuffer buffer = ByteBuffer.wrap(array); - buffer.limit(1); - - while (true) - { - buffer.position(1); - int l = responseStream.read(array); - if (l < 0) - parser.atEOF(); - else - buffer.position(0); - - if (parser.parseNext(buffer)) - return r; - else if (l < 0) - return null; - } - } - public abstract static class Input { protected final ByteBuffer _buffer; @@ -238,6 +167,77 @@ public int fillBuffer() throws IOException }; } + private HttpTester() + { + } + + public static Request newRequest() + { + Request r = new Request(); + r.setMethod(HttpMethod.GET.asString()); + r.setURI("/"); + r.setVersion(HttpVersion.HTTP_1_1); + return r; + } + + public static Request parseRequest(String request) + { + Request r = new Request(); + HttpParser parser = new HttpParser(r); + parser.parseNext(BufferUtil.toBuffer(request)); + return r; + } + + public static Request parseRequest(ByteBuffer request) + { + Request r = new Request(); + HttpParser parser = new HttpParser(r); + parser.parseNext(request); + return r; + } + + public static Response parseResponse(String response) + { + Response r = new Response(); + HttpParser parser = new HttpParser(r); + parser.parseNext(BufferUtil.toBuffer(response)); + return r; + } + + public static Response parseResponse(ByteBuffer response) + { + Response r = new Response(); + HttpParser parser = new HttpParser(r); + parser.parseNext(response); + return r; + } + + public static Response parseResponse(InputStream responseStream) throws IOException + { + Response r = new Response(); + HttpParser parser = new HttpParser(r); + + // Read and parse a character at a time so we never can read more than we should. + byte[] array = new byte[1]; + ByteBuffer buffer = ByteBuffer.wrap(array); + buffer.limit(1); + + while (true) + { + buffer.position(1); + int l = responseStream.read(array); + if (l < 0) + parser.atEOF(); + else + buffer.position(0); + + if (parser.parseNext(buffer)) + return r; + else if (l < 0) + return null; + } + } + public static Response parseResponse(Input in) throws IOException { Response r; @@ -372,8 +372,8 @@ public String getContent() return null; byte[] bytes = _content.toByteArray(); - String content_type = get(HttpHeader.CONTENT_TYPE); - String encoding = MimeTypes.getCharsetFromContentType(content_type); + String contentType = get(HttpHeader.CONTENT_TYPE); + String encoding = MimeTypes.getCharsetFromContentType(contentType); Charset charset = encoding == null ? StandardCharsets.UTF_8 : Charset.forName(encoding); return new String(bytes, charset); @@ -493,6 +493,9 @@ public ByteBuffer generate() case SHUTDOWN_OUT: break loop; + + default: + break; // TODO verify if this should be ISE } } @@ -504,7 +507,7 @@ public ByteBuffer generate() } } - abstract public MetaData getInfo(); + public abstract MetaData getInfo(); @Override public int getHeaderCacheSize() diff --git a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/requestlog/jmh/RequestLogBenchmark.java b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/requestlog/jmh/RequestLogBenchmark.java index c32e432edaca..085d4cecd192 100644 --- a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/requestlog/jmh/RequestLogBenchmark.java +++ b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/requestlog/jmh/RequestLogBenchmark.java @@ -94,14 +94,14 @@ public RequestLogBenchmark() // setup iteration iteratedLog = new Object[] - { - logURI, - " - ", - logAddr, - " ", - logLength, - "\n" - }; + { + logURI, + " - ", + logAddr, + " ", + logLength, + "\n" + }; // setup methodHandle logHandle = dropArguments(append.bindTo("\n"), 1, String.class); diff --git a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheNoTick.java b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheNoTick.java index e24baa99f31c..929cbd4c4f7f 100644 --- a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheNoTick.java +++ b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheNoTick.java @@ -90,8 +90,8 @@ public DateCacheNoTick(String format, Locale l, TimeZone tz) int zIndex = _formatString.indexOf("ZZZ"); if (zIndex >= 0) { - String ss1 = _formatString.substring(0, zIndex); - String ss2 = _formatString.substring(zIndex + 3); + final String ss1 = _formatString.substring(0, zIndex); + final String ss2 = _formatString.substring(zIndex + 3); int tzOffset = tz.getRawOffset(); StringBuilder sb = new StringBuilder(_formatString.length() + 10); diff --git a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheSimpleDateFormat.java b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheSimpleDateFormat.java index d6598d8f831a..3cef756975c4 100644 --- a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheSimpleDateFormat.java +++ b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/jmh/DateCacheSimpleDateFormat.java @@ -101,8 +101,8 @@ public DateCacheSimpleDateFormat(String format, Locale l, TimeZone tz) int zIndex = _formatString.indexOf("ZZZ"); if (zIndex >= 0) { - String ss1 = _formatString.substring(0, zIndex); - String ss2 = _formatString.substring(zIndex + 3); + final String ss1 = _formatString.substring(0, zIndex); + final String ss2 = _formatString.substring(zIndex + 3); int tzOffset = tz.getRawOffset(); StringBuilder sb = new StringBuilder(_formatString.length() + 10); diff --git a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/thread/jmh/ThreadPoolBenchmark.java b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/thread/jmh/ThreadPoolBenchmark.java index 9c6e630fc596..02fb4aa1a894 100644 --- a/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/thread/jmh/ThreadPoolBenchmark.java +++ b/tests/jetty-jmh/src/main/java/org/eclipse/jetty/util/thread/jmh/ThreadPoolBenchmark.java @@ -102,6 +102,9 @@ public void buildPool() case AETP: pool = new ExecutorThreadPool(size, size, new ArrayBlockingQueue<>(32768)); break; + + default: + throw new IllegalStateException(); } LifeCycle.start(pool); } diff --git a/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/AttributeNormalizerTest.java b/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/AttributeNormalizerTest.java index 6f6f94542027..cc997f6af0d4 100644 --- a/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/AttributeNormalizerTest.java +++ b/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/AttributeNormalizerTest.java @@ -44,9 +44,8 @@ public class AttributeNormalizerTest { public static Stream scenarios() throws IOException { - List data = new ArrayList<>(); - - String arch = String.format("%s/%s", System.getProperty("os.name"), System.getProperty("os.arch")); + final List data = new ArrayList<>(); + final String arch = String.format("%s/%s", System.getProperty("os.name"), System.getProperty("os.arch")); String title; Map env; diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java index 6a5a07dd92a1..2c45ab877b92 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java @@ -61,10 +61,10 @@ public void pause(int secs) @Test public void testClusteredScavenge() throws Exception { - String contextPath = "/"; - String servletMapping = "/server"; - int maxInactivePeriod = 5; //session will timeout after 5 seconds - int scavengePeriod = 1; //scavenging occurs every 1 seconds + final String contextPath = "/"; + final String servletMapping = "/server"; + final int maxInactivePeriod = 5; //session will timeout after 5 seconds + final int scavengePeriod = 1; //scavenging occurs every 1 seconds DefaultSessionCacheFactory cacheFactory1 = new DefaultSessionCacheFactory(); cacheFactory1.setEvictionPolicy(SessionCache.NEVER_EVICT); //don't evict sessions diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStoreTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStoreTest.java index aba2cd3517a5..6e9d09a275b9 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStoreTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStoreTest.java @@ -174,7 +174,7 @@ public void testUpdateSession() throws Exception store.start(); //create a session - long now = System.currentTimeMillis(); + final long now = System.currentTimeMillis(); SessionData data = store.newSessionData("1234", 100, 200, 199, -1);//never expires data.setAttribute("a", "b"); data.setLastNode(sessionContext.getWorkerName()); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java index 8ae693545446..37963a5672cc 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java @@ -49,9 +49,9 @@ public abstract class AbstractWebAppObjectInSessionTest extends AbstractTestBase @Test public void testWebappObjectInSession() throws Exception { - String contextName = "webappObjectInSessionTest"; - String contextPath = "/" + contextName; - String servletMapping = "/server"; + final String contextName = "webappObjectInSessionTest"; + final String contextPath = "/" + contextName; + final String servletMapping = "/server"; File targetDir = new File(System.getProperty("basedir"), "target"); File warDir = new File(targetDir, contextName); diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java index d954008674c4..08939e09e8a9 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java +++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java @@ -986,7 +986,6 @@ private boolean dump(HttpServletResponse response, String data, String chars, St { if (data != null && data.length() > 0) { - long d = Long.parseLong(data); int b = (block != null && block.length() > 0) ? Integer.parseInt(block) : 50; byte[] buf = new byte[b]; for (int i = 0; i < b; i++) @@ -999,6 +998,7 @@ private boolean dump(HttpServletResponse response, String data, String chars, St buf[0] = 'o'; OutputStream out = response.getOutputStream(); response.setContentType("text/plain"); + long d = Long.parseLong(data); while (d > 0) { if (b == 1) @@ -1041,7 +1041,6 @@ else if (d >= b) // Handle a dump of data if (chars != null && chars.length() > 0) { - long d = Long.parseLong(chars); int b = (block != null && block.length() > 0) ? Integer.parseInt(block) : 50; char[] buf = new char[b]; for (int i = 0; i < b; i++) @@ -1053,6 +1052,7 @@ else if (d >= b) buf[0] = 'o'; response.setContentType("text/plain"); PrintWriter out = response.getWriter(); + long d = Long.parseLong(chars); while (d > 0 && !out.checkError()) { if (b == 1) diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TagListener.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TagListener.java index 11fae68efc01..ad0b9e2c0378 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TagListener.java +++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TagListener.java @@ -41,98 +41,98 @@ public void attributeAdded(HttpSessionBindingEvent se) } @Override - public void attributeRemoved(HttpSessionBindingEvent se) + public void attributeAdded(ServletContextAttributeEvent scab) { - //System.err.println("tagListener: attributeRemoved "+se); + //System.err.println("tagListener: attributeAdded "+scab); } @Override - public void attributeReplaced(HttpSessionBindingEvent se) + public void attributeAdded(ServletRequestAttributeEvent srae) { - //System.err.println("tagListener: attributeReplaced "+se); + //System.err.println("tagListener: attributeAdded "+srae); } @Override - public void sessionWillPassivate(HttpSessionEvent se) + public void attributeRemoved(HttpSessionBindingEvent se) { - //System.err.println("tagListener: sessionWillPassivate "+se); + //System.err.println("tagListener: attributeRemoved "+se); } @Override - public void sessionDidActivate(HttpSessionEvent se) + public void attributeRemoved(ServletContextAttributeEvent scab) { - //System.err.println("tagListener: sessionDidActivate "+se); + //System.err.println("tagListener: attributeRemoved "+scab); } @Override - public void contextInitialized(ServletContextEvent sce) + public void attributeRemoved(ServletRequestAttributeEvent srae) { - //System.err.println("tagListener: contextInitialized "+sce); + //System.err.println("tagListener: attributeRemoved "+srae); } @Override - public void contextDestroyed(ServletContextEvent sce) + public void attributeReplaced(HttpSessionBindingEvent se) { - //System.err.println("tagListener: contextDestroyed "+sce); + //System.err.println("tagListener: attributeReplaced "+se); } @Override - public void attributeAdded(ServletContextAttributeEvent scab) + public void attributeReplaced(ServletContextAttributeEvent scab) { - //System.err.println("tagListener: attributeAdded "+scab); + //System.err.println("tagListener: attributeReplaced "+scab); } @Override - public void attributeRemoved(ServletContextAttributeEvent scab) + public void attributeReplaced(ServletRequestAttributeEvent srae) { - //System.err.println("tagListener: attributeRemoved "+scab); + //System.err.println("tagListener: attributeReplaced "+srae); } @Override - public void attributeReplaced(ServletContextAttributeEvent scab) + public void contextDestroyed(ServletContextEvent sce) { - //System.err.println("tagListener: attributeReplaced "+scab); + //System.err.println("tagListener: contextDestroyed "+sce); } @Override - public void requestDestroyed(ServletRequestEvent sre) + public void contextInitialized(ServletContextEvent sce) { - //System.err.println("tagListener: requestDestroyed "+sre); + //System.err.println("tagListener: contextInitialized "+sce); } @Override - public void requestInitialized(ServletRequestEvent sre) + public void requestDestroyed(ServletRequestEvent sre) { - //System.err.println("tagListener: requestInitialized "+sre); + //System.err.println("tagListener: requestDestroyed "+sre); } @Override - public void attributeAdded(ServletRequestAttributeEvent srae) + public void requestInitialized(ServletRequestEvent sre) { - //System.err.println("tagListener: attributeAdded "+srae); + //System.err.println("tagListener: requestInitialized "+sre); } @Override - public void attributeRemoved(ServletRequestAttributeEvent srae) + public void sessionCreated(HttpSessionEvent se) { - //System.err.println("tagListener: attributeRemoved "+srae); + //System.err.println("tagListener: sessionCreated "+se); } @Override - public void attributeReplaced(ServletRequestAttributeEvent srae) + public void sessionDestroyed(HttpSessionEvent se) { - //System.err.println("tagListener: attributeReplaced "+srae); + //System.err.println("tagListener: sessionDestroyed "+se); } @Override - public void sessionCreated(HttpSessionEvent se) + public void sessionDidActivate(HttpSessionEvent se) { - //System.err.println("tagListener: sessionCreated "+se); + //System.err.println("tagListener: sessionDidActivate "+se); } @Override - public void sessionDestroyed(HttpSessionEvent se) + public void sessionWillPassivate(HttpSessionEvent se) { - //System.err.println("tagListener: sessionDestroyed "+se); + //System.err.println("tagListener: sessionWillPassivate "+se); } } diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java index 5ae289e030a5..8658bf02d529 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java +++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java @@ -55,24 +55,26 @@ public TestListener() _called.put("TestListener", new Throwable()); } - @PostConstruct - public void postConstruct() + @Override + public void attributeAdded(HttpSessionBindingEvent se) { - _called.put("postConstruct", new Throwable()); + // System.err.println("attributedAdded "+se); + + _called.put("attributeAdded", new Throwable()); } - @PreDestroy - public void preDestroy() + @Override + public void attributeAdded(ServletContextAttributeEvent scab) { - _called.put("preDestroy", new Throwable()); + _called.put("attributeAdded", new Throwable()); + // System.err.println("attributeAdded "+scab); } @Override - public void attributeAdded(HttpSessionBindingEvent se) + public void attributeAdded(ServletRequestAttributeEvent srae) { - // System.err.println("attributedAdded "+se); - _called.put("attributeAdded", new Throwable()); + // System.err.println("attributeAdded "+srae); } @Override @@ -82,6 +84,20 @@ public void attributeRemoved(HttpSessionBindingEvent se) _called.put("attributeRemoved", new Throwable()); } + @Override + public void attributeRemoved(ServletContextAttributeEvent scab) + { + _called.put("attributeRemoved", new Throwable()); + // System.err.println("attributeRemoved "+scab); + } + + @Override + public void attributeRemoved(ServletRequestAttributeEvent srae) + { + _called.put("attributeRemoved", new Throwable()); + // System.err.println("attributeRemoved "+srae); + } + @Override public void attributeReplaced(HttpSessionBindingEvent se) { @@ -90,17 +106,24 @@ public void attributeReplaced(HttpSessionBindingEvent se) } @Override - public void sessionWillPassivate(HttpSessionEvent se) + public void attributeReplaced(ServletContextAttributeEvent scab) { - // System.err.println("sessionWillPassivate "+se); - _called.put("sessionWillPassivate", new Throwable()); + _called.put("attributeReplaced", new Throwable()); + // System.err.println("attributeReplaced "+scab); } @Override - public void sessionDidActivate(HttpSessionEvent se) + public void attributeReplaced(ServletRequestAttributeEvent srae) { - // System.err.println("sessionDidActivate "+se); - _called.put("sessionDidActivate", new Throwable()); + _called.put("attributeReplaced", new Throwable()); + // System.err.println("attributeReplaced "+srae); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) + { + _called.put("contextDestroyed", new Throwable()); + // System.err.println("contextDestroyed "+sce); } @Override @@ -153,32 +176,16 @@ public void contextInitialized(ServletContextEvent sce) } } - @Override - public void contextDestroyed(ServletContextEvent sce) - { - _called.put("contextDestroyed", new Throwable()); - // System.err.println("contextDestroyed "+sce); - } - - @Override - public void attributeAdded(ServletContextAttributeEvent scab) - { - _called.put("attributeAdded", new Throwable()); - // System.err.println("attributeAdded "+scab); - } - - @Override - public void attributeRemoved(ServletContextAttributeEvent scab) + @PostConstruct + public void postConstruct() { - _called.put("attributeRemoved", new Throwable()); - // System.err.println("attributeRemoved "+scab); + _called.put("postConstruct", new Throwable()); } - @Override - public void attributeReplaced(ServletContextAttributeEvent scab) + @PreDestroy + public void preDestroy() { - _called.put("attributeReplaced", new Throwable()); - // System.err.println("attributeReplaced "+scab); + _called.put("preDestroy", new Throwable()); } @Override @@ -199,37 +206,30 @@ public void requestInitialized(ServletRequestEvent sre) } @Override - public void attributeAdded(ServletRequestAttributeEvent srae) - { - _called.put("attributeAdded", new Throwable()); - // System.err.println("attributeAdded "+srae); - } - - @Override - public void attributeRemoved(ServletRequestAttributeEvent srae) + public void sessionCreated(HttpSessionEvent se) { - _called.put("attributeRemoved", new Throwable()); - // System.err.println("attributeRemoved "+srae); + _called.put("sessionCreated", new Throwable()); + // System.err.println("sessionCreated "+se); } @Override - public void attributeReplaced(ServletRequestAttributeEvent srae) + public void sessionDestroyed(HttpSessionEvent se) { - _called.put("attributeReplaced", new Throwable()); - // System.err.println("attributeReplaced "+srae); + _called.put("sessionDestroyed", new Throwable()); + // System.err.println("sessionDestroyed "+se); } @Override - public void sessionCreated(HttpSessionEvent se) + public void sessionDidActivate(HttpSessionEvent se) { - _called.put("sessionCreated", new Throwable()); - // System.err.println("sessionCreated "+se); + // System.err.println("sessionDidActivate "+se); + _called.put("sessionDidActivate", new Throwable()); } @Override - public void sessionDestroyed(HttpSessionEvent se) + public void sessionWillPassivate(HttpSessionEvent se) { - _called.put("sessionDestroyed", new Throwable()); - // System.err.println("sessionDestroyed "+se); + // System.err.println("sessionWillPassivate "+se); + _called.put("sessionWillPassivate", new Throwable()); } } diff --git a/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/AnnotatedListener.java b/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/AnnotatedListener.java index b7513219d741..fc0ff62c35b4 100644 --- a/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/AnnotatedListener.java +++ b/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/AnnotatedListener.java @@ -37,7 +37,6 @@ @WebListener public class AnnotatedListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener { - @Resource(mappedName = "maxAmount") private Double maxAmount; @@ -48,60 +47,72 @@ public void attributeAdded(HttpSessionBindingEvent se) } @Override - public void attributeRemoved(HttpSessionBindingEvent se) + public void attributeAdded(ServletContextAttributeEvent scab) { - // System.err.println("attributeRemoved "+se); + // System.err.println("attributeAdded "+scab); } @Override - public void attributeReplaced(HttpSessionBindingEvent se) + public void attributeAdded(ServletRequestAttributeEvent srae) { - // System.err.println("attributeReplaced "+se); + // System.err.println("attributeAdded "+srae); } @Override - public void sessionWillPassivate(HttpSessionEvent se) + public void attributeRemoved(HttpSessionBindingEvent se) { - // System.err.println("sessionWillPassivate "+se); + // System.err.println("attributeRemoved "+se); } @Override - public void sessionDidActivate(HttpSessionEvent se) + public void attributeRemoved(ServletContextAttributeEvent scab) { - // System.err.println("sessionDidActivate "+se); + // System.err.println("attributeRemoved "+scab); } @Override - public void contextInitialized(ServletContextEvent sce) + public void attributeRemoved(ServletRequestAttributeEvent srae) { - if (sce.getServletContext().getAttribute("com.acme.AnnotationTest.sclInjectWebListenerTest") != null) - throw new IllegalStateException("AnnotatedListener already initialized"); + // System.err.println("attributeRemoved "+srae); + } - sce.getServletContext().setAttribute("com.acme.AnnotationTest.sclInjectWebListenerTest", Boolean.valueOf(maxAmount != null)); + @Override + public void attributeReplaced(HttpSessionBindingEvent se) + { + // System.err.println("attributeReplaced "+se); } @Override - public void contextDestroyed(ServletContextEvent sce) + public void attributeReplaced(ServletContextAttributeEvent scab) { - // System.err.println("contextDestroyed "+sce); + // System.err.println("attributeReplaced "+scab); } @Override - public void attributeAdded(ServletContextAttributeEvent scab) + public void attributeReplaced(ServletRequestAttributeEvent srae) { - // System.err.println("attributeAdded "+scab); + // System.err.println("attributeReplaced "+srae); } @Override - public void attributeRemoved(ServletContextAttributeEvent scab) + public void contextDestroyed(ServletContextEvent sce) { - // System.err.println("attributeRemoved "+scab); + // System.err.println("contextDestroyed "+sce); } @Override - public void attributeReplaced(ServletContextAttributeEvent scab) + public void contextInitialized(ServletContextEvent sce) { - // System.err.println("attributeReplaced "+scab); + if (sce.getServletContext().getAttribute("com.acme.AnnotationTest.sclInjectWebListenerTest") != null) + throw new IllegalStateException("AnnotatedListener already initialized"); + + sce.getServletContext().setAttribute("com.acme.AnnotationTest.sclInjectWebListenerTest", Boolean.valueOf(maxAmount != null)); + } + + public void requestCompleted(ServletRequestEvent rre) + { + // TODO Auto-generated method stub + } @Override @@ -116,22 +127,16 @@ public void requestInitialized(ServletRequestEvent sre) // System.err.println("requestInitialized "+sre); } - @Override - public void attributeAdded(ServletRequestAttributeEvent srae) + public void requestResumed(ServletRequestEvent rre) { - // System.err.println("attributeAdded "+srae); - } + // TODO Auto-generated method stub - @Override - public void attributeRemoved(ServletRequestAttributeEvent srae) - { - // System.err.println("attributeRemoved "+srae); } - @Override - public void attributeReplaced(ServletRequestAttributeEvent srae) + public void requestSuspended(ServletRequestEvent rre) { - // System.err.println("attributeReplaced "+srae); + // TODO Auto-generated method stub + } @Override @@ -146,21 +151,15 @@ 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) + @Override + public void sessionDidActivate(HttpSessionEvent se) { - // TODO Auto-generated method stub - + // System.err.println("sessionDidActivate "+se); } - public void requestSuspended(ServletRequestEvent rre) + @Override + public void sessionWillPassivate(HttpSessionEvent se) { - // TODO Auto-generated method stub - + // System.err.println("sessionWillPassivate "+se); } } diff --git a/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/ClassLoaderServlet.java b/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/ClassLoaderServlet.java index 7c36e6f6d26c..c467fac2708b 100644 --- a/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/ClassLoaderServlet.java +++ b/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/ClassLoaderServlet.java @@ -117,9 +117,9 @@ public static URI getJarSource(URI uri) return uri; // Get SSP (retaining encoded form) String s = uri.getRawSchemeSpecificPart(); - int bang_slash = s.indexOf("!/"); - if (bang_slash >= 0) - s = s.substring(0, bang_slash); + int bangSlash = s.indexOf("!/"); + if (bangSlash >= 0) + s = s.substring(0, bangSlash); return new URI(s); } catch (URISyntaxException e) diff --git a/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/TestListener.java b/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/TestListener.java index 6907c3a74a92..659f90492981 100644 --- a/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/TestListener.java +++ b/tests/test-webapps/test-servlet-spec/test-spec-webapp/src/main/java/com/acme/test/TestListener.java @@ -40,58 +40,43 @@ @WebListener public class TestListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener { - public static class NaughtyServletContextListener implements ServletContextListener - { - - @Override - public void contextInitialized(ServletContextEvent sce) - { - throw new IllegalStateException("Should not call NaughtServletContextListener.contextInitialized"); - } + @Resource(mappedName = "maxAmount") + private Double maxAmount; - @Override - public void contextDestroyed(ServletContextEvent sce) - { - throw new IllegalStateException("Should not call NaughtServletContextListener.contextDestroyed"); - } + @Override + public void attributeAdded(HttpSessionBindingEvent se) + { + // System.err.println("attributedAdded "+se); } - public static class InvalidListener implements EventListener + @Override + public void attributeAdded(ServletContextAttributeEvent scab) { - public InvalidListener() - { - } + // System.err.println("attributeAdded "+scab); } - public static class ValidListener implements HttpSessionIdListener + @Override + public void attributeAdded(ServletRequestAttributeEvent srae) { - @Resource(mappedName = "maxAmount") - private Double maxAmount; - - public ValidListener() - { - } - - @Override - public void sessionIdChanged(HttpSessionEvent event, String oldSessionId) - { - - } + // System.err.println("attributeAdded "+srae); } - @Resource(mappedName = "maxAmount") - private Double maxAmount; + @Override + public void attributeRemoved(HttpSessionBindingEvent se) + { + // System.err.println("attributeRemoved "+se); + } @Override - public void attributeAdded(HttpSessionBindingEvent se) + public void attributeRemoved(ServletContextAttributeEvent scab) { - // System.err.println("attributedAdded "+se); + // System.err.println("attributeRemoved "+scab); } @Override - public void attributeRemoved(HttpSessionBindingEvent se) + public void attributeRemoved(ServletRequestAttributeEvent srae) { - // System.err.println("attributeRemoved "+se); + // System.err.println("attributeRemoved "+srae); } @Override @@ -101,15 +86,21 @@ public void attributeReplaced(HttpSessionBindingEvent se) } @Override - public void sessionWillPassivate(HttpSessionEvent se) + public void attributeReplaced(ServletContextAttributeEvent scab) { - // System.err.println("sessionWillPassivate "+se); + // System.err.println("attributeReplaced "+scab); } @Override - public void sessionDidActivate(HttpSessionEvent se) + public void attributeReplaced(ServletRequestAttributeEvent srae) { - // System.err.println("sessionDidActivate "+se); + // System.err.println("attributeReplaced "+srae); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) + { + // System.err.println("contextDestroyed "+sce); } @Override @@ -162,28 +153,10 @@ public void contextInitialized(ServletContextEvent sce) } } - @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) + public void requestCompleted(ServletRequestEvent rre) { - // System.err.println("attributeRemoved "+scab); - } + // TODO Auto-generated method stub - @Override - public void attributeReplaced(ServletContextAttributeEvent scab) - { - // System.err.println("attributeReplaced "+scab); } @Override @@ -198,22 +171,16 @@ public void requestInitialized(ServletRequestEvent sre) // System.err.println("requestInitialized "+sre); } - @Override - public void attributeAdded(ServletRequestAttributeEvent srae) + public void requestResumed(ServletRequestEvent rre) { - // System.err.println("attributeAdded "+srae); - } + // TODO Auto-generated method stub - @Override - public void attributeRemoved(ServletRequestAttributeEvent srae) - { - // System.err.println("attributeRemoved "+srae); } - @Override - public void attributeReplaced(ServletRequestAttributeEvent srae) + public void requestSuspended(ServletRequestEvent rre) { - // System.err.println("attributeReplaced "+srae); + // TODO Auto-generated method stub + } @Override @@ -228,21 +195,54 @@ public void sessionDestroyed(HttpSessionEvent se) // System.err.println("sessionDestroyed "+se); } - public void requestCompleted(ServletRequestEvent rre) + @Override + public void sessionDidActivate(HttpSessionEvent se) { - // TODO Auto-generated method stub + // System.err.println("sessionDidActivate "+se); + } + @Override + public void sessionWillPassivate(HttpSessionEvent se) + { + // System.err.println("sessionWillPassivate "+se); } - public void requestResumed(ServletRequestEvent rre) + public static class NaughtyServletContextListener implements ServletContextListener { - // TODO Auto-generated method stub + @Override + public void contextDestroyed(ServletContextEvent sce) + { + throw new IllegalStateException("Should not call NaughtServletContextListener.contextDestroyed"); + } + + @Override + public void contextInitialized(ServletContextEvent sce) + { + throw new IllegalStateException("Should not call NaughtServletContextListener.contextInitialized"); + } } - public void requestSuspended(ServletRequestEvent rre) + public static class InvalidListener implements EventListener { - // TODO Auto-generated method stub + public InvalidListener() + { + } + } + + public static class ValidListener implements HttpSessionIdListener + { + @Resource(mappedName = "maxAmount") + private Double maxAmount; + public ValidListener() + { + } + + @Override + public void sessionIdChanged(HttpSessionEvent event, String oldSessionId) + { + + } } }