Nullability refinements on private and static methods

Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
This commit is contained in:
Juergen Hoeller
2017-09-22 18:22:12 +02:00
parent 60f47f4489
commit 7ae59d0c2a
88 changed files with 319 additions and 300 deletions

View File

@@ -30,6 +30,7 @@ import okhttp3.RequestBody;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -145,6 +146,7 @@ public class OkHttp3ClientHttpRequestFactory
return builder.build();
}
@Nullable
private static okhttp3.MediaType getContentType(HttpHeaders headers) {
String rawContentType = headers.getFirst(HttpHeaders.CONTENT_TYPE);
return (StringUtils.hasText(rawContentType) ? okhttp3.MediaType.parse(rawContentType) : null);

View File

@@ -79,6 +79,7 @@ class DefaultClientCodecConfigurer extends AbstractCodecConfigurer implements Cl
return result;
}
@Nullable
private Decoder<?> getSseDecoder() {
if (this.sseDecoder != null) {
return this.sseDecoder;

View File

@@ -91,6 +91,7 @@ class DefaultServerCodecConfigurer extends AbstractCodecConfigurer implements Se
return result;
}
@Nullable
private Encoder<?> getSseEncoder() {
if (this.sseEncoder != null) {
return this.sseEncoder;

View File

@@ -67,6 +67,7 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
this.defaultMediaType = initDefaultMediaType(this.mediaTypes);
}
@Nullable
private static MediaType initDefaultMediaType(List<MediaType> mediaTypes) {
return mediaTypes.stream().filter(MediaType::isConcrete).findFirst().orElse(null);
}

View File

@@ -145,6 +145,7 @@ public abstract class RequestContextHolder {
*/
private static class FacesRequestAttributesFactory {
@Nullable
public static RequestAttributes getFacesRequestAttributes() {
FacesContext facesContext = FacesContext.getCurrentInstance();
return (facesContext != null ? new FacesRequestAttributes(facesContext) : null);

View File

@@ -146,6 +146,10 @@ public abstract class CommonsFileUploadSupport {
this.fileUpload.setHeaderEncoding(defaultEncoding);
}
/**
* Determine the default encoding to use for parsing requests.
* @see #setDefaultEncoding
*/
protected String getDefaultEncoding() {
String encoding = getFileUpload().getHeaderEncoding();
if (encoding == null) {
@@ -167,6 +171,10 @@ public abstract class CommonsFileUploadSupport {
this.uploadTempDirSpecified = true;
}
/**
* Return the temporary directory where uploaded files get stored.
* @see #setUploadTempDir
*/
protected boolean isUploadTempDirSpecified() {
return this.uploadTempDirSpecified;
}
@@ -247,19 +255,14 @@ public abstract class CommonsFileUploadSupport {
if (fileItem.isFormField()) {
String value;
String partEncoding = determineEncoding(fileItem.getContentType(), encoding);
if (partEncoding != null) {
try {
value = fileItem.getString(partEncoding);
}
catch (UnsupportedEncodingException ex) {
if (logger.isWarnEnabled()) {
logger.warn("Could not decode multipart item '" + fileItem.getFieldName() +
"' with encoding '" + partEncoding + "': using platform default");
}
value = fileItem.getString();
}
try {
value = fileItem.getString(partEncoding);
}
else {
catch (UnsupportedEncodingException ex) {
if (logger.isWarnEnabled()) {
logger.warn("Could not decode multipart item '" + fileItem.getFieldName() +
"' with encoding '" + partEncoding + "': using platform default");
}
value = fileItem.getString();
}
String[] curParam = multipartParameters.get(fileItem.getFieldName());
@@ -324,7 +327,6 @@ public abstract class CommonsFileUploadSupport {
}
}
@Nullable
private String determineEncoding(String contentTypeHeader, String defaultEncoding) {
if (!StringUtils.hasText(contentTypeHeader)) {
return defaultEncoding;

View File

@@ -28,6 +28,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -135,6 +136,7 @@ final class HierarchicalUriComponents extends UriComponents {
}
@Override
@NonNull
public String getPath() {
return this.path.getPath();
}

View File

@@ -299,7 +299,6 @@ public abstract class WebUtils {
* @return the value of the session attribute, or {@code null} if not found
* @throws IllegalStateException if the session attribute could not be found
*/
@Nullable
public static Object getRequiredSessionAttribute(HttpServletRequest request, String name)
throws IllegalStateException {