Polishing

This commit is contained in:
Juergen Hoeller
2016-12-13 13:02:23 +01:00
parent eeb7ae537f
commit 5169c51a6c
7 changed files with 27 additions and 22 deletions

View File

@@ -164,6 +164,7 @@ public class FreeMarkerView extends AbstractUrlBasedView {
@Override
protected Mono<Void> renderInternal(Map<String, Object> renderAttributes, MediaType contentType,
ServerWebExchange exchange) {
// Expose all standard FreeMarker hash models.
SimpleHash freeMarkerModel = getTemplateModel(renderAttributes, exchange);
if (logger.isDebugEnabled()) {
@@ -186,8 +187,8 @@ public class FreeMarkerView extends AbstractUrlBasedView {
return exchange.getResponse().writeWith(Flux.just(dataBuffer));
}
private static Optional<Charset> getCharset(MediaType mediaType) {
return mediaType != null ? Optional.ofNullable(mediaType.getCharset()) : Optional.empty();
private Optional<Charset> getCharset(MediaType mediaType) {
return (mediaType != null ? Optional.ofNullable(mediaType.getCharset()) : Optional.empty());
}
/**

View File

@@ -38,7 +38,6 @@ import org.springframework.web.reactive.socket.WebSocketSession;
*/
public class JettyWebSocketSession extends AbstractListenerWebSocketSession<Session> {
public JettyWebSocketSession(Session session) {
super(session, ObjectUtils.getIdentityHexString(session),
session.getUpgradeRequest().getRequestURI());
@@ -52,12 +51,12 @@ public class JettyWebSocketSession extends AbstractListenerWebSocketSession<Sess
@Override
protected void suspendReceiving() {
// No-op
// no-op
}
@Override
protected void resumeReceiving() {
// No-op
// no-op
}
@Override

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.socket.adapter;
import java.net.URI;
@@ -39,7 +40,6 @@ import org.springframework.web.reactive.socket.WebSocketSession;
*/
public class RxNettyWebSocketSession extends NettyWebSocketSessionSupport<WebSocketConnection> {
public RxNettyWebSocketSession(WebSocketConnection conn, URI uri, NettyDataBufferFactory factory) {
super(conn, uri, factory);
}

View File

@@ -40,7 +40,6 @@ import org.springframework.web.reactive.socket.WebSocketSession;
*/
public class TomcatWebSocketSession extends AbstractListenerWebSocketSession<Session> {
public TomcatWebSocketSession(Session session) {
super(session, session.getId(), session.getRequestURI());
}
@@ -53,12 +52,12 @@ public class TomcatWebSocketSession extends AbstractListenerWebSocketSession<Ses
@Override
protected void suspendReceiving() {
// No-op
// no-op
}
@Override
protected void resumeReceiving() {
// No-op
// no-op
}
@Override

View File

@@ -41,7 +41,6 @@ import org.springframework.web.reactive.socket.WebSocketSession;
*/
public class UndertowWebSocketSession extends AbstractListenerWebSocketSession<WebSocketChannel> {
public UndertowWebSocketSession(WebSocketChannel channel, URI url) {
super(channel, ObjectUtils.getIdentityHexString(channel), url);
}

View File

@@ -90,7 +90,6 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
private final Set<String> safeExtensions = new HashSet<>();
/**
* 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> {
}