Github user StephanEwen commented on a diff in the pull request: https://github.com/apache/flink/pull/2691#discussion_r85334057 --- Diff: flink-core/src/main/java/org/apache/flink/core/fs/FileSystem.java --- @@ -55,6 +60,40 @@ private static final String HADOOP_WRAPPER_SCHEME = "hdwrapper"; + private static final Logger LOG = LoggerFactory.getLogger(FileSystem.class); + + /** + * Create a SafetyNetCloseableRegistry for a Task. This method should be called at the beginning of the task's + * main thread. + */ + public static void createFileSystemCloseableRegistryForTask() { + SafetyNetCloseableRegistry current = REGISTRIES.get(); + if (null != current) { + if (!current.isClosed()) { + IOUtils.closeQuietly(current); + LOG.warn("Found open SafetyNetCloseableRegistry. Closed and replaced it."); + } + } + REGISTRIES.set(new SafetyNetCloseableRegistry()); + } + + /** + * Create a SafetyNetCloseableRegistry for a Task. This method should be called at the end of the task's + * main thread or when the task should be canceled. + */ + public static void disposeFileSystemCloseableRegistryForTask() { + SafetyNetCloseableRegistry ret = REGISTRIES.get(); + if (null != ret) { + LOG.info("Closing SafetyNetCloseableRegistry."); --- End diff -- Let's log something like "Ensuring all FileSystem streams are closed". Users will understand that better ;-)
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---