Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关闭ZipFileSystem时发生java.nio.channels.ClosedChannel异常_Java_Zip_Nio - Fatal编程技术网

关闭ZipFileSystem时发生java.nio.channels.ClosedChannel异常

关闭ZipFileSystem时发生java.nio.channels.ClosedChannel异常,java,zip,nio,Java,Zip,Nio,我在关闭ZipFileSystem时随机出现以下错误: [16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]: java.nio.channels.ClosedChannelException [16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]: at sun.nio.ch.F

我在关闭ZipFileSystem时随机出现以下错误:

[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]: java.nio.channels.ClosedChannelException
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:109)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at sun.nio.ch.FileChannelImpl.position(FileChannelImpl.java:275)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at sun.nio.ch.FileChannelImpl.position(FileChannelImpl.java:49)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.readFullyAt(ZipFileSystem.java:952)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.readFullyAt(ZipFileSystem.java:945)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.copyLOCEntry(ZipFileSystem.java:1155)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.sync(ZipFileSystem.java:1259)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.close(ZipFileSystem.java:277)
Map<String, String> env = new HashMap<>();
env.put("create", "true");
URI classCachesURI = classCachesZip.toURI();
URI classCachesZipURI = new URI("jar:" + classCachesURI.getScheme(), classCachesURI.getPath(), null);
cacheFileSystem = FileSystems.newFileSystem(classCachesZipURI, env, null);
这不是一个例外,而是一条从
com.sun.nio.zipfs.ZipFileSystem:sync
多次打印的消息(每个文件一次)。我不知道发生了什么,以及
ClosedChannelException
指的是哪个频道。发生这种情况时,文件不会保存到ZipFileSystem

以下是我创建ZipFileSystem的方法:

[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]: java.nio.channels.ClosedChannelException
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:109)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at sun.nio.ch.FileChannelImpl.position(FileChannelImpl.java:275)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at sun.nio.ch.FileChannelImpl.position(FileChannelImpl.java:49)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.readFullyAt(ZipFileSystem.java:952)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.readFullyAt(ZipFileSystem.java:945)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.copyLOCEntry(ZipFileSystem.java:1155)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.sync(ZipFileSystem.java:1259)
[16:59:27] [Thread-1/INFO] [STDERR]: [com.sun.nio.zipfs.ZipFileSystem:sync:1262]:   at com.sun.nio.zipfs.ZipFileSystem.close(ZipFileSystem.java:277)
Map<String, String> env = new HashMap<>();
env.put("create", "true");
URI classCachesURI = classCachesZip.toURI();
URI classCachesZipURI = new URI("jar:" + classCachesURI.getScheme(), classCachesURI.getPath(), null);
cacheFileSystem = FileSystems.newFileSystem(classCachesZipURI, env, null);
并关闭它:

cacheFileSystem.close();

我看了很多次文档,看不出我可能做错了什么。我应该做些什么来避免这个问题?

对我很有用。请提供一个。@SotiriosDelimanolis创建文件系统,用上面的代码向其中写入一些文件,然后关闭它会导致随机出现问题(大约1/10次)。