You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/08/04 13:36:11 UTC

[GitHub] [commons-vfs] garydgregory commented on a change in pull request #96: Modify some loop using stream API

garydgregory commented on a change in pull request #96:
URL: https://github.com/apache/commons-vfs/pull/96#discussion_r465052852



##########
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:
       @PeterAlfredLee 
   May you please rebase on `master`, test and cast to `java.io.Closeable` instead of `VfsComponent`.

##########
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:
       Formatting: `scheme+":"` -> `scheme + ":"`




----------------------------------------------------------------
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:
users@infra.apache.org