Skip to content

Commit 9b7af8b

Browse files
committed
Polishing
1 parent 07b479e commit 9b7af8b

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

spring-core/src/main/java/org/springframework/util/concurrent/DelegatingCompletableFuture.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.concurrent.CompletableFuture;
2020
import java.util.concurrent.Future;
2121

22+
import org.springframework.util.Assert;
23+
2224
/**
2325
* Extension of {@link CompletableFuture} which allows for cancelling
2426
* a delegate along with the {@link CompletableFuture} itself.
@@ -30,10 +32,13 @@ class DelegatingCompletableFuture<T> extends CompletableFuture<T> {
3032

3133
private final Future<T> delegate;
3234

35+
3336
public DelegatingCompletableFuture(Future<T> delegate) {
37+
Assert.notNull(delegate, "Delegate must not be null");
3438
this.delegate = delegate;
3539
}
3640

41+
3742
@Override
3843
public boolean cancel(boolean mayInterruptIfRunning) {
3944
boolean result = this.delegate.cancel(mayInterruptIfRunning);

spring-messaging/src/main/java/org/springframework/messaging/core/GenericMessagingTemplate.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,10 @@ public long getReceiveTimeout() {
9797
return this.receiveTimeout;
9898
}
9999

100-
101100
/**
102101
* Set the name of the header used to determine the send timeout (if present).
103102
* Default {@value #DEFAULT_SEND_TIMEOUT_HEADER}.
104-
* The header is removed before sending the message to avoid propagation.
105-
* @param sendTimeoutHeader the sendTimeoutHeader to set
103+
* <p>The header is removed before sending the message to avoid propagation.
106104
* @since 5.0
107105
*/
108106
public void setSendTimeoutHeader(String sendTimeoutHeader) {
@@ -111,18 +109,17 @@ public void setSendTimeoutHeader(String sendTimeoutHeader) {
111109
}
112110

113111
/**
114-
* @return the configured sendTimeoutHeader.
112+
* Return the configured send-timeout header.
115113
* @since 5.0
116114
*/
117115
public String getSendTimeoutHeader() {
118-
return sendTimeoutHeader;
116+
return this.sendTimeoutHeader;
119117
}
120118

121119
/**
122120
* Set the name of the header used to determine the send timeout (if present).
123121
* Default {@value #DEFAULT_RECEIVE_TIMEOUT_HEADER}.
124122
* The header is removed before sending the message to avoid propagation.
125-
* @param receiveTimeoutHeader the receiveTimeoutHeader to set
126123
* @since 5.0
127124
*/
128125
public void setReceiveTimeoutHeader(String receiveTimeoutHeader) {
@@ -131,11 +128,11 @@ public void setReceiveTimeoutHeader(String receiveTimeoutHeader) {
131128
}
132129

133130
/**
134-
* @return the configured receiveTimeoutHeader
131+
* Return the configured receive-timeout header.
135132
* @since 5.0
136133
*/
137134
public String getReceiveTimeoutHeader() {
138-
return receiveTimeoutHeader;
135+
return this.receiveTimeoutHeader;
139136
}
140137

141138
/**
@@ -157,6 +154,7 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
157154
setDestinationResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
158155
}
159156

157+
160158
@Override
161159
protected final void doSend(MessageChannel channel, Message<?> message) {
162160
doSend(channel, message, sendTimeout(message));
@@ -267,6 +265,7 @@ else if (headerValue instanceof String) {
267265
}
268266
}
269267

268+
270269
/**
271270
* A temporary channel for receiving a single reply message.
272271
*/

src/docs/asciidoc/languages/kotlin.adoc

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -391,51 +391,48 @@ you will be able to write your Kotlin beans without any additional `open` keywor
391391

392392
=== Using immutable class instances for persistence
393393

394-
In Kotlin, it is very convenient and considered best practice to declare
395-
read-only properties within the primary constructor, as in the following
396-
example:
394+
In Kotlin, it is very convenient and considered best practice to declare read-only properties
395+
within the primary constructor, as in the following example:
397396

398397
[source,kotlin]
399398
----
400399
class Person(val name: String, val age: Int)
401400
----
402401

403402
You can optionally add https://kotlinlang.org/docs/reference/data-classes.html[the `data` keyword]
404-
to make the compiler automatically derives the following members from all properties
405-
declared in the primary constructor:
403+
to make the compiler automatically derive the following members from all properties declared
404+
in the primary constructor:
406405

407406
* equals()/hashCode() pair
408407
* toString() of the form "User(name=John, age=42)"
409408
* componentN() functions corresponding to the properties in their order of declaration
410409
* copy() function
411410

412-
This allows to change easily just one of the properties even if `User` properties are read-only:
413-
his allows us to write:
414-
411+
This allows for easy changes to individual properties even if `Person` properties are read-only:
415412

416413
[source,kotlin]
417414
----
418415
data class Person(val name: String, val age: Int)
419416
420-
val jack = User(name = "Jack", age = 1)
417+
val jack = Person(name = "Jack", age = 1)
421418
val olderJack = jack.copy(age = 2)
422419
----
423420

424-
But some persistence technologies like JPA require a default constructor, preventing this
421+
Common persistence technologies such as JPA require a default constructor, preventing this
425422
kind of design. Fortunately, there is now a workaround for this
426423
https://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell["default constructor hell"]
427424
since Kotlin provides a https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-jpa-compiler-plugin[kotlin-jpa]
428425
plugin which generates synthetic no-arg constructor for classes annotated with JPA annotations.
429426

430-
If you need to leverage this kind of mechanism for other persistence technologies, you can
431-
configure https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[kotlin-noarg]
427+
If you need to leverage this kind of mechanism for other persistence technologies, you can configure
428+
the https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[kotlin-noarg]
432429
plugin.
433430

434431
[NOTE]
435432
====
436-
As of Kay release train, Spring Data supports Kotlin immutable class instances
437-
and should not require `kotlin-noarg` plugin if the module leverages Spring Data object
438-
mapping (like with MongoDB, Redis, Cassandra, etc.).
433+
As of the Kay release train, Spring Data supports Kotlin immutable class instances and
434+
does not require the `kotlin-noarg` plugin if the module leverages Spring Data object
435+
mappings (like with MongoDB, Redis, Cassandra, etc).
439436
====
440437

441438

0 commit comments

Comments
 (0)