Use Supplier variants of Assert methods
This commit is contained in:
committed by
Rob Winch
parent
7d4e7bf42d
commit
d07cfe655d
+1
-1
@@ -92,7 +92,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager,
|
||||
|
||||
for (Object currentObject : newList) {
|
||||
Assert.isInstanceOf(ChannelProcessor.class, currentObject,
|
||||
"ChannelProcessor " + currentObject.getClass().getName()
|
||||
() -> "ChannelProcessor " + currentObject.getClass().getName()
|
||||
+ " must implement ChannelProcessor");
|
||||
channelProcessors.add((ChannelProcessor) currentObject);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,7 +67,7 @@ public final class ExpressionBasedFilterInvocationSecurityMetadataSource
|
||||
.entrySet()) {
|
||||
RequestMatcher request = entry.getKey();
|
||||
Assert.isTrue(entry.getValue().size() == 1,
|
||||
"Expected a single expression attribute for " + request);
|
||||
() -> "Expected a single expression attribute for " + request);
|
||||
ArrayList<ConfigAttribute> attributes = new ArrayList<>(1);
|
||||
String expression = entry.getValue().toArray(new ConfigAttribute[1])[0]
|
||||
.getAttribute();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,7 +76,7 @@ public class ExceptionMappingAuthenticationFailureHandler extends
|
||||
"Exception key must be a String (the exception classname).");
|
||||
Assert.isInstanceOf(String.class, url, "URL must be a String");
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl((String) url),
|
||||
"Not a valid redirect URL: " + url);
|
||||
() -> "Not a valid redirect URL: " + url);
|
||||
this.failureUrlMap.put((String) exception, (String) url);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,8 +41,8 @@ public class ForwardAuthenticationFailureHandler implements AuthenticationFailur
|
||||
* @param forwardUrl
|
||||
*/
|
||||
public ForwardAuthenticationFailureHandler(String forwardUrl) {
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(forwardUrl), "'"
|
||||
+ forwardUrl + "' is not a valid forward URL");
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(forwardUrl),
|
||||
() -> "'" + forwardUrl + "' is not a valid forward URL");
|
||||
this.forwardUrl = forwardUrl;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,8 +41,8 @@ public class ForwardAuthenticationSuccessHandler implements AuthenticationSucces
|
||||
* @param forwardUrl
|
||||
*/
|
||||
public ForwardAuthenticationSuccessHandler(String forwardUrl) {
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(forwardUrl), "'"
|
||||
+ forwardUrl + "' is not a valid forward URL");
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(forwardUrl),
|
||||
() -> "'" + forwardUrl + "' is not a valid forward URL");
|
||||
this.forwardUrl = forwardUrl;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -123,8 +123,8 @@ public class SimpleUrlAuthenticationFailureHandler implements
|
||||
* @param defaultFailureUrl the failure URL, for example "/loginFailed.jsp".
|
||||
*/
|
||||
public void setDefaultFailureUrl(String defaultFailureUrl) {
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl), "'"
|
||||
+ defaultFailureUrl + "' is not a valid redirect URL");
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl),
|
||||
() -> "'" + defaultFailureUrl + "' is not a valid redirect URL");
|
||||
this.defaultFailureUrl = defaultFailureUrl;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,8 +42,8 @@ public class ForwardLogoutSuccessHandler implements LogoutSuccessHandler {
|
||||
* @param targetUrl the target URL
|
||||
*/
|
||||
public ForwardLogoutSuccessHandler(String targetUrl) {
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(targetUrl), "'" + targetUrl
|
||||
+ "' is not a valid target URL");
|
||||
Assert.isTrue(UrlUtils.isValidRedirectUrl(targetUrl),
|
||||
() -> "'" + targetUrl + "' is not a valid target URL");
|
||||
this.targetUrl = targetUrl;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class LogoutFilter extends GenericFilterBean {
|
||||
Assert.isTrue(
|
||||
!StringUtils.hasLength(logoutSuccessUrl)
|
||||
|| UrlUtils.isValidRedirectUrl(logoutSuccessUrl),
|
||||
logoutSuccessUrl + " isn't a valid redirect URL");
|
||||
() -> logoutSuccessUrl + " isn't a valid redirect URL");
|
||||
SimpleUrlLogoutSuccessHandler urlLogoutSuccessHandler = new SimpleUrlLogoutSuccessHandler();
|
||||
if (StringUtils.hasText(logoutSuccessUrl)) {
|
||||
urlLogoutSuccessHandler.setDefaultTargetUrl(logoutSuccessUrl);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,7 @@ public class MatcherSecurityWebFilterChain implements SecurityWebFilterChain {
|
||||
|
||||
public MatcherSecurityWebFilterChain(ServerWebExchangeMatcher matcher, List<WebFilter> filters) {
|
||||
Assert.notNull(matcher, "matcher cannot be null");
|
||||
Assert.notEmpty(filters, "filters cannot be null or empty. Got " + filters);
|
||||
Assert.notEmpty(filters, () -> "filters cannot be null or empty. Got " + filters);
|
||||
this.matcher = matcher;
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ public class ConcurrentSessionFilter extends GenericFilterBean {
|
||||
public ConcurrentSessionFilter(SessionRegistry sessionRegistry, String expiredUrl) {
|
||||
Assert.notNull(sessionRegistry, "SessionRegistry required");
|
||||
Assert.isTrue(expiredUrl == null || UrlUtils.isValidRedirectUrl(expiredUrl),
|
||||
expiredUrl + " isn't a valid redirect URL");
|
||||
() -> expiredUrl + " isn't a valid redirect URL");
|
||||
this.expiredUrl = expiredUrl;
|
||||
this.sessionRegistry = sessionRegistry;
|
||||
this.sessionInformationExpiredStrategy = new SessionInformationExpiredStrategy() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -371,8 +371,8 @@ public class ResolvableMethod {
|
||||
*/
|
||||
public ResolvableMethod build() {
|
||||
Set<Method> methods = MethodIntrospector.selectMethods(this.objectClass, this::isMatch);
|
||||
Assert.state(!methods.isEmpty(), "No matching method: " + this);
|
||||
Assert.state(methods.size() == 1, "Multiple matching methods: " + this + formatMethods(methods));
|
||||
Assert.state(!methods.isEmpty(), () -> "No matching method: " + this);
|
||||
Assert.state(methods.size() == 1, () -> "Multiple matching methods: " + this + formatMethods(methods));
|
||||
return new ResolvableMethod(methods.iterator().next());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user