@ SuppressWarnings ( "unchecked" ) public CompletableFuture < Void > close ( ) { this . closed = true ; List < CompletableFuture < Void > > futures = new ArrayList <> ( ) ; forEach ( ( connectionKey , closeable ) -> { futures . add ( closeable . closeAsync ( ) ) ; connections . remove ( connectionKey ) ; } ) ; return Futures . allOf ( futures ) ; }
Close all connections . Pending connections are closed using future chaining .