File tree 1 file changed +2
-0
lines changed
1 file changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -1330,6 +1330,7 @@ See also [ETS.3](#unneeded-thread-safety) about unneeded thread-safety of a meth
1330
1330
` Future ` before asynchronous execution is started** , and is it started at all? Here is the
1331
1331
antipattern:
1332
1332
``` java
1333
+ // DON'T DO THIS
1333
1334
Future<Salary > getSalary(Employee employee) throws ConnectionException {
1334
1335
Branch branch = retrieveBranch(employee); // A database or an RPC call
1335
1336
return CompletableFuture . supplyAsync(() - > {
@@ -1341,6 +1342,7 @@ Blocking the caller thread is unexpected for a user seeing a method returning a
1341
1342
1342
1343
An example completely without asynchrony:
1343
1344
``` java
1345
+ // DON'T DO THIS
1344
1346
Future<Salary > getSalary(Employee employee) throws ConnectionException {
1345
1347
SalaryDTO salaryDto = retrieveSalary(employee); // A database or an RPC call
1346
1348
Salary salary = toSalary(salaryDto);
You can’t perform that action at this time.
0 commit comments