|
48 | 48 | import java.util.concurrent.Executors;
|
49 | 49 | import java.util.concurrent.Future;
|
50 | 50 | import java.util.concurrent.LinkedBlockingQueue;
|
| 51 | +import java.util.concurrent.ScheduledExecutorService; |
51 | 52 | import java.util.concurrent.ScheduledFuture;
|
52 | 53 | import java.util.concurrent.TimeUnit;
|
53 | 54 | import java.util.concurrent.TimeoutException;
|
@@ -195,6 +196,7 @@ public class Channel implements Serializable {
|
195 | 196 | private transient LinkedHashMap<String, LinkedList<TL>> txListeners = new LinkedHashMap<>();
|
196 | 197 | //Cleans up any transaction listeners that will probably never complete.
|
197 | 198 | private transient ScheduledFuture<?> sweeper = null;
|
| 199 | + private transient ScheduledExecutorService sweeperExecutorService; |
198 | 200 | private transient String blh = null;
|
199 | 201 | private transient ServiceDiscovery serviceDiscovery;
|
200 | 202 |
|
@@ -4195,14 +4197,14 @@ public CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalRe
|
4195 | 4197 | /**
|
4196 | 4198 | * NofEvents may be used with @see {@link TransactionOptions#nOfEvents(NOfEvents)} to control how reporting Peer service events and Eventhubs will
|
4197 | 4199 | * complete the future acknowledging the transaction has been seen by those Peers.
|
4198 |
| - * <p/> |
| 4200 | + * <p> |
4199 | 4201 | * You can use the method @see {@link #nofNoEvents} to create an NOEvents that will result in the future being completed immediately
|
4200 | 4202 | * when the Orderer has accepted the transaction. Note in this case the transaction event will be set to null.
|
4201 |
| - * <p/> |
| 4203 | + * <p> |
4202 | 4204 | * NofEvents can add Peer Eventing services and Eventhubs that should complete the future. By default all will need to
|
4203 | 4205 | * 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
|
4204 | 4206 | * completion. Essentially setting it to 1 is any.
|
4205 |
| - * </p> |
| 4207 | + * <p> |
4206 | 4208 | * NofEvents may also contain other NofEvent grouping. They can be nested.
|
4207 | 4209 | */
|
4208 | 4210 |
|
@@ -4569,7 +4571,7 @@ public TransactionOptions shuffleOrders(boolean shuffleOrders) {
|
4569 | 4571 | * This maybe set to NOfEvents.nofNoEvents that will complete the future as soon as a successful submission
|
4570 | 4572 | * to an Orderer, but the completed Transaction event in that case will be null.
|
4571 | 4573 | *
|
4572 |
| - * @param nOfEvents @see {@link NOfEvents} |
| 4574 | + * @param nOfEvents See @see {@link NOfEvents} |
4573 | 4575 | * @return This TransactionOptions
|
4574 | 4576 | */
|
4575 | 4577 | public TransactionOptions nOfEvents(NOfEvents nOfEvents) {
|
@@ -5328,11 +5330,12 @@ void runSweeper() {
|
5328 | 5330 |
|
5329 | 5331 | if (sweeper == null) {
|
5330 | 5332 |
|
5331 |
| - sweeper = Executors.newSingleThreadScheduledExecutor(r -> { |
| 5333 | + sweeperExecutorService = Executors.newSingleThreadScheduledExecutor(r -> { |
5332 | 5334 | Thread t = Executors.defaultThreadFactory().newThread(r);
|
5333 | 5335 | t.setDaemon(true);
|
5334 | 5336 | return t;
|
5335 |
| - }).scheduleAtFixedRate(() -> { |
| 5337 | + }); |
| 5338 | + sweeper = sweeperExecutorService.scheduleAtFixedRate(() -> { |
5336 | 5339 | try {
|
5337 | 5340 |
|
5338 | 5341 | if (txListeners != null) {
|
@@ -5646,6 +5649,12 @@ public synchronized void shutdown(boolean force) {
|
5646 | 5649 | if (null != lsweeper) {
|
5647 | 5650 | lsweeper.cancel(true);
|
5648 | 5651 | }
|
| 5652 | + |
| 5653 | + ScheduledExecutorService lse = sweeperExecutorService; |
| 5654 | + sweeperExecutorService = null; |
| 5655 | + if (null != lse) { |
| 5656 | + lse.shutdownNow(); |
| 5657 | + } |
5649 | 5658 | }
|
5650 | 5659 |
|
5651 | 5660 | /**
|
|
0 commit comments