8066577: Cleanup and make better use of the stream API in the jrtfs code
Reviewed-by: alanb, psandoz, redestad
This commit is contained in:
parent
af8dc755fd
commit
bc903b0547
@ -47,8 +47,8 @@ final class JrtDirectoryStream implements DirectoryStream<Path> {
|
|||||||
|
|
||||||
private final JrtPath dir;
|
private final JrtPath dir;
|
||||||
private final DirectoryStream.Filter<? super Path> filter;
|
private final DirectoryStream.Filter<? super Path> filter;
|
||||||
private volatile boolean isClosed;
|
private boolean isClosed;
|
||||||
private volatile Iterator<Path> itr;
|
private Iterator<Path> itr;
|
||||||
|
|
||||||
JrtDirectoryStream(JrtPath dir,
|
JrtDirectoryStream(JrtPath dir,
|
||||||
DirectoryStream.Filter<? super java.nio.file.Path> filter)
|
DirectoryStream.Filter<? super java.nio.file.Path> filter)
|
||||||
@ -73,24 +73,22 @@ final class JrtDirectoryStream implements DirectoryStream<Path> {
|
|||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
return new Iterator<Path>() {
|
return new Iterator<Path>() {
|
||||||
private Path next;
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean hasNext() {
|
public boolean hasNext() {
|
||||||
|
synchronized (JrtDirectoryStream.this) {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
return false;
|
return false;
|
||||||
return itr.hasNext();
|
return itr.hasNext();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Path next() {
|
public Path next() {
|
||||||
|
synchronized (JrtDirectoryStream.this) {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
return itr.next();
|
return itr.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,7 @@ class JrtFileSystem extends FileSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Path> getRootDirectories() {
|
public Iterable<Path> getRootDirectories() {
|
||||||
ArrayList<Path> dirs = new ArrayList<>();
|
return Collections.singleton(getRootPath());
|
||||||
dirs.add(getRootPath());
|
|
||||||
return dirs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -159,9 +157,7 @@ class JrtFileSystem extends FileSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Iterable<FileStore> getFileStores() {
|
public final Iterable<FileStore> getFileStores() {
|
||||||
ArrayList<FileStore> list = new ArrayList<>(1);
|
return Collections.singleton(getFileStore(getRootPath()));
|
||||||
list.add(getFileStore(getRootPath()));
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<String> supportedFileAttributeViews
|
private static final Set<String> supportedFileAttributeViews
|
||||||
|
Loading…
x
Reference in New Issue
Block a user