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 514c3070853..bafdde2dd8b 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 @@ -47,7 +47,7 @@ public class ServletPathSpec extends PathSpec assertValidServletPathSpec(servletPathSpec); // The Root Path Spec - if (servletPathSpec.length() == 0) + if (servletPathSpec.isEmpty()) { super.pathSpec = ""; super.pathDepth = -1; // force this to be at the end of the sort order diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java index c2263af8ff4..2ad2005ec2d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java @@ -725,7 +725,7 @@ public class SessionHandler extends ScopedHandler if (isUsingCookies()) { String sessionPath = (_cookieConfig.getPath()==null) ? contextPath : _cookieConfig.getPath(); - sessionPath = (sessionPath==null||sessionPath.length()==0) ? "/" : sessionPath; + sessionPath = (sessionPath==null|| sessionPath.isEmpty()) ? "/" : sessionPath; String id = getExtendedId(session); HttpCookie cookie = null; if (_sessionComment == null) diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java index d5c2b1917a4..5607b0f7e99 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java @@ -628,7 +628,7 @@ public class ServletHandler extends ScopedHandler FilterChain chain = null; if (_filterChainsCached) { - if (filters.size() > 0) + if (!filters.isEmpty()) chain = newCachedChain(filters, servletHolder); final Map cache=_chainCache[dispatch]; @@ -652,7 +652,7 @@ public class ServletHandler extends ScopedHandler cache.put(key,chain); lru.add(key); } - else if (filters.size() > 0) + else if (!filters.isEmpty()) chain = new Chain(baseRequest,filters, servletHolder); return chain; @@ -1567,7 +1567,7 @@ public class ServletHandler extends ScopedHandler */ protected CachedChain(List filters, ServletHolder servletHolder) { - if (filters.size()>0) + if (!filters.isEmpty()) { _filterHolder=filters.get(0); filters.remove(0); diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java index 6bbd176b0d1..fbd5ad8c1bf 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java @@ -184,8 +184,8 @@ public class PushCacheFilter implements Filter port = request.isSecure() ? 443 : 80; } - boolean referredFromHere = _hosts.size() > 0 ? _hosts.contains(host) : host.equals(request.getServerName()); - referredFromHere &= _ports.size() > 0 ? _ports.contains(port) : port == request.getServerPort(); + boolean referredFromHere = !_hosts.isEmpty()? _hosts.contains(host) : host.equals(request.getServerName()); + referredFromHere &= !_ports.isEmpty()? _ports.contains(port) : port == request.getServerPort(); if (referredFromHere) { diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index a074efd5123..102da4225ae 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -865,7 +865,7 @@ public class StartArgs public boolean hasJvmArgs() { - return jvmArgs.size() > 0; + return !jvmArgs.isEmpty(); } public boolean hasSystemProperties() 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 c331ac7a3e2..d0fde189369 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 @@ -249,7 +249,7 @@ public class JSON try { buffer.append('"'); - if (input != null && input.length() > 0) + if (input != null && !input.isEmpty()) { escapeString(buffer, input); } 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 75015ac0e10..b38334fd0ff 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 @@ -1025,10 +1025,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL throws Exception { //if the configuration instances have been set explicitly, use them - if (_configurations.size()>0) + if (!_configurations.isEmpty()) return; - if (_configurationClasses.size()==0) { + if (_configurationClasses.isEmpty()) { _configurationClasses.addAll(Configuration.ClassList.serverDefault(getServer())); } for (String configClass : _configurationClasses) diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/ChatServlet.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/ChatServlet.java index ca99ec2efad..3c13db08a15 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/ChatServlet.java +++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/ChatServlet.java @@ -133,7 +133,7 @@ public class ChatServlet extends HttpServlet synchronized (member) { LOG.debug("Queue size: {}", member._queue.size()); - if (member._queue.size() > 0) + if (!member._queue.isEmpty()) { sendSingleMessage(response, member); }