diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpConnection.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpConnection.java index 17dee5cab017..38723867bb2e 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpConnection.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpConnection.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.io.CyclicTimeouts; import org.eclipse.jetty.util.Attachable; import org.eclipse.jetty.util.NanoTime; +import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.thread.AutoLock; import org.eclipse.jetty.util.thread.Scheduler; import org.slf4j.Logger; @@ -145,7 +146,7 @@ protected void normalizeRequest(HttpRequest request) // Make sure the path is there String path = request.getPath(); - if (path.trim().isEmpty()) + if (StringUtil.isBlank(path)) { path = "/"; request.path(path); diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java index 7d30336279e4..393500f4001c 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java @@ -657,21 +657,7 @@ public static int indexOfControlChars(String str) */ public static boolean isBlank(String str) { - if (str == null) - { - return true; - } - int len = str.length(); - for (int i = 0; i < len; i++) - { - if (!Character.isWhitespace(str.codePointAt(i))) - { - // found a non-whitespace, we can stop searching now - return false; - } - } - // only whitespace - return true; + return str == null || str.isBlank(); } /** @@ -727,21 +713,7 @@ public static int getLength(String s) */ public static boolean isNotBlank(String str) { - if (str == null) - { - return false; - } - int len = str.length(); - for (int i = 0; i < len; i++) - { - if (!Character.isWhitespace(str.codePointAt(i))) - { - // found a non-whitespace, we can stop searching now - return true; - } - } - // only whitespace - return false; + return !isBlank(str); } public static boolean isHex(String str, int offset, int length)