diff --git a/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java b/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java index d448b909366..fd2b9f63307 100644 --- a/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java +++ b/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java @@ -119,7 +119,7 @@ public class JettyJspServlet extends JspServlet */ private String addPaths(String servletPath, String pathInfo) { - if (servletPath.length()==0) + if (servletPath.isEmpty()) return pathInfo; if (pathInfo==null) 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 6db2d2af434..09e342fb2c3 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 @@ -79,7 +79,7 @@ public class ManyHandlers ServletException { Map params = request.getParameterMap(); - if (params.size() > 0) + if (!params.isEmpty()) { response.setContentType("text/plain"); response.getWriter().println(JSON.toString(params)); diff --git a/jetty-cdi/cdi-websocket/src/main/java/org/eclipse/jetty/cdi/websocket/WebSocketCdiListener.java b/jetty-cdi/cdi-websocket/src/main/java/org/eclipse/jetty/cdi/websocket/WebSocketCdiListener.java index 8e7544025d7..be7beb0f364 100644 --- a/jetty-cdi/cdi-websocket/src/main/java/org/eclipse/jetty/cdi/websocket/WebSocketCdiListener.java +++ b/jetty-cdi/cdi-websocket/src/main/java/org/eclipse/jetty/cdi/websocket/WebSocketCdiListener.java @@ -47,7 +47,7 @@ public class WebSocketCdiListener extends AbstractContainerListener ScopedInstance sbean = new ScopedInstance(); Set> beans = bm.getBeans(clazz,AnyLiteral.INSTANCE); - if (beans.size() > 0) + if (!beans.isEmpty()) { sbean.bean = beans.iterator().next(); sbean.creationalContext = bm.createCreationalContext(sbean.bean); diff --git a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java index 8e52bbeedd7..db67c560a8d 100644 --- a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java +++ b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java @@ -87,7 +87,7 @@ public class HttpChannelOverFCGI extends HttpChannel public void onRequest() { String uri = path; - if (query != null && query.length() > 0) + if (query != null && !query.isEmpty()) uri += "?" + query; // TODO https? onRequest(new MetaData.Request(method, HttpScheme.HTTP.asString(), hostPort, uri, HttpVersion.fromString(version), fields,Long.MIN_VALUE)); diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java index 12fdde7f412..0202e9310cd 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java @@ -100,7 +100,7 @@ public class HttpField { if (search==null) return _value==null; - if (search.length()==0) + if (search.isEmpty()) return false; if (_value==null) return false; diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 2abc4b6c431..13a807ce131 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -1013,7 +1013,7 @@ public class HttpParser else { List values = new QuotedCSV(_valueString).getValues(); - if (values.size()>0 && HttpHeaderValue.CHUNKED.is(values.get(values.size()-1))) + if (!values.isEmpty() && HttpHeaderValue.CHUNKED.is(values.get(values.size()-1))) { _endOfContent=EndOfContent.CHUNKED_CONTENT; _contentLength=-1; 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 9c43512d9cf..417f5600cde 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 @@ -554,7 +554,7 @@ public class HttpURI public String getHost() { // Return null for empty host to retain compatibility with java.net.URI - if (_host!=null && _host.length()==0) + if (_host!=null && _host.isEmpty()) return null; return _host; } @@ -599,7 +599,7 @@ public class HttpURI /* ------------------------------------------------------------ */ public boolean hasQuery() { - return _query!=null && _query.length()>0; + return _query!=null && !_query.isEmpty(); } /* ------------------------------------------------------------ */ @@ -653,7 +653,7 @@ public class HttpURI /* ------------------------------------------------------------ */ public boolean isAbsolute() { - return _scheme!=null && _scheme.length()>0; + return _scheme!=null && !_scheme.isEmpty(); } /* ------------------------------------------------------------ */ 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 6c0c4fb91a3..333163dd53f 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 @@ -223,7 +223,7 @@ public class MimeTypes .forEach(x-> __dftMimeMap.put(StringUtil.asciiToLowerCase(x), normalizeMimeType(props.getProperty(x)))); - if (__dftMimeMap.size()==0) + if (__dftMimeMap.isEmpty()) { LOG.warn("Empty mime types at {}", resourceName); } @@ -268,7 +268,7 @@ public class MimeTypes __inferredEncodings.put(t, props.getProperty(t)); }); - if (__inferredEncodings.size()==0) + if (__inferredEncodings.isEmpty()) { LOG.warn("Empty encodings at {}", resourceName); } 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 928f59c3c64..4147ab5cff4 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 @@ -107,7 +107,7 @@ public class MultiPartFormInputStream // We will either be writing to a file, if it has a filename on the content-disposition // and otherwise a byte-array-input-stream, OR if we exceed the getFileSizeThreshold, we // will need to change to write to a file. - if (isWriteFilesWithFilenames() && _filename != null && _filename.trim().length() > 0) + if (isWriteFilesWithFilenames() && _filename != null && !_filename.trim().isEmpty()) { createFile(); } @@ -365,7 +365,7 @@ public class MultiPartFormInputStream Collection> values = _parts.values(); for (List partList : values) { - if (partList.size() != 0) + if (!partList.isEmpty()) return false; } diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java b/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java index 11cf72b5e7a..c063478d03b 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java @@ -294,7 +294,7 @@ public class PathMap extends HashMap if (path==null) return entries; - if (path.length()==0) + if (path.isEmpty()) return _defaultSingletonList; // try exact match @@ -417,7 +417,7 @@ public class PathMap extends HashMap */ public static boolean match(String pathSpec, String path, boolean noDefault) { - if (pathSpec.length()==0) + if (pathSpec.isEmpty()) return "/".equals(path); char c = pathSpec.charAt(0); diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/CookieDump.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/CookieDump.java index f9c6d58ce89..48d79149dec 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/CookieDump.java +++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/CookieDump.java @@ -46,10 +46,10 @@ public class CookieDump extends HttpServlet String value = request.getParameter("Value"); String age = request.getParameter("Age"); - if (name!=null && name.length()>0) + if (name!=null && !name.isEmpty()) { Cookie cookie = new Cookie(name,value); - if (age!=null && age.length()>0) + if (age!=null && !age.isEmpty()) cookie.setMaxAge(Integer.parseInt(age)); response.addCookie(cookie); } diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/SessionDump.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/SessionDump.java index 3e9e7c15af8..9133b48ea78 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/SessionDump.java +++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/SessionDump.java @@ -91,7 +91,7 @@ public class SessionDump extends HttpServlet { if (action.equals("Invalidate")) session.invalidate(); - else if (action.equals("Set") && name!=null && name.length()>0) + else if (action.equals("Set") && name!=null && !name.isEmpty()) session.setAttribute(name,value); else if (action.equals("Remove")) session.removeAttribute(name);