Skip to content

Commit 514896e

Browse files
ionik0Google Java Core Libraries
authored andcommitted
Advertise ClosingFuture from ListenableFuture, Futures, and FluentFuture.
Each of the three already has a passage about chaining operations and the alternatives for doing so; this adds a short pointer to `ClosingFuture` in each. Fixes #4022 Fixes #8688 RELNOTES=n/a PiperOrigin-RevId: 987494211
1 parent 39979d0 commit 514896e

7 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎android/guava/src/com/google/common/util/concurrent/FluentFuture.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
* need to adapt between {@code CompletableFuture} and {@code ListenableFuture}, consider <a
6666
* href="https://github.com/lukas-krecan/future-converter">Future Converter</a>.)
6767
*
68+
* <h3>{@link ClosingFuture}</h3>
69+
*
70+
* <p>If the steps of your pipeline create objects that must be closed when the computation is done,
71+
* such as database connections or file handles, use {@code ClosingFuture}. It supports the same
72+
* kinds of derived steps as {@code FluentFuture} but closes those objects once the pipeline
73+
* completes, fails, or is cancelled.
74+
*
6875
* <h2>Extension</h2>
6976
*
7077
* If you want a class like {@code FluentFuture} but with extra methods, we recommend declaring your

‎android/guava/src/com/google/common/util/concurrent/Futures.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@
7272
* <li><a href="https://dagger.dev/producers.html">Dagger Producers</a>
7373
* </ul>
7474
*
75-
* <p>If you do chain your operations manually, you may want to use {@link FluentFuture}.
75+
* <p>If you do chain your operations manually, you may want to use {@link FluentFuture}. If those
76+
* operations create objects that must be closed when the computation is done, see {@link
77+
* ClosingFuture}.
7678
*
7779
* @author Kevin Bourrillion
7880
* @author Nishant Thakkar

‎android/guava/src/com/google/common/util/concurrent/ListenableFuture.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
* <li><a href="https://dagger.dev/producers.html">Dagger Producers</a>
4848
* </ul>
4949
*
50+
* <p>If the operations in your chain create objects that must be closed when the computation is
51+
* done, such as database connections or file handles, consider {@link ClosingFuture}. It closes
52+
* them once the whole computation completes, fails, or is cancelled.
53+
*
5054
* <p>The main purpose of {@link #addListener addListener} is to support this chaining. You will
5155
* rarely use it directly, in part because it does not provide direct access to the {@code Future}
5256
* result. (If you want such access, you may prefer {@link Futures#addCallback

‎futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
* <li><a href="https://dagger.dev/producers.html">Dagger Producers</a>
4848
* </ul>
4949
*
50+
* <p>If the operations in your chain create objects that must be closed when the computation is
51+
* done, such as database connections or file handles, consider {@link ClosingFuture}. It closes
52+
* them once the whole computation completes, fails, or is cancelled.
53+
*
5054
* <p>The main purpose of {@link #addListener addListener} is to support this chaining. You will
5155
* rarely use it directly, in part because it does not provide direct access to the {@code Future}
5256
* result. (If you want such access, you may prefer {@link Futures#addCallback

‎guava/src/com/google/common/util/concurrent/FluentFuture.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
* need to adapt between {@code CompletableFuture} and {@code ListenableFuture}, consider <a
6666
* href="https://github.com/lukas-krecan/future-converter">Future Converter</a>.)
6767
*
68+
* <h3>{@link ClosingFuture}</h3>
69+
*
70+
* <p>If the steps of your pipeline create objects that must be closed when the computation is done,
71+
* such as database connections or file handles, use {@code ClosingFuture}. It supports the same
72+
* kinds of derived steps as {@code FluentFuture} but closes those objects once the pipeline
73+
* completes, fails, or is cancelled.
74+
*
6875
* <h2>Extension</h2>
6976
*
7077
* If you want a class like {@code FluentFuture} but with extra methods, we recommend declaring your

‎guava/src/com/google/common/util/concurrent/Futures.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@
7272
* <li><a href="https://dagger.dev/producers.html">Dagger Producers</a>
7373
* </ul>
7474
*
75-
* <p>If you do chain your operations manually, you may want to use {@link FluentFuture}.
75+
* <p>If you do chain your operations manually, you may want to use {@link FluentFuture}. If those
76+
* operations create objects that must be closed when the computation is done, see {@link
77+
* ClosingFuture}.
7678
*
7779
* @author Kevin Bourrillion
7880
* @author Nishant Thakkar

‎guava/src/com/google/common/util/concurrent/ListenableFuture.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
* <li><a href="https://dagger.dev/producers.html">Dagger Producers</a>
4848
* </ul>
4949
*
50+
* <p>If the operations in your chain create objects that must be closed when the computation is
51+
* done, such as database connections or file handles, consider {@link ClosingFuture}. It closes
52+
* them once the whole computation completes, fails, or is cancelled.
53+
*
5054
* <p>The main purpose of {@link #addListener addListener} is to support this chaining. You will
5155
* rarely use it directly, in part because it does not provide direct access to the {@code Future}
5256
* result. (If you want such access, you may prefer {@link Futures#addCallback

0 commit comments

Comments
 (0)