From 910d2788e9aee8ce1c2cbb23817b56c6a74521e5 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 23 Mar 2020 18:02:55 +0100 Subject: [PATCH] Polishing --- .../context/annotation/Configuration.java | 2 +- .../DataSourceTransactionManager.java | 3 +- .../function/DefaultServerRequest.java | 38 +++++++++---------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java index 8c10e2ff2aa..725999d89c8 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java @@ -447,7 +447,7 @@ public @interface Configuration { * subclass which comes with limitations such as the configuration class and * its methods not being allowed to declare {@code final}. *

The default is {@code true}, allowing for 'inter-bean references' via direct - * method call within the configuration class as well as for external calls to + * method calls within the configuration class as well as for external calls to * this configuration's {@code @Bean} methods, e.g. from another configuration class. * If this is not needed since each of this particular configuration's {@code @Bean} * methods is self-contained and designed as a plain factory method for container use, diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java index e7a66c53d1e..b05e4fcf333 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -138,6 +138,7 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan afterPropertiesSet(); } + /** * Set the JDBC DataSource that this instance should manage transactions for. *

This will typically be a locally defined DataSource, for example an diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java index 99e690afd7a..fa930797f25 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java @@ -86,8 +86,7 @@ class DefaultServerRequest implements ServerRequest { private final Map attributes; - public DefaultServerRequest(HttpServletRequest servletRequest, - List> messageConverters) { + public DefaultServerRequest(HttpServletRequest servletRequest, List> messageConverters) { this.serverHttpRequest = new ServletServerHttpRequest(servletRequest); this.messageConverters = Collections.unmodifiableList(new ArrayList<>(messageConverters)); this.allSupportedMediaTypes = allSupportedMediaTypes(messageConverters); @@ -104,6 +103,7 @@ class DefaultServerRequest implements ServerRequest { .collect(Collectors.toList()); } + @Override public String methodName() { return servletRequest().getMethod(); @@ -187,11 +187,8 @@ class DefaultServerRequest implements ServerRequest { } @SuppressWarnings("unchecked") - private T bodyInternal(Type bodyType, Class bodyClass) - throws ServletException, IOException { - - MediaType contentType = - this.headers.contentType().orElse(MediaType.APPLICATION_OCTET_STREAM); + private T bodyInternal(Type bodyType, Class bodyClass) throws ServletException, IOException { + MediaType contentType = this.headers.contentType().orElse(MediaType.APPLICATION_OCTET_STREAM); for (HttpMessageConverter messageConverter : this.messageConverters) { if (messageConverter instanceof GenericHttpMessageConverter) { @@ -232,10 +229,10 @@ class DefaultServerRequest implements ServerRequest { } @Override + @SuppressWarnings("unchecked") public Map pathVariables() { - @SuppressWarnings("unchecked") - Map pathVariables = (Map) servletRequest() - .getAttribute(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE); + Map pathVariables = (Map) + servletRequest().getAttribute(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE); if (pathVariables != null) { return pathVariables; } @@ -254,8 +251,9 @@ class DefaultServerRequest implements ServerRequest { return Optional.ofNullable(this.serverHttpRequest.getPrincipal()); } - static Optional checkNotModified(HttpServletRequest servletRequest, @Nullable Instant lastModified, - @Nullable String etag) { + + static Optional checkNotModified( + HttpServletRequest servletRequest, @Nullable Instant lastModified, @Nullable String etag) { long lastModifiedTimestamp = -1; if (lastModified != null && lastModified.isAfter(Instant.EPOCH)) { @@ -274,6 +272,7 @@ class DefaultServerRequest implements ServerRequest { } } + /** * Default implementation of {@link Headers}. */ @@ -281,7 +280,6 @@ class DefaultServerRequest implements ServerRequest { private final HttpHeaders delegate; - public DefaultRequestHeaders(HttpHeaders delegate) { this.delegate = delegate; } @@ -339,11 +337,11 @@ class DefaultServerRequest implements ServerRequest { } } + private static final class ServletParametersMap extends AbstractMap> { private final HttpServletRequest servletRequest; - private ServletParametersMap(HttpServletRequest servletRequest) { this.servletRequest = servletRequest; } @@ -389,7 +387,6 @@ class DefaultServerRequest implements ServerRequest { public void clear() { throw new UnsupportedOperationException(); } - } @@ -443,17 +440,15 @@ class DefaultServerRequest implements ServerRequest { this.servletRequest.removeAttribute(name); return value; } - - } + /** * Simple implementation of {@link HttpServletResponse} used by * {@link #checkNotModified(HttpServletRequest, Instant, String)} to record status and headers set by * {@link ServletWebRequest#checkNotModified(String, long)}. Throws an {@code UnsupportedOperationException} * for other methods. */ - @SuppressWarnings("deprecation") private static final class CheckNotModifiedResponse implements HttpServletResponse { private final HttpHeaders headers = new HttpHeaders(); @@ -486,6 +481,7 @@ class DefaultServerRequest implements ServerRequest { } @Override + @Deprecated public void setStatus(int sc, String sm) { this.status = sc; } @@ -496,6 +492,7 @@ class DefaultServerRequest implements ServerRequest { } @Override + @Nullable public String getHeader(String name) { return this.headers.getFirst(name); } @@ -503,7 +500,7 @@ class DefaultServerRequest implements ServerRequest { @Override public Collection getHeaders(String name) { List result = this.headers.get(name); - return result != null ? result : Collections.emptyList(); + return (result != null ? result : Collections.emptyList()); } @Override @@ -513,6 +510,7 @@ class DefaultServerRequest implements ServerRequest { // Unsupported + @Override public void addCookie(Cookie cookie) { throw new UnsupportedOperationException(); @@ -529,11 +527,13 @@ class DefaultServerRequest implements ServerRequest { } @Override + @Deprecated public String encodeUrl(String url) { throw new UnsupportedOperationException(); } @Override + @Deprecated public String encodeRedirectUrl(String url) { throw new UnsupportedOperationException(); }