src/share/classes/jdk/nio/zipfs/ZipFileSystem.java

Print this page

        

*** 39,48 **** --- 39,50 ---- import java.nio.file.*; import java.nio.file.attribute.*; import java.nio.file.spi.*; import java.security.AccessController; import java.security.PrivilegedAction; + import java.security.PrivilegedActionException; + import java.security.PrivilegedExceptionAction; import java.util.*; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.regex.Pattern; import java.util.zip.CRC32;
*** 108,118 **** throw new FileSystemNotFoundException(zfpath.toString()); } } // sm and existence check zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.READ); ! if (!Files.isWritable(zfpath)) this.readOnly = true; this.zc = ZipCoder.get(nameEncoding); this.defaultdir = new ZipPath(this, getBytes(defaultDir)); this.ch = Files.newByteChannel(zfpath, READ); this.cen = initCEN(); --- 110,122 ---- throw new FileSystemNotFoundException(zfpath.toString()); } } // sm and existence check zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.READ); ! boolean writeable = AccessController.doPrivileged( ! (PrivilegedAction<Boolean>) () -> Files.isWritable(zfpath)); ! if (!writeable) this.readOnly = true; this.zc = ZipCoder.get(nameEncoding); this.defaultdir = new ZipPath(this, getBytes(defaultDir)); this.ch = Files.newByteChannel(zfpath, READ); this.cen = initCEN();
*** 260,272 **** for (InputStream is: copy) is.close(); } beginWrite(); // lock and sync try { ! sync(); ch.close(); // close the ch just in case no update ! } finally { // and sync dose not close the ch endWrite(); } synchronized (inflaters) { for (Inflater inf : inflaters) --- 264,280 ---- for (InputStream is: copy) is.close(); } beginWrite(); // lock and sync try { ! AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> { ! sync(); return null; ! }); ch.close(); // close the ch just in case no update ! } catch (PrivilegedActionException e) { // and sync dose not close the ch ! throw (IOException)e.getException(); ! } finally { endWrite(); } synchronized (inflaters) { for (Inflater inf : inflaters)
*** 279,290 **** IOException ioe = null; synchronized (tmppaths) { for (Path p: tmppaths) { try { ! Files.deleteIfExists(p); ! } catch (IOException x) { if (ioe == null) ioe = x; else ioe.addSuppressed(x); } --- 287,300 ---- IOException ioe = null; synchronized (tmppaths) { for (Path p: tmppaths) { try { ! AccessController.doPrivileged( ! (PrivilegedExceptionAction<Boolean>)() -> Files.deleteIfExists(p)); ! } catch (PrivilegedActionException e) { ! IOException x = (IOException)e.getException(); if (ioe == null) ioe = x; else ioe.addSuppressed(x); }