1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Use String#isEmpty

Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
This commit is contained in:
Tran Ngoc Nhan
2025-08-24 13:00:09 +07:00
committed by Josh Cummings
parent 6fcca39500
commit 21bef947b0
8 changed files with 10 additions and 11 deletions
@@ -130,7 +130,7 @@ public abstract class AbstractRememberMeServices
return null;
}
this.logger.debug("Remember-me cookie detected");
if (rememberMeCookie.length() == 0) {
if (rememberMeCookie.isEmpty()) {
this.logger.debug("Cookie was empty");
cancelCookie(request, response);
return null;
@@ -383,7 +383,7 @@ public abstract class AbstractRememberMeServices
private String getCookiePath(HttpServletRequest request) {
String contextPath = request.getContextPath();
return (contextPath.length() > 0) ? contextPath : "/";
return contextPath.isEmpty() ? "/" : contextPath;
}
/**
@@ -57,7 +57,7 @@ final class RequestWrapper extends FirewalledRequest {
super(request);
this.strippedServletPath = strip(request.getServletPath());
String pathInfo = strip(request.getPathInfo());
if (pathInfo != null && pathInfo.length() == 0) {
if (pathInfo != null && pathInfo.isEmpty()) {
pathInfo = null;
}
this.strippedPathInfo = pathInfo;
@@ -321,7 +321,7 @@ public class DefaultSavedRequest implements SavedRequest {
if (matchingRequestParameterName == null) {
return queryString;
}
if (queryString == null || queryString.length() == 0) {
if (queryString == null || queryString.isEmpty()) {
return matchingRequestParameterName;
}
return UriComponentsBuilder.newInstance()
@@ -25,7 +25,7 @@ package org.springframework.security.web.util;
public abstract class TextEscapeUtils {
public static String escapeEntities(String s) {
if (s == null || s.length() == 0) {
if (s == null || s.isEmpty()) {
return s;
}
StringBuilder sb = new StringBuilder();
@@ -73,7 +73,7 @@ public class RequestWrapperTests {
String path = entry.getKey();
String expectedResult = entry.getValue();
// Should be null when stripped value is empty
if (expectedResult.length() == 0) {
if (expectedResult.isEmpty()) {
expectedResult = null;
}
request.setPathInfo(path);