Use Assert.state() where appropriate
This commit is contained in:
@@ -374,7 +374,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
||||
@Override
|
||||
@Nullable
|
||||
public RequestMatchResult match(HttpServletRequest request, String pattern) {
|
||||
Assert.isNull(getPatternParser(), "This HandlerMapping uses PathPatterns.");
|
||||
Assert.state(getPatternParser() == null, "This HandlerMapping uses PathPatterns.");
|
||||
String lookupPath = UrlPathHelper.getResolvedLookupPath(request);
|
||||
if (getPathMatcher().match(pattern, lookupPath)) {
|
||||
return new RequestMatchResult(pattern, lookupPath, getPathMatcher());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -158,7 +158,7 @@ public class HandlerMappingIntrospector
|
||||
HttpServletRequest request, boolean ignoreException,
|
||||
BiFunction<HandlerMapping, HandlerExecutionChain, T> matchHandler) throws Exception {
|
||||
|
||||
Assert.notNull(this.handlerMappings, "Handler mappings not initialized");
|
||||
Assert.state(this.handlerMappings != null, "Handler mappings not initialized");
|
||||
|
||||
boolean parseRequestPath = !this.pathPatternHandlerMappings.isEmpty();
|
||||
RequestPath previousPath = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -59,7 +59,7 @@ class PathPatternMatchableHandlerMapping implements MatchableHandlerMapping {
|
||||
@Override
|
||||
public RequestMatchResult match(HttpServletRequest request, String pattern) {
|
||||
PathPattern pathPattern = this.pathPatternCache.computeIfAbsent(pattern, value -> {
|
||||
Assert.isTrue(this.pathPatternCache.size() < MAX_PATTERNS, "Max size for pattern cache exceeded.");
|
||||
Assert.state(this.pathPatternCache.size() < MAX_PATTERNS, "Max size for pattern cache exceeded.");
|
||||
return this.parser.parse(pattern);
|
||||
});
|
||||
PathContainer path = ServletRequestPathUtils.getParsedRequestPath(request).pathWithinApplication();
|
||||
|
||||
@@ -448,7 +448,7 @@ public class MvcUriComponentsBuilder {
|
||||
*/
|
||||
public static MethodArgumentBuilder fromMappingName(@Nullable UriComponentsBuilder builder, String name) {
|
||||
WebApplicationContext wac = getWebApplicationContext();
|
||||
Assert.notNull(wac, "No WebApplicationContext");
|
||||
Assert.state(wac != null, "No WebApplicationContext");
|
||||
Map<String, RequestMappingInfoHandlerMapping> map = wac.getBeansOfType(RequestMappingInfoHandlerMapping.class);
|
||||
List<HandlerMethod> handlerMethods = null;
|
||||
for (RequestMappingInfoHandlerMapping mapping : map.values()) {
|
||||
|
||||
@@ -454,7 +454,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
|
||||
|
||||
@Override
|
||||
public RequestMatchResult match(HttpServletRequest request, String pattern) {
|
||||
Assert.isNull(getPatternParser(), "This HandlerMapping requires a PathPattern");
|
||||
Assert.state(getPatternParser() == null, "This HandlerMapping uses PathPatterns.");
|
||||
RequestMappingInfo info = RequestMappingInfo.paths(pattern).options(this.config).build();
|
||||
RequestMappingInfo match = info.getMatchingCondition(request);
|
||||
return (match != null && match.getPatternsCondition() != null ?
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -625,8 +625,8 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||
return null;
|
||||
}
|
||||
|
||||
Assert.notNull(this.resolverChain, "ResourceResolverChain not initialized.");
|
||||
Assert.notNull(this.transformerChain, "ResourceTransformerChain not initialized.");
|
||||
Assert.state(this.resolverChain != null, "ResourceResolverChain not initialized.");
|
||||
Assert.state(this.transformerChain != null, "ResourceTransformerChain not initialized.");
|
||||
|
||||
Resource resource = this.resolverChain.resolveResource(request, path, getLocations());
|
||||
if (resource != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.core.Conventions;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.AbstractContextLoaderInitializer;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
@@ -77,13 +78,13 @@ public abstract class AbstractDispatcherServletInitializer extends AbstractConte
|
||||
*/
|
||||
protected void registerDispatcherServlet(ServletContext servletContext) {
|
||||
String servletName = getServletName();
|
||||
Assert.hasLength(servletName, "getServletName() must not return null or empty");
|
||||
Assert.state(StringUtils.hasLength(servletName), "getServletName() must not return null or empty");
|
||||
|
||||
WebApplicationContext servletAppContext = createServletApplicationContext();
|
||||
Assert.notNull(servletAppContext, "createServletApplicationContext() must not return null");
|
||||
Assert.state(servletAppContext != null, "createServletApplicationContext() must not return null");
|
||||
|
||||
FrameworkServlet dispatcherServlet = createDispatcherServlet(servletAppContext);
|
||||
Assert.notNull(dispatcherServlet, "createDispatcherServlet(WebApplicationContext) must not return null");
|
||||
Assert.state(dispatcherServlet != null, "createDispatcherServlet(WebApplicationContext) must not return null");
|
||||
dispatcherServlet.setContextInitializers(getServletApplicationContextInitializers());
|
||||
|
||||
ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, dispatcherServlet);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -97,7 +97,7 @@ public class MarshallingView extends AbstractView {
|
||||
|
||||
@Override
|
||||
protected void initApplicationContext() {
|
||||
Assert.notNull(this.marshaller, "Property 'marshaller' is required");
|
||||
Assert.state(this.marshaller != null, "Property 'marshaller' is required");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user