PeterAlfredLee commented on a change in pull request #96:
URL: https://github.com/apache/commons-vfs/pull/96#discussion_r465418018
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/CompositeFileProvider.java
##########
@@ -53,12 +55,7 @@ public FileObject findFile(final FileObject baseFile, final
String uri, final Fi
final StringBuilder buf = new StringBuilder(INITIAL_BUFSZ);
UriParser.extractScheme(getContext().getFileSystemManager().getSchemes(), uri,
buf);
-
- final String[] schemes = getSchemes();
- for (final String scheme : schemes) {
- buf.insert(0, ":");
- buf.insert(0, scheme);
- }
+ Arrays.stream(getSchemes()).forEach(scheme -> buf.insert(0,
scheme+":"));
Review comment:
Sure
##########
File path:
commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsContainer.java
##########
@@ -81,11 +82,7 @@ public void close() {
}
// Close all components
- for (final Object component : toclose) {
- if (component instanceof VfsComponent) {
- final VfsComponent vfsComponent = (VfsComponent) component;
- vfsComponent.close();
- }
- }
+ Arrays.stream(toclose).filter(component -> component instanceof
VfsComponent)
+ .forEach(component -> ((VfsComponent)
component).close());
Review comment:
It seems the `close` in `java.io.Closeable` may throw an IOException
while the `close` in `VfsComponent` won't. This means we have to surround this
with a try-catch, which I think is not a good idea.
```
// Close all components
Arrays.stream(toclose).filter(component -> component instanceof
VfsComponent)
.forEach(component -> {
try {
((java.io.Closeable)
component).close();
} catch (IOException e) {
e.printStackTrace();
}
});
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]