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