public synchronized void close()

in flink-connector-mongodb/src/main/java/org/apache/flink/connector/mongodb/sink/writer/MongoWriter.java [177:199]


    public synchronized void close() throws Exception {
        if (!closed) {
            if (scheduledFuture != null) {
                scheduledFuture.cancel(false);
                scheduler.shutdown();
            }

            if (!bulkRequests.isEmpty()) {
                try {
                    doBulkWrite();
                } catch (Exception e) {
                    LOG.error("Writing records to MongoDB failed when closing MongoWriter", e);
                    throw new IOException("Writing records to MongoDB failed.", e);
                } finally {
                    mongoClient.close();
                    closed = true;
                }
            } else {
                mongoClient.close();
                closed = true;
            }
        }
    }