Resolve feedback

Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
This commit is contained in:
Tran Ngoc Nhan 2025-10-21 19:35:05 +07:00 committed by Josh Cummings
parent deb6416c93
commit 17933ddab3
5 changed files with 21 additions and 27 deletions

View File

@ -72,13 +72,13 @@ final class DefaultServiceAuthenticationDetails extends WebAuthenticationDetails
@Override
public boolean equals(Object obj) {
if (super.equals(obj)) {
if (this == obj) {
return true;
}
if (obj instanceof DefaultServiceAuthenticationDetails that) {
return this.serviceUrl.equals(that.getServiceUrl());
if (!(obj instanceof DefaultServiceAuthenticationDetails that)) {
return false;
}
return false;
return this.serviceUrl.equals(that.getServiceUrl());
}
@Override
@ -111,7 +111,10 @@ final class DefaultServiceAuthenticationDetails extends WebAuthenticationDetails
*/
private @Nullable String getQueryString(final HttpServletRequest request, final Pattern artifactPattern) {
final String query = request.getQueryString();
String result = (query != null) ? artifactPattern.matcher(query).replaceFirst("") : "";
if (query == null) {
return null;
}
String result = artifactPattern.matcher(query).replaceFirst("");
if (result.isEmpty()) {
return null;
}

View File

@ -210,8 +210,8 @@ public abstract class SecurityExpressionRoot<T extends @Nullable Object> impleme
/**
* Convenience method to access {@link Authentication#getPrincipal()} from
* {@link #getAuthentication()}
* @return the <code>Principal</code> being authenticated or the authenticated
* principal after authentication.
* @return the {@code Principal} being authenticated or the authenticated principal
* after authentication.
*/
public @Nullable Object getPrincipal() {
return getAuthentication().getPrincipal();

View File

@ -21,7 +21,11 @@ import org.jspecify.annotations.Nullable;
import org.springframework.util.StringUtils;
/**
* Implementation of PasswordEncoder.
* An abstract {@link PasswordEncoder} that implementers can use for expecting the
* password to be non-{@code null}. Each common password API method is accompanied with an
* abstract method with a {@code NonNull} prefix. By implementing this, the concrete class
* is specifying what to do with the password when it is non-{@code null}, allowing this
* class to handle the {@code null} case.
*
* @author Rob Winch
* @since 7.0
@ -50,10 +54,10 @@ public abstract class AbstractValidatingPasswordEncoder implements PasswordEncod
@Override
public final boolean upgradeEncoding(@Nullable String encodedPassword) {
if (StringUtils.hasLength(encodedPassword)) {
return upgradeEncodingNonNull(encodedPassword);
if (!StringUtils.hasLength(encodedPassword)) {
return false;
}
return false;
return upgradeEncodingNonNull(encodedPassword);
}
protected boolean upgradeEncodingNonNull(String encodedPassword) {

View File

@ -25,6 +25,7 @@ import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable;
import org.springframework.util.StringUtils;
/**
* Request wrapper which ensures values of {@code servletPath} and {@code pathInfo} are
@ -58,7 +59,7 @@ final class RequestWrapper extends FirewalledRequest {
super(request);
this.strippedServletPath = strip(request.getServletPath());
String pathInfo = strip(request.getPathInfo());
if (pathInfo != null && pathInfo.isEmpty()) {
if (!StringUtils.hasLength(pathInfo)) {
pathInfo = null;
}
this.strippedPathInfo = pathInfo;

View File

@ -102,7 +102,7 @@ public class DefaultSavedRequest implements SavedRequest {
private final @Nullable String matchingRequestParameterName;
public DefaultSavedRequest(HttpServletRequest request) {
this(request, (String) null);
this(request, null);
}
public DefaultSavedRequest(HttpServletRequest request, @Nullable String matchingRequestParameterName) {
@ -208,10 +208,6 @@ public class DefaultSavedRequest implements SavedRequest {
}
}
private void addParameter(String name, String[] values) {
this.parameters.put(name, values);
}
public @Nullable String getContextPath() {
return this.contextPath;
}
@ -303,16 +299,6 @@ public class DefaultSavedRequest implements SavedRequest {
return this.servletPath;
}
private boolean propertyEquals(@Nullable Object arg1, Object arg2) {
if ((arg1 == null) && (arg2 == null)) {
return true;
}
if (arg1 == null || arg2 == null) {
return false;
}
return arg1.equals(arg2);
}
@Override
public String toString() {
return "DefaultSavedRequest [" + getRedirectUrl() + "]";