/** * Safely close some resource without throwing an exception. Any exception will be logged at TRACE level. * * @param c the resource */ public static void safeClose(final Closeable c) { if (c != null) { try { c.close(); } catch (Exception e) { VFSLogger.ROOT_LOGGER.trace("Failed to close resource", e); } } }
public AssemblyFileSystem(VirtualFileAssembly assembly) { this.assembly = assembly; VFSLogger.ROOT_LOGGER.tracef("Constructed a new assembly filesystem for %s", assembly); }
/** * Construct a real filesystem with the given real root. * * @param realRoot the real root * @param privileged {@code true} to check permissions once up front, {@code false} to check at access time */ public RealFileSystem(File realRoot, boolean privileged) { if (privileged) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new FilePermission(new File(realRoot, "-").getPath(), "read,delete")); } } // the transformation is for case insensitive file systems. This helps to ensure that the rest of the path matches exactly the canonical form File canonicalRoot = realRoot; try { canonicalRoot = realRoot.getCanonicalFile(); } catch(IOException e) { VFSLogger.ROOT_LOGGER.warnf(e, "Cannot get the canonical form of the real root. This could lead to potential problems if the %s flag is set.", VFSUtils.FORCE_CASE_SENSITIVE_KEY); } this.realRoot = canonicalRoot; this.privileged = privileged; VFSLogger.ROOT_LOGGER.tracef("Constructed real %s filesystem at root %s", privileged ? "privileged" : "unprivileged", realRoot); }
throw MESSAGES.nullArgument("paths"); boolean trace = VFSLogger.ROOT_LOGGER.isTraceEnabled(); Manifest manifest = getManifest(file); if (manifest == null) { return; } if (classPath == null) { if (trace) { VFSLogger.ROOT_LOGGER.tracef("Manifest has no Class-Path for %s", file.getPathName()); VFSLogger.ROOT_LOGGER.debugf("%s has no parent.", file); return; VFSLogger.ROOT_LOGGER.tracef("Parsing Class-Path: %s for %s parent=%s", classPath, file.getName(), parent.getName()); addManifestLocations(vf, paths); } else if (trace) { VFSLogger.ROOT_LOGGER.tracef("%s from manifest is already in the classpath %s", vf.getName(), paths); VFSLogger.ROOT_LOGGER.trace("Unable to find " + path + " from " + parent.getName()); VFSLogger.ROOT_LOGGER.debugf("Manifest Class-Path entry %s ignored for %s reason= %s", path, file.getPathName(), e);
VFSLogger.ROOT_LOGGER.failedToCleanExistingContentForTempFileProvider(providerType); VFSLogger.ROOT_LOGGER.debug("Failed to clean existing content for temp file provider of type " + providerType, t);
/** * Get a manifest from a virtual file, assuming the virtual file is the root of an archive * * @param archive the root the archive * @return the manifest or null if not found * @throws IOException if there is an error reading the manifest or the virtual file is closed * @throws IllegalArgumentException for a null archive */ public static Manifest getManifest(VirtualFile archive) throws IOException { if (archive == null) { throw MESSAGES.nullArgument("archive"); } VirtualFile manifest = archive.getChild(JarFile.MANIFEST_NAME); if (manifest == null || !manifest.exists()) { if (VFSLogger.ROOT_LOGGER.isTraceEnabled()) { VFSLogger.ROOT_LOGGER.tracef("Can't find manifest for %s", archive.getPathName()); } return null; } return readManifest(manifest); }
@SuppressWarnings({"FinalizeDoesntCallSuperFinalize"}) protected void finalize() throws IOException { if (!closed.get()) { final StackTraceElement[] allocationPoint = this.allocationPoint; if (allocationPoint != null) { final LeakDescriptor t = new LeakDescriptor(); t.setStackTrace(allocationPoint); VFSLogger.ROOT_LOGGER.vfsMountLeaked(mountPoint, t); } else { VFSLogger.ROOT_LOGGER.vfsMountLeaked(mountPoint, null); } close(); } } }
private void mount(VirtualFile target, MountConfig mountConfig) throws IOException { if (mounted.compareAndSet(false, true)) { if (target.isFile()) { VFSLogger.ROOT_LOGGER.debugf("Automounting: %s with options %s", target, mountConfig); final TempFileProvider provider = getTempFileProvider(); if (mountConfig.mountExpanded()) { if (mountConfig.copyTarget()) { handles.add(VFS.mountZipExpanded(target, target, provider)); } else { handles.add(VFS.mountZipExpanded(target.getPhysicalFile(), target, provider)); } } else { if (mountConfig.copyTarget()) { handles.add(VFS.mountZip(target, target, provider)); } else { handles.add(VFS.mountZip(target.getPhysicalFile(), target, provider)); } } } } }
public void run() { if (VFSUtils.recursiveDelete(root) == false) { if (retryExecutor != null) { VFSLogger.ROOT_LOGGER.tracef("Failed to delete root (%s), retrying in 30sec.", root); retryExecutor.schedule(this, 30L, TimeUnit.SECONDS); } else { VFSLogger.ROOT_LOGGER.tracef("Failed to delete root (%s).", root); } } } }
/** * Safely close some resource without throwing an exception. Any exception will be logged at TRACE level. * * @param zipFile the resource */ public static void safeClose(final ZipFile zipFile) { if (zipFile != null) { try { zipFile.close(); } catch (Exception e) { VFSLogger.ROOT_LOGGER.trace("Failed to close resource", e); } } }
/** * {@inheritDoc} */ public void close() throws IOException { VFSLogger.ROOT_LOGGER.tracef("Closing assembly filesystem %s", this); assembly.close(); }
public boolean accepts(VirtualFile file) { try { URL url = file.toURL(); String urlString = url.toExternalForm(); for (String include : includes) { if (urlString.contains(include) == false) { return false; } } for (String exclude : excludes) { if (urlString.contains(exclude)) { return false; } } return true; } catch (Exception e) { VFSLogger.ROOT_LOGGER.tracef(e,"Exception while filtering file: %s", file); return false; } } }
/** * Accept any file that ends with one of the filter suffixes. This checks that the file.getName() endsWith a suffix. * * @return true if the file matches a suffix, false otherwise. */ public boolean accepts(VirtualFile file) { String name = file.getName(); boolean accepts = false; for (String suffix : suffixes) { if (name.endsWith(suffix)) { accepts = true; break; } } VFSLogger.ROOT_LOGGER.tracef("%s accepted: %s", file, accepts); return accepts; } }
/** * {@inheritDoc} */ public void close() throws IOException { VFSLogger.ROOT_LOGGER.tracef("Closing zip filesystem %s", this); VFSUtils.safeClose(new Closeable() { public void close() throws IOException { zipFile.close(); } }); tempDir.close(); }
/** * Do we accept file. * <p/> * If pathName contains any of the keys, * * if the value is null - then do exclude * * if value is not null - only exclude if it value contains simple name * * @param file the virtual file * @return false if file is excluded by excludes map, true other wise */ public boolean accepts(VirtualFile file) { String pathName = getPathName(file); for (Map.Entry<String, Set<String>> entry : excludes.entrySet()) { String key = entry.getKey(); if (pathName.contains(key)) { String simpleName = file.getName(); Set<String> value = entry.getValue(); if (value == null || value.contains(simpleName)) { VFSLogger.ROOT_LOGGER.tracef("Excluding %s", pathName); return false; } } } return true; }
VFSLogger.ROOT_LOGGER.tracef("Unmounted filesystem %s on mount point %s", fileSystem, mountPoint); return; VFSLogger.ROOT_LOGGER.tracef("Unmounted filesystem %s on mount point %s", fileSystem, mountPoint); return; newParentMounts.remove(name); if (mounts.replace(parent, parentMounts, newParentMounts)) { VFSLogger.ROOT_LOGGER.tracef("Unmounted filesystem %s on mount point %s", fileSystem, mountPoint); return;
contentsDir = tempDir.getFile("contents"); contentsDir.mkdir(); VFSLogger.ROOT_LOGGER.tracef("Created zip filesystem for file %s in temp dir %s", archiveFile, tempDir);
VFSLogger.ROOT_LOGGER.tracef("Mounted filesystem %s on mount point %s", fileSystem, mountPoint); return mount;