Skip to content

Commit 3881a4a

Browse files
committed
Polishing
1 parent 3899b7a commit 3881a4a

File tree

39 files changed

+133
-147
lines changed

39 files changed

+133
-147
lines changed

spring-core/src/main/java/org/springframework/core/codec/Hints.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.core.codec;
1718

1819
import java.util.Collections;
@@ -34,15 +35,13 @@ public abstract class Hints {
3435

3536
/**
3637
* Name of hint exposing a prefix to use for correlating log messages.
37-
* @since 5.1
3838
*/
3939
public static final String LOG_PREFIX_HINT = Log.class.getName() + ".PREFIX";
4040

4141
/**
4242
* Name of boolean hint whether to avoid logging data either because it's
4343
* potentially sensitive, or because it has been logged by a composite
4444
* encoder, e.g. for multipart requests.
45-
* @since 5.1
4645
*/
4746
public static final String SUPPRESS_LOGGING_HINT = Log.class.getName() + ".SUPPRESS_LOGGING";
4847

@@ -91,7 +90,7 @@ public static <T> T getRequiredHint(@Nullable Map<String, Object> hints, String
9190
* @return the log prefix
9291
*/
9392
public static String getLogPrefix(@Nullable Map<String, Object> hints) {
94-
return hints != null ? (String) hints.getOrDefault(LOG_PREFIX_HINT, "") : "";
93+
return (hints != null ? (String) hints.getOrDefault(LOG_PREFIX_HINT, "") : "");
9594
}
9695

9796
/**
@@ -100,7 +99,7 @@ public static String getLogPrefix(@Nullable Map<String, Object> hints) {
10099
* @return whether logging of data is allowed
101100
*/
102101
public static boolean isLoggingSuppressed(@Nullable Map<String, Object> hints) {
103-
return hints != null && (boolean) hints.getOrDefault(SUPPRESS_LOGGING_HINT, false);
102+
return (hints != null && (boolean) hints.getOrDefault(SUPPRESS_LOGGING_HINT, false));
104103
}
105104

106105
/**

spring-core/src/main/java/org/springframework/core/env/Profiles.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,26 @@ public interface Profiles {
3939
*/
4040
boolean matches(Predicate<String> activeProfiles);
4141

42+
4243
/**
4344
* Create a new {@link Profiles} instance that checks for matches against
4445
* the given <em>profile strings</em>.
45-
*
4646
* <p>The returned instance will {@linkplain Profiles#matches(Predicate) match}
4747
* if any one of the given profile strings matches.
48-
*
4948
* <p>A profile string may contain a simple profile name (for example
5049
* {@code "production"}) or a profile expression. A profile expression allows
5150
* for more complicated profile logic to be expressed, for example
5251
* {@code "production & cloud"}.
53-
*
5452
* <p>The following operators are supported in profile expressions:
5553
* <ul>
5654
* <li>{@code !} - A logical <em>not</em> of the profile</li>
5755
* <li>{@code &} - A logical <em>and</em> of the profiles</li>
5856
* <li>{@code |} - A logical <em>or</em> of the profiles</li>
5957
* </ul>
60-
*
6158
* <p>Please note that the {@code &} and {@code |} operators may not be mixed
6259
* without using parentheses. For example {@code "a & b | c"} is not a valid
6360
* expression; it must be expressed as {@code "(a & b) | c"} or
6461
* {@code "a & (b | c)"}.
65-
*
6662
* @param profiles the <em>profile strings</em> to include
6763
* @return a new {@link Profiles} instance
6864
*/

spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ public Collection<String> getDestinationPrefixes() {
129129
return this.destinationPrefixes;
130130
}
131131

132-
@Override
133-
public void setApplicationEventPublisher(@Nullable ApplicationEventPublisher publisher) {
134-
this.eventPublisher = publisher;
135-
}
136-
137132
/**
138133
* Whether the client must receive messages in the order of publication.
139134
* <p>By default messages sent to the {@code "clientOutboundChannel"} may
@@ -159,6 +154,11 @@ public boolean isPreservePublishOrder() {
159154
return this.preservePublishOrder;
160155
}
161156

157+
@Override
158+
public void setApplicationEventPublisher(@Nullable ApplicationEventPublisher publisher) {
159+
this.eventPublisher = publisher;
160+
}
161+
162162
@Nullable
163163
public ApplicationEventPublisher getApplicationEventPublisher() {
164164
return this.eventPublisher;

spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-test/src/main/java/org/springframework/mock/web/server/MockServerWebExchange.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.mock.web.server;
1718

1819
import reactor.core.publisher.Mono;
@@ -38,7 +39,6 @@
3839
*/
3940
public final class MockServerWebExchange extends DefaultServerWebExchange {
4041

41-
4242
private MockServerWebExchange(MockServerHttpRequest request, WebSessionManager sessionManager) {
4343
super(request, new MockServerHttpResponse(), sessionManager,
4444
ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
@@ -101,12 +101,10 @@ public static class Builder {
101101
@Nullable
102102
private WebSessionManager sessionManager;
103103

104-
105104
public Builder(MockServerHttpRequest request) {
106105
this.request = request;
107106
}
108107

109-
110108
/**
111109
* Set the session to use for the exchange.
112110
* <p>This method is mutually exclusive with

spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,14 @@ void setGlobalResultHandlers(List<ResultHandler> resultHandlers) {
123123
this.defaultResultHandlers = resultHandlers;
124124
}
125125

126-
127126
/**
128127
* Return the underlying {@link DispatcherServlet} instance that this
129128
* {@code MockMvc} was initialized with.
130-
* <p>This is intended for use in custom request processing scenario where
131-
* a request handling component happens to delegate to the
132-
* {@code DispatcherServlet} at runtime and therefore needs to be injected
133-
* with it.
134-
* <p>For most processing scenarios, simply use {@link MockMvc#perform}, or
135-
* if you need to configure the {@code DispatcherServlet}, provide a
129+
* <p>This is intended for use in custom request processing scenario where a
130+
* request handling component happens to delegate to the {@code DispatcherServlet}
131+
* at runtime and therefore needs to be injected with it.
132+
* <p>For most processing scenarios, simply use {@link MockMvc#perform},
133+
* or if you need to configure the {@code DispatcherServlet}, provide a
136134
* {@link DispatcherServletCustomizer} to the {@code MockMvcBuilder}.
137135
* @since 5.1
138136
*/

spring-test/src/main/java/org/springframework/test/web/servlet/ResultMatcher.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
@FunctionalInterface
5050
public interface ResultMatcher {
5151

52-
5352
/**
5453
* Assert the result of an executed request.
5554
* @param result the result of the executed request

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,6 @@ public void setBasicAuth(String username, String password, @Nullable Charset cha
758758
* @see <a href="https://tools.ietf.org/html/rfc6750">RFC 6750</a>
759759
*/
760760
public void setBearerAuth(String token) {
761-
Assert.notNull(token, "Token must not be null");
762-
763761
set(AUTHORIZATION, "Bearer " + token);
764762
}
765763

spring-web/src/main/java/org/springframework/http/HttpLogging.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public static Log forLogName(Class<?> primaryLoggerClass) {
5959

6060
/**
6161
* Wrap the given primary logger with a composite logger that delegates to
62-
* it or to the fallback logger "org.springframework.web.HttpLogging", if
63-
* the primary is not enabled.
62+
* it or to the fallback logger "org.springframework.web.HttpLogging",
63+
* if the primary is not enabled.
6464
* @param primaryLogger the primary logger to use
6565
* @return the resulting composite logger
6666
*/

spring-web/src/main/java/org/springframework/http/ResponseCookie.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public String getSameSite() {
122122
return this.sameSite;
123123
}
124124

125+
125126
@Override
126127
public boolean equals(Object other) {
127128
if (this == other) {

spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpConnector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.springframework.core.io.buffer.DataBufferFactory;
3030
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
3131
import org.springframework.http.HttpMethod;
32+
import org.springframework.util.Assert;
3233

3334
/**
3435
* Jetty ReactiveStreams HttpClient implementation of {@link ClientHttpConnector}.
@@ -60,6 +61,7 @@ public JettyClientHttpConnector() {
6061
* Create a Jetty {@link ClientHttpConnector} with the given {@link HttpClient}.
6162
*/
6263
public JettyClientHttpConnector(HttpClient httpClient) {
64+
Assert.notNull(httpClient, "HttpClient is required");
6365
this.httpClient = httpClient;
6466
}
6567

@@ -68,6 +70,7 @@ public void setBufferFactory(DataBufferFactory bufferFactory) {
6870
this.bufferFactory = bufferFactory;
6971
}
7072

73+
7174
@Override
7275
public int getPhase() {
7376
return Integer.MAX_VALUE;
@@ -110,6 +113,7 @@ public void stop(Runnable callback) {
110113
callback.run();
111114
}
112115

116+
113117
@Override
114118
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
115119
Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {

spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpResponse.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.http.HttpHeaders;
2828
import org.springframework.http.HttpStatus;
2929
import org.springframework.http.ResponseCookie;
30-
import org.springframework.util.Assert;
3130
import org.springframework.util.CollectionUtils;
3231
import org.springframework.util.LinkedMultiValueMap;
3332
import org.springframework.util.MultiValueMap;
@@ -47,8 +46,6 @@ class JettyClientHttpResponse implements ClientHttpResponse {
4746

4847

4948
public JettyClientHttpResponse(ReactiveResponse reactiveResponse, Publisher<DataBuffer> content) {
50-
Assert.notNull(reactiveResponse, "reactiveResponse should not be null");
51-
Assert.notNull(content, "content should not be null");
5249
this.reactiveResponse = reactiveResponse;
5350
this.content = Flux.from(content);
5451
}

spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import reactor.netty.http.client.HttpClientResponse;
2929

3030
import org.springframework.http.HttpMethod;
31+
import org.springframework.util.Assert;
3132

3233
/**
3334
* Reactor-Netty implementation of {@link ClientHttpConnector}.
@@ -56,6 +57,7 @@ public ReactorClientHttpConnector() {
5657
* @since 5.1
5758
*/
5859
public ReactorClientHttpConnector(HttpClient httpClient) {
60+
Assert.notNull(httpClient, "HttpClient is required");
5961
this.httpClient = httpClient;
6062
}
6163

spring-web/src/main/java/org/springframework/http/codec/LoggingCodecSupport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.http.codec;
1718

1819
import org.apache.commons.logging.Log;

spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,7 @@ public Jackson2ObjectMapperBuilder defaultUseWrapper(boolean defaultUseWrapper)
458458
* @see com.fasterxml.jackson.annotation.PropertyAccessor
459459
* @see com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility
460460
*/
461-
public Jackson2ObjectMapperBuilder visibility(PropertyAccessor accessor,
462-
JsonAutoDetect.Visibility visibility) {
461+
public Jackson2ObjectMapperBuilder visibility(PropertyAccessor accessor, JsonAutoDetect.Visibility visibility) {
463462
this.visibilities.put(accessor, visibility);
464463
return this;
465464
}

spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public ProtobufJsonFormatHttpMessageConverter(@Nullable JsonFormat.Parser parser
8383
* @param parser the JSON parser configuration
8484
* @param printer the JSON printer configuration
8585
* @param registryInitializer an initializer for message extensions
86-
* @deprecated as of Spring Framework 5.1, use
87-
* {@link #ProtobufJsonFormatHttpMessageConverter(JsonFormat.Parser, JsonFormat.Printer, ExtensionRegistry)} instead
86+
* @deprecated as of 5.1, in favor of
87+
* {@link #ProtobufJsonFormatHttpMessageConverter(JsonFormat.Parser, JsonFormat.Printer, ExtensionRegistry)}
8888
*/
8989
@Deprecated
9090
public ProtobufJsonFormatHttpMessageConverter(@Nullable JsonFormat.Parser parser,

spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
public interface ServerHttpRequest extends HttpRequest, ReactiveHttpInputMessage {
4040

4141
/**
42-
* Return an id that represents the underlying connection, if available, or
43-
* the request, for the purpose of correlating log messages.
42+
* Return an id that represents the underlying connection, if available,
43+
* or the request for the purpose of correlating log messages.
4444
* @since 5.1
4545
* @see org.springframework.web.server.ServerWebExchange#getLogPrefix()
4646
*/

spring-web/src/main/java/org/springframework/web/filter/FormContentFilter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ public void setFormConverter(FormHttpMessageConverter converter) {
6969
this.formConverter = converter;
7070
}
7171

72-
public FormHttpMessageConverter getFormConverter() {
73-
return this.formConverter;
74-
}
75-
7672
/**
7773
* The default character set to use for reading form data.
7874
* This is a shortcut for:<br>

spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.method;
1718

1819
import java.lang.annotation.Annotation;
@@ -93,10 +94,12 @@ else if (controllerType != null) {
9394
}
9495

9596
private boolean hasSelectors() {
96-
return !this.basePackages.isEmpty() || !this.assignableTypes.isEmpty() || !this.annotations.isEmpty();
97+
return (!this.basePackages.isEmpty() || !this.assignableTypes.isEmpty() || !this.annotations.isEmpty());
9798
}
9899

99100

101+
// Static factory methods
102+
100103
/**
101104
* {@code Predicate} that applies to any handlers.
102105
*/
@@ -158,7 +161,6 @@ public static class Builder {
158161

159162
private final List<Class<? extends Annotation>> annotations = new ArrayList<>();
160163

161-
162164
/**
163165
* Match handlers declared under a base package, e.g. "org.example".
164166
* @param packages one or more base package classes

spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public List<MediaType> getSupportedMediaTypes() {
9797

9898
/**
9999
* Return the body type in the context of which this exception was generated.
100-
* This is applicable when the exception was raised as a result trying to
100+
* <p>This is applicable when the exception was raised as a result trying to
101101
* encode from or decode to a specific Java type.
102-
* @return the body type, or {@code null}
102+
* @return the body type, or {@code null} if not available
103103
* @since 5.1
104104
*/
105105
@Nullable

spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ public void setWarnLogCategory(String loggerName) {
6262

6363
@Override
6464
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
65-
6665
HttpStatus status = resolveStatus(ex);
6766
if (status == null || !exchange.getResponse().setStatusCode(status)) {
6867
return Mono.error(ex);
6968
}
7069

71-
// Mirrors AbstractHandlerExceptionResolver in spring-webmvc..
72-
70+
// Mirrors AbstractHandlerExceptionResolver in spring-webmvc...
7371
String logPrefix = exchange.getLogPrefix();
7472
if (this.warnLogger != null && this.warnLogger.isWarnEnabled()) {
7573
this.warnLogger.warn(logPrefix + formatError(ex, exchange.getRequest()), ex);

0 commit comments

Comments
 (0)