Polishing

This commit is contained in:
Juergen Hoeller
2016-12-19 01:51:57 +01:00
parent 594f4d56b8
commit b5f2e56e38
15 changed files with 99 additions and 88 deletions

View File

@@ -90,7 +90,6 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
private final Set<String> safeExtensions = new HashSet<String>();
/**
* Constructor with list of converters only.
*/
@@ -348,9 +347,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
* header with a safe attachment file name ("f.txt") is added to prevent
* RFD exploits.
*/
private void addContentDispositionHeader(ServletServerHttpRequest request,
ServletServerHttpResponse response) {
private void addContentDispositionHeader(ServletServerHttpRequest request, ServletServerHttpResponse response) {
HttpHeaders headers = response.getHeaders();
if (headers.containsKey(HttpHeaders.CONTENT_DISPOSITION)) {
return;
@@ -363,7 +360,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
}
}
catch (Throwable ex) {
// Ignore
// ignore
}
HttpServletRequest servletRequest = request.getServletRequest();

View File

@@ -69,11 +69,7 @@ import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
import org.springframework.web.util.WebUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
/**
* Test fixture for a {@link RequestResponseBodyMethodProcessor} with
@@ -732,7 +728,6 @@ public class RequestResponseBodyMethodProcessorTests {
}
String handle(
@RequestBody List<SimpleBean> list,
@RequestBody SimpleBean simpleBean,
@@ -751,15 +746,18 @@ public class RequestResponseBodyMethodProcessorTests {
return null;
}
private static abstract class MyParameterizedController<DTO extends Identifiable> {
@SuppressWarnings("unused")
public void handleDto(@RequestBody DTO dto) {}
}
private static class MySimpleParameterizedController extends MyParameterizedController<SimpleBean> {
}
private interface Identifiable extends Serializable {
Long getId();
@@ -767,6 +765,7 @@ public class RequestResponseBodyMethodProcessorTests {
void setId(Long id);
}
@SuppressWarnings("unused")
private static abstract class MyParameterizedControllerWithList<DTO extends Identifiable> {
@@ -774,6 +773,7 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
@SuppressWarnings("unused")
private static class MySimpleParameterizedControllerWithList extends MyParameterizedControllerWithList<SimpleBean> {
}
@@ -843,9 +843,12 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
private interface MyJacksonView1 {}
private interface MyJacksonView2 {}
private static class JacksonViewBean {
@JsonView(MyJacksonView1.class)
@@ -881,6 +884,7 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
public static class ParentClass {
@@ -902,6 +906,7 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
@JsonTypeName("foo")
public static class Foo extends ParentClass {
@@ -913,6 +918,7 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
@JsonTypeName("bar")
public static class Bar extends ParentClass {
@@ -924,6 +930,7 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
private static class JacksonController {
@RequestMapping
@@ -996,9 +1003,9 @@ public class RequestResponseBodyMethodProcessorTests {
public String defaultCharset() {
return "foo";
}
}
private static class EmptyRequestBodyAdvice implements RequestBodyAdvice {
@Override
@@ -1030,12 +1037,15 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
interface MappingInterface<A> {
default A handle(@RequestBody A arg) {
return arg;
}
}
static class MyControllerImplementingInterface implements MappingInterface<String> {
}