From 25d3f0f055009147f39a615538bd4fafed7ab757 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Wed, 24 Jan 2024 16:42:38 +0100 Subject: [PATCH] Use EFS.getNullFileSystem() instead of new NullFileSystem() --- Signed-off-by: Peter Kriens Signed-off-by: Peter Kriens --- .../jareditor/internal/JarFileSystem.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java b/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java index 0bed075df6..11abe69d0d 100644 --- a/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java +++ b/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java @@ -26,8 +26,6 @@ import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.filesystem.provider.FileStore; import org.eclipse.core.filesystem.provider.FileSystem; -import org.eclipse.core.internal.filesystem.NullFileStore; -import org.eclipse.core.internal.filesystem.NullFileSystem; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -51,12 +49,10 @@ * jarfileuri ::= * * - * @author aqute */ public class JarFileSystem extends FileSystem { private static final ILogger logger = Logger.getLogger(JarFileSystem.class); @SuppressWarnings("unused") - private static final NullFileSystem INIT = new NullFileSystem(); private static final String SCHEME_JARF = "jarf"; private final ConcurrentMap> roots = new ConcurrentHashMap<>(); @@ -100,10 +96,10 @@ public String[] childNames(int options, IProgressMonitor monitor) throws CoreExc @Override public IFileStore getChild(String name) { - new NullFileSystem(); - return new NullFileStore(new Path(getPath()).append(name)); + return nullFileStore(new Path(getPath()).append(name)); } + @Override public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException { return new ByteArrayInputStream(new byte[0]); @@ -215,7 +211,7 @@ public InputStream openInputStream(int options, IProgressMonitor monitor) throws public IFileStore getStore(URI uri) { if (!SCHEME_JARF.equals(uri.getScheme())) { logger.logError("No file system for : " + uri, null); - return new NullFileStore(Path.EMPTY); + return nullFileStore(new Path(uri.getPath())); } return jarf(uri).map(pair -> { URI fileuri = pair.getFirst(); @@ -224,14 +220,14 @@ public IFileStore getStore(URI uri) { store = EFS.getStore(fileuri); } catch (CoreException e) { logger.logError("Cannot locate filestore for the JAR file: " + fileuri, e); - return new NullFileStore(Path.EMPTY); + return nullFileStore(Path.EMPTY); } JarRootNode root = roots.compute(store, this::computeRootNode) .get(); if (root == null) { logger.logError("Failed to load jar for: " + fileuri, null); - return new NullFileStore(Path.EMPTY); + return nullFileStore(Path.EMPTY); } IPath path = pair.getSecond(); @@ -243,7 +239,7 @@ public IFileStore getStore(URI uri) { }) .recover(err -> { logger.logError(err, null); - return new NullFileStore(Path.EMPTY); + return nullFileStore(Path.EMPTY); }) .unwrap(); } @@ -333,4 +329,9 @@ static Result openInputStream(URI uri, String path, IProgressMonito return Result.err("Failed to open resource %s from %s : %s", path, uri, e); } } + + static IFileStore nullFileStore(IPath path) { + return EFS.getNullFileSystem() + .getStore(path); + } }