Skip to content

Commit 74ffd65

Browse files
committed
GH-1189 - Deprecate @CheckReturnValue in favor of Spring Framework variant.
1 parent 8326923 commit 74ffd65

File tree

2 files changed

+20
-3
lines changed
  • spring-modulith-core/src/main/java/org/springframework/modulith/core/util
  • spring-modulith-test/src/main/java/org/springframework/modulith/test

2 files changed

+20
-3
lines changed

spring-modulith-core/src/main/java/org/springframework/modulith/core/util/CheckReturnValue.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
* "https://github.com/findbugsproject/findbugs/blob/264ae7baf890d2b347d91805c90057062b5dcb1e/findbugs/src/java/edu/umd/cs/findbugs/detect/BuildCheckReturnAnnotationDatabase.java#L120">Findbugs
2828
* source code</a>
2929
* @since 1.3
30+
* @deprecated since 1.4, use Spring Framework's {@link org.springframework.lang.CheckReturnValue} instead.
3031
*/
3132
@Target({
3233
ElementType.CONSTRUCTOR,
3334
ElementType.METHOD,
3435
ElementType.PACKAGE,
3536
ElementType.TYPE,
3637
})
38+
@Deprecated(since = "1.4", forRemoval = true)
3739
@Retention(RetentionPolicy.CLASS)
3840
public @interface CheckReturnValue {}

spring-modulith-test/src/main/java/org/springframework/modulith/test/Scenario.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import org.awaitility.Awaitility;
3232
import org.awaitility.core.ConditionFactory;
3333
import org.springframework.context.ApplicationEventPublisher;
34+
import org.springframework.lang.CheckReturnValue;
3435
import org.springframework.lang.Nullable;
35-
import org.springframework.modulith.core.util.CheckReturnValue;
3636
import org.springframework.modulith.test.PublishedEvents.TypedPublishedEvents;
3737
import org.springframework.modulith.test.PublishedEventsAssert.PublishedEventAssert;
3838
import org.springframework.transaction.TransactionDefinition;
@@ -53,7 +53,6 @@
5353
* @author Oliver Drotbohm
5454
* @see ApplicationModuleTest
5555
*/
56-
@CheckReturnValue
5756
public class Scenario {
5857

5958
private static final Predicate<Object> DEFAULT_ACCEPTANCE = it -> {
@@ -110,6 +109,7 @@ public class Scenario {
110109
* @param event must not be {@literal null}.
111110
* @return will never be {@literal null}.
112111
*/
112+
@CheckReturnValue
113113
public When<Void> publish(Object event) {
114114
return stimulate((tx, e) -> {
115115
tx.executeWithoutResult(__ -> e.publishEvent(event));
@@ -123,6 +123,7 @@ public When<Void> publish(Object event) {
123123
* @param event must not be {@literal null}.
124124
* @return will never be {@literal null}.
125125
*/
126+
@CheckReturnValue
126127
public When<Void> publish(Supplier<Object> event) {
127128

128129
return stimulate((tx, e) -> {
@@ -136,6 +137,7 @@ public When<Void> publish(Supplier<Object> event) {
136137
* @param runnable must not be {@literal null}.
137138
* @return will never be {@literal null}.
138139
*/
140+
@CheckReturnValue
139141
public When<Void> stimulate(Runnable runnable) {
140142

141143
Assert.notNull(runnable, "Runnable must not be null!");
@@ -156,6 +158,7 @@ public When<Void> stimulate(Runnable runnable) {
156158
* @see org.springframework.modulith.test.Scenario.When.StateChangeResult#andVerify(Consumer)
157159
* @see org.springframework.modulith.test.Scenario.When.EventResult#toArriveAndVerify(Consumer)
158160
*/
161+
@CheckReturnValue
159162
public <S> When<S> stimulate(Supplier<S> supplier) {
160163
return stimulate(tx -> tx.execute(__ -> supplier.get()));
161164
}
@@ -168,6 +171,7 @@ public <S> When<S> stimulate(Supplier<S> supplier) {
168171
* @param function must not be {@literal null}.
169172
* @return will never be {@literal null}.
170173
*/
174+
@CheckReturnValue
171175
public <S> When<S> stimulate(Function<TransactionOperations, S> function) {
172176
return stimulate((tx, __) -> {
173177
return function.apply(tx);
@@ -181,6 +185,7 @@ public <S> When<S> stimulate(Function<TransactionOperations, S> function) {
181185
* @param stimulus must not be {@literal null}.
182186
* @return will never be {@literal null}.
183187
*/
188+
@CheckReturnValue
184189
public When<Void> stimulate(BiConsumer<TransactionOperations, ApplicationEventPublisher> stimulus) {
185190

186191
Assert.notNull(stimulus, "Stimulus must not be null!");
@@ -199,6 +204,7 @@ public When<Void> stimulate(BiConsumer<TransactionOperations, ApplicationEventPu
199204
* @param stimulus must not be {@literal null}.
200205
* @return will never be {@literal null}.
201206
*/
207+
@CheckReturnValue
202208
public <S> When<S> stimulate(BiFunction<TransactionOperations, ApplicationEventPublisher, S> stimulus) {
203209

204210
Assert.notNull(stimulus, "Stimulus must not be null!");
@@ -221,7 +227,6 @@ Scenario setDefaultCustomizer(Function<ConditionFactory, ConditionFactory> custo
221227
return this;
222228
}
223229

224-
@CheckReturnValue
225230
public class When<T> {
226231

227232
private final BiFunction<TransactionOperations, ApplicationEventPublisher, T> stimulus;
@@ -247,6 +252,7 @@ public class When<T> {
247252
* @param runnable must not be {@literal null}.
248253
* @return will never be {@literal null}.
249254
*/
255+
@CheckReturnValue
250256
public When<T> andCleanup(Runnable runnable) {
251257

252258
Assert.notNull(runnable, "Cleanup callback must not be null!");
@@ -261,6 +267,7 @@ public When<T> andCleanup(Runnable runnable) {
261267
* @param consumer must not be {@literal null}.
262268
* @return will never be {@literal null}.
263269
*/
270+
@CheckReturnValue
264271
public When<T> andCleanup(Consumer<T> consumer) {
265272

266273
Assert.notNull(consumer, "Cleanup callback must not be null!");
@@ -277,6 +284,7 @@ public When<T> andCleanup(Consumer<T> consumer) {
277284
* @param duration must not be {@literal null}.
278285
* @return will never be {@literal null}.
279286
*/
287+
@CheckReturnValue
280288
public When<T> andWaitAtMost(Duration duration) {
281289

282290
Assert.notNull(duration, "Duration must not be null!");
@@ -292,6 +300,7 @@ public When<T> andWaitAtMost(Duration duration) {
292300
* @param customizer must not be {@literal null}.
293301
* @return will never be {@literal null}.
294302
*/
303+
@CheckReturnValue
295304
public When<T> customize(Function<ConditionFactory, ConditionFactory> customizer) {
296305

297306
Assert.notNull(customizer, "Customizer must not be null!");
@@ -310,6 +319,7 @@ public When<T> customize(Function<ConditionFactory, ConditionFactory> customizer
310319
* @return will never be {@literal null}.
311320
* @see #andWaitForEventOfType(Class)
312321
*/
322+
@CheckReturnValue
313323
public <E> EventResult<E> forEventOfType(Class<E> type) {
314324
return andWaitForEventOfType(type);
315325
}
@@ -323,6 +333,7 @@ public <E> EventResult<E> forEventOfType(Class<E> type) {
323333
* @return will never be {@literal null}.
324334
* @see #andWaitForStateChange(Supplier)
325335
*/
336+
@CheckReturnValue
326337
public <S> StateChangeResult<S> forStateChange(Supplier<S> supplier) {
327338
return forStateChange(supplier, DEFAULT_ACCEPTANCE);
328339
}
@@ -337,6 +348,7 @@ public <S> StateChangeResult<S> forStateChange(Supplier<S> supplier) {
337348
* @return will never be {@literal null}.
338349
* @see #andWaitForStateChange(Supplier, Predicate)
339350
*/
351+
@CheckReturnValue
340352
public <S> StateChangeResult<S> forStateChange(Supplier<S> supplier, Predicate<? super S> acceptanceCriteria) {
341353
return andWaitForStateChange(supplier, acceptanceCriteria);
342354
}
@@ -350,6 +362,7 @@ public <S> StateChangeResult<S> forStateChange(Supplier<S> supplier, Predicate<?
350362
* @return will never be {@literal null}.
351363
* @see #forEventOfType(Class)
352364
*/
365+
@CheckReturnValue
353366
public <E> EventResult<E> andWaitForEventOfType(Class<E> type) {
354367
return new EventResult<E>(type, Function.identity(), null);
355368
}
@@ -365,6 +378,7 @@ public <E> EventResult<E> andWaitForEventOfType(Class<E> type) {
365378
* @return will never be {@literal null}.
366379
* @see #forStateChange(Supplier)
367380
*/
381+
@CheckReturnValue
368382
public <S> StateChangeResult<S> andWaitForStateChange(Supplier<S> supplier) {
369383
return andWaitForStateChange(supplier, DEFAULT_ACCEPTANCE);
370384
}
@@ -379,6 +393,7 @@ public <S> StateChangeResult<S> andWaitForStateChange(Supplier<S> supplier) {
379393
* @return will never be {@literal null}.
380394
* @see #andWaitForStateChange(Supplier, Predicate)
381395
*/
396+
@CheckReturnValue
382397
public <S> StateChangeResult<S> andWaitForStateChange(Supplier<S> supplier,
383398
Predicate<? super S> acceptanceCriteria) {
384399

0 commit comments

Comments
 (0)