public static OutputStreamAndPath createEntropyAware(
            FileSystem fs, Path path, WriteMode writeMode) throws IOException {

        final Path processedPath = addEntropy(fs, path);

        // create the stream on the original file system to let the safety net
        // take its effect
        final FSDataOutputStream out = fs.create(processedPath, writeMode);
        return new OutputStreamAndPath(out, processedPath);
    }
@Test
    void testClassLoaderFixingFsWithSafeyNet() throws Exception {
        final String entropyKey = "__ekey__";
        final String entropyValue = "abc";

        final File folder = TempDirUtils.newFolder(tempFolder);

        final Path path = new Path(Path.fromLocalFile(folder), entropyKey + "/path/");
        final Path pathWithEntropy = new Path(Path.fromLocalFile(folder), entropyValue + "/path/");

        PluginFileSystemFactory pluginFsFactory =
                PluginFileSystemFactory.of(new TestFileSystemFactory(entropyKey, entropyValue));
        FileSystem testFs = pluginFsFactory.create(URI.create("test"));

        FileSystemSafetyNet.initializeSafetyNetForThread();
        FileSystem fs = FileSystemSafetyNet.wrapWithSafetyNetWhenActivated(testFs);
        try {
            OutputStreamAndPath streamAndPath =
                    EntropyInjector.createEntropyAware(fs, path, WriteMode.NO_OVERWRITE);

            assertThat(streamAndPath.path()).isEqualTo(pathWithEntropy);
        } finally {
            FileSystemSafetyNet.closeSafetyNetAndGuardedResourcesForThread();
        }
    }