Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit c30a34e

Browse files
committed
FABJ-389 shutdown threadExecutor
PS 02 Odd javadoc now getting flagged. Change-Id: I4a6d5287c56a5e5245f7a766dc4f9635b63c6104 Signed-off-by: rickr <cr22rc@gmail.com>
1 parent b9f61bd commit c30a34e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/main/java/org/hyperledger/fabric/sdk/Channel.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.concurrent.Executors;
4949
import java.util.concurrent.Future;
5050
import java.util.concurrent.LinkedBlockingQueue;
51+
import java.util.concurrent.ScheduledExecutorService;
5152
import java.util.concurrent.ScheduledFuture;
5253
import java.util.concurrent.TimeUnit;
5354
import java.util.concurrent.TimeoutException;
@@ -195,6 +196,7 @@ public class Channel implements Serializable {
195196
private transient LinkedHashMap<String, LinkedList<TL>> txListeners = new LinkedHashMap<>();
196197
//Cleans up any transaction listeners that will probably never complete.
197198
private transient ScheduledFuture<?> sweeper = null;
199+
private transient ScheduledExecutorService sweeperExecutorService;
198200
private transient String blh = null;
199201
private transient ServiceDiscovery serviceDiscovery;
200202

@@ -4195,14 +4197,14 @@ public CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalRe
41954197
/**
41964198
* NofEvents may be used with @see {@link TransactionOptions#nOfEvents(NOfEvents)} to control how reporting Peer service events and Eventhubs will
41974199
* complete the future acknowledging the transaction has been seen by those Peers.
4198-
* <p/>
4200+
* <p>
41994201
* You can use the method @see {@link #nofNoEvents} to create an NOEvents that will result in the future being completed immediately
42004202
* when the Orderer has accepted the transaction. Note in this case the transaction event will be set to null.
4201-
* <p/>
4203+
* <p>
42024204
* NofEvents can add Peer Eventing services and Eventhubs that should complete the future. By default all will need to
42034205
* see the transactions to complete the future. The method @see {@link #setN(int)} can set how many in the group need to see the transaction
42044206
* completion. Essentially setting it to 1 is any.
4205-
* </p>
4207+
* <p>
42064208
* NofEvents may also contain other NofEvent grouping. They can be nested.
42074209
*/
42084210

@@ -4569,7 +4571,7 @@ public TransactionOptions shuffleOrders(boolean shuffleOrders) {
45694571
* This maybe set to NOfEvents.nofNoEvents that will complete the future as soon as a successful submission
45704572
* to an Orderer, but the completed Transaction event in that case will be null.
45714573
*
4572-
* @param nOfEvents @see {@link NOfEvents}
4574+
* @param nOfEvents See @see {@link NOfEvents}
45734575
* @return This TransactionOptions
45744576
*/
45754577
public TransactionOptions nOfEvents(NOfEvents nOfEvents) {
@@ -5328,11 +5330,12 @@ void runSweeper() {
53285330

53295331
if (sweeper == null) {
53305332

5331-
sweeper = Executors.newSingleThreadScheduledExecutor(r -> {
5333+
sweeperExecutorService = Executors.newSingleThreadScheduledExecutor(r -> {
53325334
Thread t = Executors.defaultThreadFactory().newThread(r);
53335335
t.setDaemon(true);
53345336
return t;
5335-
}).scheduleAtFixedRate(() -> {
5337+
});
5338+
sweeper = sweeperExecutorService.scheduleAtFixedRate(() -> {
53365339
try {
53375340

53385341
if (txListeners != null) {
@@ -5646,6 +5649,12 @@ public synchronized void shutdown(boolean force) {
56465649
if (null != lsweeper) {
56475650
lsweeper.cancel(true);
56485651
}
5652+
5653+
ScheduledExecutorService lse = sweeperExecutorService;
5654+
sweeperExecutorService = null;
5655+
if (null != lse) {
5656+
lse.shutdownNow();
5657+
}
56495658
}
56505659

56515660
/**

0 commit comments

Comments
 (0)