Clean up warnings in spring-webmvc

This commit is contained in:
Sam Brannen
2018-04-04 14:04:54 +02:00
parent 2c648379ab
commit aba882af4c
49 changed files with 153 additions and 156 deletions

View File

@@ -754,6 +754,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
private static class EmptyHandler {
@SuppressWarnings("unused")
public void handle() {
throw new UnsupportedOperationException("Not implemented");
}

View File

@@ -447,6 +447,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
return result;
}
@SuppressWarnings("unused")
public HttpHeaders handle() {
return this.headers;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -287,7 +287,7 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
@Nullable
protected Object adaptArgumentIfNecessary(@Nullable Object arg, MethodParameter parameter) {
if (parameter.getParameterType() == Optional.class) {
if (arg == null || (arg instanceof Collection && ((Collection) arg).isEmpty()) ||
if (arg == null || (arg instanceof Collection && ((Collection<?>) arg).isEmpty()) ||
(arg instanceof Object[] && ((Object[]) arg).length == 0)) {
return Optional.empty();
}

View File

@@ -190,7 +190,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
valueType = getReturnValueType(outputValue, returnType);
declaredType = getGenericType(returnType);
}
if (isResourceType(value, returnType)) {
outputMessage.getHeaders().set(HttpHeaders.ACCEPT_RANGES, "bytes");
if (value != null && inputMessage.getHeaders().getFirst(HttpHeaders.RANGE) != null) {
@@ -262,7 +262,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
if (genericConverter != null ?
((GenericHttpMessageConverter) converter).canWrite(declaredType, valueType, selectedMediaType) :
converter.canWrite(valueType, selectedMediaType)) {
outputValue = (T) getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType,
outputValue = getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType,
(Class<? extends HttpMessageConverter<?>>) converter.getClass(),
inputMessage, outputMessage);
if (outputValue != null) {
@@ -321,7 +321,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
/**
* @see #getProducibleMediaTypes(HttpServletRequest, Class, Type)
*/
@SuppressWarnings({"unchecked", "unused"})
@SuppressWarnings("unused")
protected List<MediaType> getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass) {
return getProducibleMediaTypes(request, valueClass, null);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -113,6 +113,7 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur
}
@Override
@SuppressWarnings("resource")
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -57,6 +57,7 @@ public class StreamingResponseBodyReturnValueHandler implements HandlerMethodRet
}
@Override
@SuppressWarnings("resource")
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {

View File

@@ -118,6 +118,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
logger.trace("Transforming resource: " + resource);
}
@SuppressWarnings("resource")
Scanner scanner = new Scanner(content);
LineInfo previous = null;
LineAggregator aggregator = new LineAggregator(resource, content);

View File

@@ -17,7 +17,6 @@
package org.springframework.web.servlet.resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -165,7 +165,7 @@ public class MarshallingView extends AbstractView {
Assert.state(this.marshaller != null, "No Marshaller set");
Class<?> classToCheck = value.getClass();
if (value instanceof JAXBElement) {
classToCheck = ((JAXBElement) value).getDeclaredType();
classToCheck = ((JAXBElement<?>) value).getDeclaredType();
}
return this.marshaller.supports(classToCheck);
}