Perform NullAway build-time checks in spring-webmvc
See gh-32475
This commit is contained in:
parent
cf8810042a
commit
0e7aba4179
|
@ -118,7 +118,7 @@ tasks.withType(JavaCompile).configureEach {
|
|||
disableAllChecks = true
|
||||
option("NullAway:CustomContractAnnotations", "org.springframework.lang.Contract")
|
||||
option("NullAway:AnnotatedPackages", "org.springframework.core,org.springframework.expression," +
|
||||
"org.springframework.web.reactive")
|
||||
"org.springframework.web.reactive,org.springframework.web.servlet")
|
||||
option("NullAway:UnannotatedSubPackages", "org.springframework.instrument,org.springframework.context.index," +
|
||||
"org.springframework.asm,org.springframework.cglib,org.springframework.objenesis," +
|
||||
"org.springframework.javapoet,org.springframework.aot.nativex.substitution")
|
||||
|
|
|
@ -64,6 +64,7 @@ public class ResourceChainRegistration {
|
|||
this(cacheResources, (cacheResources ? new ConcurrentMapCache(DEFAULT_CACHE_NAME) : null));
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
public ResourceChainRegistration(boolean cacheResources, @Nullable Cache cache) {
|
||||
Assert.isTrue(!cacheResources || cache != null, "'cache' is required when cacheResources=true");
|
||||
if (cacheResources) {
|
||||
|
|
|
@ -442,6 +442,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
private void addMatchingMappings(Collection<T> mappings, List<Match> matches, HttpServletRequest request) {
|
||||
for (T mapping : mappings) {
|
||||
T match = getMatchingMapping(mapping, request);
|
||||
|
|
|
@ -186,6 +186,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
|||
* @since 5.3
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("NullAway")
|
||||
protected Object lookupHandler(
|
||||
RequestPath path, String lookupPath, HttpServletRequest request) throws Exception {
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ public class RequestMatchResult {
|
|||
* {@link PathMatcher#extractUriTemplateVariables}.
|
||||
* @return a map with URI template variables
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@SuppressWarnings({"ConstantConditions", "NullAway"})
|
||||
public Map<String, String> extractUriTemplateVariables() {
|
||||
return (this.pathPattern != null ?
|
||||
this.pathPattern.matchAndExtract(this.lookupPathContainer).getUriVariables() :
|
||||
|
|
|
@ -490,7 +490,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
|||
return this.hashCode;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@SuppressWarnings({"ConstantConditions", "NullAway"})
|
||||
private static int calculateHashCode(
|
||||
@Nullable PathPatternsRequestCondition pathPatterns, @Nullable PatternsRequestCondition patterns,
|
||||
RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers,
|
||||
|
|
|
@ -215,6 +215,7 @@ public class ServletInvocableHandlerMethod extends InvocableHandlerMethod {
|
|||
|
||||
private final MethodParameter returnType;
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
public ConcurrentResultHandlerMethod(@Nullable Object result, ConcurrentResultMethodParameter returnType) {
|
||||
super((Callable<Object>) () -> {
|
||||
if (result instanceof Exception exception) {
|
||||
|
|
|
@ -219,6 +219,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
|||
* @return the resolved public URL path, or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("NullAway")
|
||||
public final String getForLookupPath(String lookupPath) {
|
||||
// Clean duplicate slashes or pathWithinPattern won't match lookupPath
|
||||
String previous;
|
||||
|
|
|
@ -328,11 +328,11 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
|||
String url = getUrl();
|
||||
Assert.state(url != null, "'url' not set");
|
||||
|
||||
if (this.contextRelative && getUrl().startsWith("/")) {
|
||||
if (this.contextRelative && url.startsWith("/")) {
|
||||
// Do not apply context path to relative URLs.
|
||||
targetUrl.append(getContextPath(request));
|
||||
}
|
||||
targetUrl.append(getUrl());
|
||||
targetUrl.append(url);
|
||||
|
||||
String enc = this.encodingScheme;
|
||||
if (enc == null) {
|
||||
|
|
Loading…
Reference in New Issue