Skip to content

Commit dc5ddff

Browse files
committed
Polishing
1 parent f8ab19d commit dc5ddff

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

spring-test/src/main/java/org/springframework/test/context/transaction/TestContextTransactionUtils.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -205,13 +205,10 @@ public static PlatformTransactionManager retrieveTransactionManager(TestContext
205205
"Only one TransactionManagementConfigurer may exist in the ApplicationContext");
206206
if (configurers.size() == 1) {
207207
TransactionManager tm = configurers.values().iterator().next().annotationDrivenTransactionManager();
208-
if (tm instanceof PlatformTransactionManager) {
209-
return (PlatformTransactionManager) tm;
210-
}
211-
else {
212-
throw new IllegalStateException(
213-
"Specified transaction manager is not a PlatformTransactionManager: " + tm);
214-
}
208+
Assert.state(tm instanceof PlatformTransactionManager, () ->
209+
"Transaction manager specified via TransactionManagementConfigurer " +
210+
"is not a PlatformTransactionManager: " + tm);
211+
return (PlatformTransactionManager) tm;
215212
}
216213
}
217214

0 commit comments

Comments
 (0)