class CloseableConnection implements Transport.Connection {

    private final CompletableFuture<Void> closeContext = new CompletableFuture<>();

    @Override
    public void addCloseListener(ActionListener<Void> listener) {
        closeContext.whenComplete(listener);
    }

    @Override
    public boolean isClosed() {
        return closeContext.isDone();
    }

    @Override
    public void close() {<FILL_FUNCTION_BODY>}
}

        // This method is safe to call multiple times as the close context will provide concurrency
        // protection and only be completed once. The attached listeners will only be notified once.
        closeContext.complete(null);
    
<no_super_class>