protected final void doClose()

in java/commons/src/main/java/com/epam/deltix/data/connectors/commons/HttpFeed.java [98:139]


    protected final void doClose() {

        mgmtService.execute(() -> {
            if (state != STARTED_STATE) {
                return;
            }
            state = CLOSED_STATE;

            InterruptedException wasInterrupted = null;

            try {
                onClose();
            } catch (final Throwable t) {
                if (t instanceof InterruptedException) {
                    wasInterrupted = (InterruptedException) t;
                } else {
                    logger().warning(() -> "Unexpected error in onClose(): " + t.getLocalizedMessage(), t);
                }
            }

            try {
                httpExecutorService.shutdownNow();
                try {
                    httpExecutorService.awaitTermination(5, TimeUnit.SECONDS);
                } catch (final InterruptedException e) {
                    wasInterrupted = e;
                }
            } catch (final Throwable t) {
                //???
            }
            if (wasInterrupted != null) {
                Thread.currentThread().interrupt();
            }
        });

        mgmtService.shutdown(); // to allow to execute 'close' logic
        try {
            mgmtService.awaitTermination(15, TimeUnit.SECONDS);
        } catch (final InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }