Skip to content

Commit e9019cd

Browse files
committed
Polishing
1 parent e1bb697 commit e9019cd

File tree

13 files changed

+70
-80
lines changed

13 files changed

+70
-80
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlLobValue.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -169,8 +169,7 @@ public SqlLobValue(Reader reader, int length, LobHandler lobHandler) {
169169
* Set the specified content via the LobCreator.
170170
*/
171171
@Override
172-
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName)
173-
throws SQLException {
172+
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName) throws SQLException {
174173
if (sqlType == Types.BLOB) {
175174
if (this.content instanceof byte[] || this.content == null) {
176175
this.lobCreator.setBlobAsBytes(ps, paramIndex, (byte[]) this.content);
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/**
2-
* Provides a stategy interface for Large OBject handling,
3-
* with implementations for various databases.
4-
*
5-
* <p>Can be used independently from jdbc.core and jdbc.object,
6-
* for example in custom JDBC access code.
2+
* Provides a strategy interface for Large OBject handling,
3+
* as well as a customizable default implementation.
74
*/
85
package org.springframework.jdbc.support.lob;

spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -131,8 +131,8 @@ public static boolean isSessionTransactional(Session session, ConnectionFactory
131131
* @return the transactional Session, or {@code null} if none found
132132
* @throws JMSException in case of JMS failure
133133
*/
134-
public static Session getTransactionalSession(
135-
final ConnectionFactory cf, final Connection existingCon, final boolean synchedLocalTransactionAllowed)
134+
public static Session getTransactionalSession(final ConnectionFactory cf,
135+
final Connection existingCon, final boolean synchedLocalTransactionAllowed)
136136
throws JMSException {
137137

138138
return doGetTransactionalSession(cf, new ResourceFactory() {
@@ -173,8 +173,8 @@ public boolean isSynchedLocalTransactionAllowed() {
173173
* @return the transactional Session, or {@code null} if none found
174174
* @throws JMSException in case of JMS failure
175175
*/
176-
public static QueueSession getTransactionalQueueSession(
177-
final QueueConnectionFactory cf, final QueueConnection existingCon, final boolean synchedLocalTransactionAllowed)
176+
public static QueueSession getTransactionalQueueSession(final QueueConnectionFactory cf,
177+
final QueueConnection existingCon, final boolean synchedLocalTransactionAllowed)
178178
throws JMSException {
179179

180180
return (QueueSession) doGetTransactionalSession(cf, new ResourceFactory() {
@@ -215,8 +215,8 @@ public boolean isSynchedLocalTransactionAllowed() {
215215
* @return the transactional Session, or {@code null} if none found
216216
* @throws JMSException in case of JMS failure
217217
*/
218-
public static TopicSession getTransactionalTopicSession(
219-
final TopicConnectionFactory cf, final TopicConnection existingCon, final boolean synchedLocalTransactionAllowed)
218+
public static TopicSession getTransactionalTopicSession(final TopicConnectionFactory cf,
219+
final TopicConnection existingCon, final boolean synchedLocalTransactionAllowed)
220220
throws JMSException {
221221

222222
return (TopicSession) doGetTransactionalSession(cf, new ResourceFactory() {
@@ -234,7 +234,8 @@ public Connection createConnection() throws JMSException {
234234
}
235235
@Override
236236
public Session createSession(Connection con) throws JMSException {
237-
return ((TopicConnection) con).createTopicSession(synchedLocalTransactionAllowed, Session.AUTO_ACKNOWLEDGE);
237+
return ((TopicConnection) con).createTopicSession(
238+
synchedLocalTransactionAllowed, Session.AUTO_ACKNOWLEDGE);
238239
}
239240
@Override
240241
public boolean isSynchedLocalTransactionAllowed() {
@@ -339,8 +340,8 @@ public static Session doGetTransactionalSession(
339340
}
340341
if (resourceHolderToUse != resourceHolder) {
341342
TransactionSynchronizationManager.registerSynchronization(
342-
new JmsResourceSynchronization(
343-
resourceHolderToUse, connectionFactory, resourceFactory.isSynchedLocalTransactionAllowed()));
343+
new JmsResourceSynchronization(resourceHolderToUse, connectionFactory,
344+
resourceFactory.isSynchedLocalTransactionAllowed()));
344345
resourceHolderToUse.setSynchronizedWithTransaction(true);
345346
TransactionSynchronizationManager.bindResource(connectionFactory, resourceHolderToUse);
346347
}

spring-tx/src/main/java/org/springframework/transaction/support/TransactionCallbackWithoutResult.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -40,15 +40,12 @@ public final Object doInTransaction(TransactionStatus status) {
4040
* context. Does not need to care about transactions itself, although it can retrieve
4141
* and influence the status of the current transaction via the given status object,
4242
* e.g. setting rollback-only.
43-
*
4443
* <p>A RuntimeException thrown by the callback is treated as application
4544
* exception that enforces a rollback. An exception gets propagated to the
4645
* caller of the template.
47-
*
4846
* <p>Note when using JTA: JTA transactions only work with transactional
4947
* JNDI resources, so implementations need to use such resources if they
5048
* want transaction support.
51-
*
5249
* @param status associated transaction status
5350
* @see TransactionTemplate#execute
5451
*/

spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public static <T> BodyInserter<T, ReactiveHttpOutputMessage> fromObject(T body)
8585
* @param <P> the type of the {@code Publisher}
8686
* @return a {@code BodyInserter} that writes a {@code Publisher}
8787
*/
88-
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(P publisher,
89-
Class<T> elementClass) {
88+
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(
89+
P publisher, Class<T> elementClass) {
9090

9191
Assert.notNull(publisher, "'publisher' must not be null");
9292
Assert.notNull(elementClass, "'elementClass' must not be null");
@@ -101,8 +101,8 @@ public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMess
101101
* @param <P> the type of the {@code Publisher}
102102
* @return a {@code BodyInserter} that writes a {@code Publisher}
103103
*/
104-
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(P publisher,
105-
ResolvableType elementType) {
104+
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(
105+
P publisher, ResolvableType elementType) {
106106

107107
Assert.notNull(publisher, "'publisher' must not be null");
108108
Assert.notNull(elementType, "'elementType' must not be null");
@@ -111,9 +111,8 @@ public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMess
111111

112112
/**
113113
* Return a {@code BodyInserter} that writes the given {@code Resource}.
114-
* If the resource can be resolved to a {@linkplain Resource#getFile() file}, it will be copied
115-
* using
116-
* <a href="https://en.wikipedia.org/wiki/Zero-copy">zero-copy</a>
114+
* <p>If the resource can be resolved to a {@linkplain Resource#getFile() file}, it will
115+
* be copied using <a href="https://en.wikipedia.org/wiki/Zero-copy">zero-copy</a>.
117116
* @param resource the resource to write to the output message
118117
* @param <T> the type of the {@code Resource}
119118
* @return a {@code BodyInserter} that writes a {@code Publisher}
@@ -133,7 +132,7 @@ private static HttpMessageWriter<Resource> resourceHttpMessageWriter(BodyInserte
133132
.findFirst()
134133
.map(BodyInserters::<Resource>cast)
135134
.orElseThrow(() -> new IllegalStateException(
136-
"Could not find HttpMessageWriter that supports Resources."));
135+
"Could not find HttpMessageWriter that supports Resource objects"));
137136
}
138137

139138
/**
@@ -212,9 +211,10 @@ public static <T, S extends Publisher<T>> BodyInserter<S, ServerHttpResponse> fr
212211
* @param formData the form data to write to the output message
213212
* @return a {@code BodyInserter} that writes form data
214213
*/
215-
public static BodyInserter<MultiValueMap<String, String>, ClientHttpRequest> fromFormData(MultiValueMap<String, String> formData) {
216-
Assert.notNull(formData, "'formData' must not be null");
214+
public static BodyInserter<MultiValueMap<String, String>, ClientHttpRequest> fromFormData(
215+
MultiValueMap<String, String> formData) {
217216

217+
Assert.notNull(formData, "'formData' must not be null");
218218
return (outputMessage, context) -> {
219219
HttpMessageWriter<MultiValueMap<String, String>> messageWriter =
220220
findMessageWriter(context, FORM_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
@@ -223,9 +223,8 @@ public static BodyInserter<MultiValueMap<String, String>, ClientHttpRequest> fro
223223
};
224224
}
225225

226-
private static <T> HttpMessageWriter<T> findMessageWriter(BodyInserter.Context context,
227-
ResolvableType type,
228-
MediaType mediaType) {
226+
private static <T> HttpMessageWriter<T> findMessageWriter(
227+
BodyInserter.Context context, ResolvableType type, MediaType mediaType) {
229228

230229
return context.messageWriters().get()
231230
.filter(messageWriter -> messageWriter.canWrite(type, mediaType))
@@ -238,24 +237,24 @@ private static <T> HttpMessageWriter<T> findMessageWriter(BodyInserter.Context c
238237

239238

240239
/**
241-
* Return a {@code BodyInserter} that writes the given {@code Publisher<DataBuffer>} to the
242-
* body.
240+
* Return a {@code BodyInserter} that writes the given {@code Publisher<DataBuffer>} to the body.
243241
* @param publisher the data buffer publisher to write
244242
* @param <T> the type of the publisher
245243
* @return a {@code BodyInserter} that writes directly to the body
246244
* @see ReactiveHttpOutputMessage#writeWith(Publisher)
247245
*/
248-
public static <T extends Publisher<DataBuffer>> BodyInserter<T, ReactiveHttpOutputMessage> fromDataBuffers(T publisher) {
249-
Assert.notNull(publisher, "'publisher' must not be null");
246+
public static <T extends Publisher<DataBuffer>> BodyInserter<T, ReactiveHttpOutputMessage> fromDataBuffers(
247+
T publisher) {
250248

249+
Assert.notNull(publisher, "'publisher' must not be null");
251250
return (outputMessage, context) -> outputMessage.writeWith(publisher);
252251
}
253252

254253

255-
private static <T, P extends Publisher<?>, M extends ReactiveHttpOutputMessage> BodyInserter<T, M> bodyInserterFor(P body, ResolvableType bodyType) {
254+
private static <T, P extends Publisher<?>, M extends ReactiveHttpOutputMessage> BodyInserter<T, M> bodyInserterFor(
255+
P body, ResolvableType bodyType) {
256256

257257
return (m, context) -> {
258-
259258
MediaType contentType = m.getHeaders().getContentType();
260259
Supplier<Stream<HttpMessageWriter<?>>> messageWriters = context.messageWriters();
261260
return messageWriters.get()
@@ -280,5 +279,4 @@ private static <T> HttpMessageWriter<T> cast(HttpMessageWriter<?> messageWriter)
280279
return (HttpMessageWriter<T>) messageWriter;
281280
}
282281

283-
284282
}

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunction.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -41,12 +41,11 @@ public interface RouterFunction<T extends ServerResponse> {
4141

4242
/**
4343
* Return a composed routing function that first invokes this function,
44-
* and then invokes the {@code other} function (of the same type {@code T}) if this route had
45-
* {@linkplain Mono#empty() no result}.
46-
*
44+
* and then invokes the {@code other} function (of the same type {@code T})
45+
* if this route had {@linkplain Mono#empty() no result}.
4746
* @param other the function of type {@code T} to apply when this function has no result
48-
* @return a composed function that first routes with this function and then the {@code other} function if this
49-
* function has no result
47+
* @return a composed function that first routes with this function and then the
48+
* {@code other} function if this function has no result
5049
*/
5150
default RouterFunction<T> andSame(RouterFunction<T> other) {
5251
return request -> this.route(request).otherwiseIfEmpty(other.route(request));
@@ -56,10 +55,9 @@ default RouterFunction<T> andSame(RouterFunction<T> other) {
5655
* Return a composed routing function that first invokes this function,
5756
* and then invokes the {@code other} function (of a different type) if this route had
5857
* {@linkplain Optional#empty() no result}.
59-
*
6058
* @param other the function to apply when this function has no result
61-
* @return a composed function that first routes with this function and then the {@code other} function if this
62-
* function has no result
59+
* @return a composed function that first routes with this function and then the
60+
* {@code other} function if this function has no result
6361
*/
6462
default RouterFunction<?> and(RouterFunction<?> other) {
6563
return request -> this.route(request)
@@ -72,24 +70,24 @@ default RouterFunction<?> and(RouterFunction<?> other) {
7270
* and then routes to the given handler function if the given request predicate applies. This
7371
* method is a convenient combination of {@link #and(RouterFunction)} and
7472
* {@link RouterFunctions#route(RequestPredicate, HandlerFunction)}.
73+
* @param <S> the handler function type
7574
* @param predicate the predicate to test
7675
* @param handlerFunction the handler function to route to
77-
* @param <S> the handler function type
7876
* @return a composed function that first routes with this function and then the function
7977
* created from {@code predicate} and {@code handlerFunction} if this
8078
* function has no result
8179
*/
8280
default <S extends ServerResponse> RouterFunction<?> andRoute(RequestPredicate predicate,
8381
HandlerFunction<S> handlerFunction) {
82+
8483
return and(RouterFunctions.route(predicate, handlerFunction));
8584
}
8685

8786
/**
8887
* Filter all {@linkplain HandlerFunction handler functions} routed by this function with the given
8988
* {@linkplain HandlerFilterFunction filter function}.
90-
*
89+
* @param <S> the filter return type
9190
* @param filterFunction the filter to apply
92-
* @param <S> the filter return type
9391
* @return the filtered routing function
9492
*/
9593
default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T, S> filterFunction) {

spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
public abstract class AbstractView implements View, ApplicationContextAware {
4343

44-
/** Well-known name for the RequestDataValueProcessor in the bean factory. */
44+
/** Well-known name for the RequestDataValueProcessor in the bean factory */
4545
public static final String REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME = "requestDataValueProcessor";
4646

4747

@@ -68,7 +68,7 @@ public AbstractView() {
6868
* Default is "text/html;charset=UTF-8".
6969
*/
7070
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
71-
Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' is required.");
71+
Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
7272
this.mediaTypes.clear();
7373
if (supportedMediaTypes != null) {
7474
this.mediaTypes.addAll(supportedMediaTypes);
@@ -122,7 +122,7 @@ public void setApplicationContext(ApplicationContext applicationContext) {
122122
}
123123

124124
public ApplicationContext getApplicationContext() {
125-
return applicationContext;
125+
return this.applicationContext;
126126
}
127127

128128
/**

spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -25,7 +25,6 @@
2525
import org.springframework.beans.factory.InitializingBean;
2626
import org.springframework.util.PatternMatchUtils;
2727

28-
2928
/**
3029
* A {@link ViewResolver} that allow direct resolution of symbolic view names
3130
* to URLs without explicit mapping definition. This is useful if symbolic names
@@ -52,6 +51,7 @@
5251
*
5352
* <p>Note: This class does not support localized resolution, i.e. resolving
5453
* a symbolic view name to different resources depending on the current locale.
54+
*
5555
* @author Rossen Stoyanchev
5656
* @author Sebastien Deleuze
5757
* @since 5.0
@@ -75,7 +75,7 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes
7575

7676
private String[] viewNames;
7777

78-
private Function<String, RedirectView> redirectViewProvider = url -> new RedirectView(url);
78+
private Function<String, RedirectView> redirectViewProvider = RedirectView::new;
7979

8080
private String requestContextAttribute;
8181

@@ -194,6 +194,7 @@ public Mono<View> resolveViewName(String viewName, Locale locale) {
194194
if (!canHandle(viewName, locale)) {
195195
return Mono.empty();
196196
}
197+
197198
AbstractUrlBasedView urlBasedView;
198199
if (viewName.startsWith(REDIRECT_URL_PREFIX)) {
199200
String redirectUrl = viewName.substring(REDIRECT_URL_PREFIX.length());
@@ -202,6 +203,7 @@ public Mono<View> resolveViewName(String viewName, Locale locale) {
202203
else {
203204
urlBasedView = createUrlBasedView(viewName);
204205
}
206+
205207
View view = applyLifecycleMethods(viewName, urlBasedView);
206208
try {
207209
return (urlBasedView.checkResourceExists(locale) ? Mono.just(view) : Mono.empty());

spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolverSupport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -57,7 +57,7 @@ public ViewResolverSupport() {
5757
* Default is "text/html;charset=UTF-8".
5858
*/
5959
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
60-
Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' is required.");
60+
Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
6161
this.mediaTypes.clear();
6262
if (supportedMediaTypes != null) {
6363
this.mediaTypes.addAll(supportedMediaTypes);
@@ -77,7 +77,7 @@ public List<MediaType> getSupportedMediaTypes() {
7777
* Default is {@linkplain StandardCharsets#UTF_8 UTF 8}.
7878
*/
7979
public void setDefaultCharset(Charset defaultCharset) {
80-
Assert.notNull(defaultCharset, "'defaultCharset' must not be null");
80+
Assert.notNull(defaultCharset, "Default Charset must not be null");
8181
this.defaultCharset = defaultCharset;
8282
}
8383

0 commit comments

Comments
 (0)