Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720 Issue: SPR-15792
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.reactive;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -67,11 +68,11 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(DispatcherHandler.class);
|
||||
|
||||
private List<HandlerMapping> handlerMappings;
|
||||
private List<HandlerMapping> handlerMappings = Collections.emptyList();
|
||||
|
||||
private List<HandlerAdapter> handlerAdapters;
|
||||
private List<HandlerAdapter> handlerAdapters = Collections.emptyList();
|
||||
|
||||
private List<HandlerResultHandler> resultHandlers;
|
||||
private List<HandlerResultHandler> resultHandlers = Collections.emptyList();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,10 +27,13 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class PathMatchConfigurer {
|
||||
|
||||
@Nullable
|
||||
private Boolean trailingSlashMatch;
|
||||
|
||||
@Nullable
|
||||
private Boolean caseSensitiveMatch;
|
||||
|
||||
|
||||
/**
|
||||
* Whether to match to URLs irrespective of their case.
|
||||
* If enabled a method mapped to "/users" won't match to "/Users/".
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.function.Consumer;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.HttpMessageWriter;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.reactive.result.view.ViewResolver;
|
||||
import org.springframework.web.server.WebExceptionHandler;
|
||||
@@ -48,6 +49,7 @@ class DefaultHandlerStrategiesBuilder implements HandlerStrategies.Builder {
|
||||
|
||||
private final List<WebExceptionHandler> exceptionHandlers = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
private LocaleContextResolver localeContextResolver;
|
||||
|
||||
|
||||
@@ -55,10 +57,11 @@ class DefaultHandlerStrategiesBuilder implements HandlerStrategies.Builder {
|
||||
this.codecConfigurer.registerDefaults(false);
|
||||
}
|
||||
|
||||
|
||||
public void defaultConfiguration() {
|
||||
this.codecConfigurer.registerDefaults(true);
|
||||
exceptionHandler(new ResponseStatusExceptionHandler());
|
||||
localeContextResolver(new AcceptHeaderLocaleContextResolver());
|
||||
this.exceptionHandlers.add(new ResponseStatusExceptionHandler());
|
||||
this.localeContextResolver = new AcceptHeaderLocaleContextResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,16 +119,16 @@ class DefaultHandlerStrategiesBuilder implements HandlerStrategies.Builder {
|
||||
|
||||
private final List<WebExceptionHandler> exceptionHandlers;
|
||||
|
||||
@Nullable
|
||||
private final LocaleContextResolver localeContextResolver;
|
||||
|
||||
|
||||
public DefaultHandlerStrategies(
|
||||
List<HttpMessageReader<?>> messageReaders,
|
||||
List<HttpMessageWriter<?>> messageWriters,
|
||||
List<ViewResolver> viewResolvers,
|
||||
List<WebFilter> webFilters,
|
||||
List<WebExceptionHandler> exceptionHandlers,
|
||||
LocaleContextResolver localeContextResolver) {
|
||||
@Nullable LocaleContextResolver localeContextResolver) {
|
||||
|
||||
this.messageReaders = unmodifiableCopy(messageReaders);
|
||||
this.messageWriters = unmodifiableCopy(messageWriters);
|
||||
|
||||
@@ -73,8 +73,8 @@ public class PathResourceResolver extends AbstractResourceResolver {
|
||||
|
||||
|
||||
@Override
|
||||
protected Mono<Resource> resolveResourceInternal(ServerWebExchange exchange, String requestPath,
|
||||
List<? extends Resource> locations, ResourceResolverChain chain) {
|
||||
protected Mono<Resource> resolveResourceInternal(@Nullable ServerWebExchange exchange,
|
||||
String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) {
|
||||
|
||||
return getResource(requestPath, locations);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -17,10 +17,11 @@
|
||||
package org.springframework.web.reactive.result.view.script;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptEngine;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* An implementation of the Spring WebFlux {@link ScriptTemplateConfig} for
|
||||
* creating a {@code ScriptEngine} for use in a web application.
|
||||
@@ -48,20 +49,28 @@ import javax.script.ScriptEngine;
|
||||
*/
|
||||
public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
|
||||
@Nullable
|
||||
private ScriptEngine engine;
|
||||
|
||||
@Nullable
|
||||
private String engineName;
|
||||
|
||||
@Nullable
|
||||
private Boolean sharedEngine;
|
||||
|
||||
@Nullable
|
||||
private String[] scripts;
|
||||
|
||||
@Nullable
|
||||
private String renderObject;
|
||||
|
||||
@Nullable
|
||||
private String renderFunction;
|
||||
|
||||
@Nullable
|
||||
private Charset charset;
|
||||
|
||||
@Nullable
|
||||
private String resourceLoaderPath;
|
||||
|
||||
|
||||
@@ -88,11 +97,12 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* one (since it implies multiple lazy instantiations of the script engine).
|
||||
* @see #setEngineName(String)
|
||||
*/
|
||||
public void setEngine(ScriptEngine engine) {
|
||||
public void setEngine(@Nullable ScriptEngine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ScriptEngine getEngine() {
|
||||
return this.engine;
|
||||
}
|
||||
@@ -103,11 +113,12 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* You must define {@code engine} or {@code engineName}, not both.
|
||||
* @see #setEngine(ScriptEngine)
|
||||
*/
|
||||
public void setEngineName(String engineName) {
|
||||
public void setEngineName(@Nullable String engineName) {
|
||||
this.engineName = engineName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getEngineName() {
|
||||
return this.engineName;
|
||||
}
|
||||
@@ -124,11 +135,12 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* each request.
|
||||
* @see <a href="http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngineFactory.html#getParameter-java.lang.String-">THREADING ScriptEngine parameter<a/>
|
||||
*/
|
||||
public void setSharedEngine(Boolean sharedEngine) {
|
||||
public void setSharedEngine(@Nullable Boolean sharedEngine) {
|
||||
this.sharedEngine = sharedEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Boolean isSharedEngine() {
|
||||
return this.sharedEngine;
|
||||
}
|
||||
@@ -144,11 +156,12 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* @see #setResourceLoaderPath
|
||||
* @see <a href="http://www.webjars.org">WebJars</a>
|
||||
*/
|
||||
public void setScripts(String... scriptNames) {
|
||||
public void setScripts(@Nullable String... scriptNames) {
|
||||
this.scripts = scriptNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String[] getScripts() {
|
||||
return this.scripts;
|
||||
}
|
||||
@@ -158,11 +171,12 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* For example, in order to call {@code Mustache.render()}, {@code renderObject}
|
||||
* should be set to {@code "Mustache"} and {@code renderFunction} to {@code "render"}.
|
||||
*/
|
||||
public void setRenderObject(String renderObject) {
|
||||
public void setRenderObject(@Nullable String renderObject) {
|
||||
this.renderObject = renderObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getRenderObject() {
|
||||
return this.renderObject;
|
||||
}
|
||||
@@ -174,15 +188,16 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* <ol>
|
||||
* <li>{@code String template}: the template content</li>
|
||||
* <li>{@code Map model}: the view model</li>
|
||||
* <li>{@code RenderingContext context}: the rendering context (since 5.0)</li>
|
||||
* <li>{@code RenderingContext context}: the rendering context</li>
|
||||
* </ol>
|
||||
* @see RenderingContext
|
||||
*/
|
||||
public void setRenderFunction(String renderFunction) {
|
||||
public void setRenderFunction(@Nullable String renderFunction) {
|
||||
this.renderFunction = renderFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getRenderFunction() {
|
||||
return this.renderFunction;
|
||||
}
|
||||
@@ -191,11 +206,12 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* Set the charset used to read script and template files.
|
||||
* ({@code UTF-8} by default).
|
||||
*/
|
||||
public void setCharset(Charset charset) {
|
||||
public void setCharset(@Nullable Charset charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Charset getCharset() {
|
||||
return this.charset;
|
||||
}
|
||||
@@ -208,11 +224,12 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
|
||||
* Relative paths are allowed when running in an ApplicationContext.
|
||||
* <p>Default is "classpath:".
|
||||
*/
|
||||
public void setResourceLoaderPath(String resourceLoaderPath) {
|
||||
public void setResourceLoaderPath(@Nullable String resourceLoaderPath) {
|
||||
this.resourceLoaderPath = resourceLoaderPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getResourceLoaderPath() {
|
||||
return this.resourceLoaderPath;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext context) {
|
||||
public void setApplicationContext(@Nullable ApplicationContext context) {
|
||||
super.setApplicationContext(context);
|
||||
|
||||
ScriptTemplateConfig viewConfig = autodetectViewConfig();
|
||||
|
||||
Reference in New Issue
Block a user