ivakegg commented on code in PR #395:
URL: https://github.com/apache/commons-vfs/pull/395#discussion_r1186868027
##########
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java:
##########
@@ -49,7 +49,53 @@ public class ZipFileSystem extends AbstractFileSystem {
private final File file;
private final Charset charset;
- private ZipFile zipFile;
+ private ZipFileThreadLocal zipFile = new ZipFileThreadLocal();
+
+ private class ZipFileThreadLocal {
+
+ private ThreadLocal<Boolean> isPresent = new ThreadLocal<Boolean>() {
+ @Override
+ protected Boolean initialValue() {
+ return Boolean.FALSE;
+ }
+ };
+ private ThreadLocal<ZipFile> zipFile = new ThreadLocal<ZipFile>() {
+ @Override
+ public ZipFile initialValue() {
+ if (isPresent.get()) {
+ throw new IllegalStateException("Creating an initial value
but we already have one");
+ }
+ try {
+ isPresent.set(Boolean.TRUE);
+ return createZipFile(ZipFileSystem.this.file);
+ } catch (FileSystemException fse) {
+ throw new RuntimeException(fse);
Review Comment:
ok, no problem. Good point. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]