Polishing

This commit is contained in:
Juergen Hoeller 2015-09-04 14:38:47 +02:00
parent 811de8e50b
commit 667fc7e4a9
12 changed files with 32 additions and 37 deletions

View File

@ -393,17 +393,14 @@ public abstract class YamlProcessor {
*/
protected static class StrictMapAppenderConstructor extends Constructor {
public StrictMapAppenderConstructor() {
super();
}
@Override
protected Map<Object, Object> constructMapping(MappingNode node) {
try {
return super.constructMapping(node);
} catch (IllegalStateException e) {
}
catch (IllegalStateException ex) {
throw new ParserException("while parsing MappingNode",
node.getStartMark(), e.getMessage(), node.getEndMark());
node.getStartMark(), ex.getMessage(), node.getEndMark());
}
}
@ -414,7 +411,7 @@ public abstract class YamlProcessor {
@Override
public Object put(Object key, Object value) {
if (delegate.containsKey(key)) {
throw new IllegalStateException("duplicate key: " + key);
throw new IllegalStateException("Duplicate key: " + key);
}
return delegate.put(key, value);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@ -80,13 +80,14 @@ public class ReflectiveMethodExecutor implements MethodExecutor {
try {
clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());
return clazz;
} catch (NoSuchMethodException nsme) {
}
catch (NoSuchMethodException ex) {
// Continue below...
}
}
Class<?>[] intfaces = clazz.getInterfaces();
for (Class<?> intface: intfaces) {
discoverPublicClass(method, intface);
Class<?>[] ifcs = clazz.getInterfaces();
for (Class<?> ifc: ifcs) {
discoverPublicClass(method, ifc);
}
if (clazz.getSuperclass() != null) {
return discoverPublicClass(method, clazz.getSuperclass());

View File

@ -58,9 +58,8 @@ public class StompDecoder {
/**
* Configure a
* {@link org.springframework.messaging.support.MessageHeaderInitializer MessageHeaderInitializer}
* to apply to the headers of {@link Message}s from decoded STOMP frames.
* Configure a {@link MessageHeaderInitializer} to apply to the headers of
* {@link Message}s from decoded STOMP frames.
*/
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) {
this.headerInitializer = headerInitializer;

View File

@ -33,7 +33,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
@ -499,7 +498,8 @@ public class MockHttpServletResponse implements HttpServletResponse {
dateFormat.setTimeZone(GMT);
try {
return dateFormat.parse(getHeader(name)).getTime();
} catch (ParseException exception) {
}
catch (ParseException ex) {
throw new IllegalArgumentException(
"Value for header '" + name + "' is not a valid Date: " + getHeader(name));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@ -38,7 +38,6 @@ public class ResponseBodyTests {
@Test
public void json() throws Exception {
standaloneSetup(new PersonController()).build()
.perform(get("/person/Lee").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
@ -46,14 +45,14 @@ public class ResponseBodyTests {
.andExpect(jsonPath("$.name").value("Lee"));
}
@Controller
private class PersonController {
@RequestMapping(value="/person/{name}")
@ResponseBody
public Person get(@PathVariable String name) {
Person person = new Person(name);
return person;
return new Person(name);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.

View File

@ -35,7 +35,6 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.accept.ContentNegotiationManager;
@ -121,8 +120,9 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
List<MediaType> requestedMediaTypes = getAcceptableMediaTypes(servletRequest);
List<MediaType> producibleMediaTypes = getProducibleMediaTypes(servletRequest, returnValueClass, returnValueType);
Assert.isTrue(returnValue == null || !producibleMediaTypes.isEmpty(),
"No converter found for return value of type: " + returnValueClass);
if (returnValue != null && producibleMediaTypes.isEmpty()) {
throw new IllegalArgumentException("No converter found for return value of type: " + returnValueClass);
}
Set<MediaType> compatibleMediaTypes = new LinkedHashSet<MediaType>();
for (MediaType requestedType : requestedMediaTypes) {

View File

@ -144,8 +144,7 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
ServletServerHttpRequest inputMessage = new ServletServerHttpRequest(servletRequest);
Object arg = null;
arg = readWithMessageConverters(inputMessage, methodParam, paramType);
Object arg = readWithMessageConverters(inputMessage, methodParam, paramType);
if (arg == null) {
if (methodParam.getParameterAnnotation(RequestBody.class).required()) {
throw new HttpMessageNotReadableException("Required request body is missing: " +