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
@@ -108,7 +108,7 @@ public class Jsr250MethodSecurityMetadataSource extends AbstractFallbackMethodSe
if (role == null) {
return role;
}
if (this.defaultRolePrefix == null || this.defaultRolePrefix.length() == 0) {
if (this.defaultRolePrefix == null || this.defaultRolePrefix.isEmpty()) {
return role;
}
if (role.startsWith(this.defaultRolePrefix)) {
@@ -111,7 +111,7 @@ final class DefaultServiceAuthenticationDetails extends WebAuthenticationDetails
return null;
}
String result = artifactPattern.matcher(query).replaceFirst("");
if (result.length() == 0) {
if (result.isEmpty()) {
return null;
}
// strip off the trailing & only if the artifact was the first query param
@@ -32,8 +32,7 @@ public abstract class AbstractValidatingPasswordEncoder implements PasswordEncod
@Override
public final boolean matches(@Nullable CharSequence rawPassword, @Nullable String encodedPassword) {
if (rawPassword == null || rawPassword.length() == 0 || encodedPassword == null
|| encodedPassword.length() == 0) {
if (rawPassword == null || rawPassword.isEmpty() || encodedPassword == null || encodedPassword.isEmpty()) {
return false;
}
return matchesNonNull(rawPassword.toString(), encodedPassword);
@@ -43,7 +42,7 @@ public abstract class AbstractValidatingPasswordEncoder implements PasswordEncod
@Override
public final boolean upgradeEncoding(@Nullable String encodedPassword) {
if (encodedPassword == null || encodedPassword.length() == 0) {
if (encodedPassword == null || encodedPassword.isEmpty()) {
return false;
}
return upgradeEncodingNonNull(encodedPassword);
@@ -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);