Copilot commented on code in PR #870:
URL: https://github.com/apache/commons-io/pull/870#discussion_r3740882487


##########
src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java:
##########
@@ -527,7 +585,19 @@ public void initialize() throws Exception {
      * @return The child file entries.
      */
     private FileEntry[] listFileEntries(final File file, final FileEntry 
entry) {
-        return Stream.of(listFiles(file)).map(f -> createFileEntry(entry, 
f)).toArray(FileEntry[]::new);
+        return Stream.of(listFiles(file, entry)).map(f -> 
createFileEntry(entry, f)).toArray(FileEntry[]::new);
+    }
+
+    /**
+     * Lists the contents of a directory when the parent entry is below the 
maximum depth.
+     *
+     * @param directory The directory to list.
+     * @param entry     The directory entry.
+     * @return The directory contents or a zero length array if the maximum 
depth is reached.
+     */

Review Comment:
   The Javadoc summary says this lists contents when the *parent* entry is 
below the maximum depth, but the method actually checks the depth of the 
directory entry being listed (`entry.getLevel() - rootEntry.getLevel()`). 
Updating the wording will avoid confusion about which level is compared to 
`maxDepth`.



##########
src/changes/changes.xml:
##########
@@ -62,6 +62,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary 
Gregory">DeferredFileOutputStream better NPE message and new file permission 
tests (#862).</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Add messages 
when throwing NullPointerException.</action>
       <!-- ADD -->
+      <action type="add" due-to="bart" issue="IO-892">Add 
FileAlterationObserver.Builder.setMaxDepth(int) to limit directory traversal 
depth.</action>

Review Comment:
   In the 2.23.0 release notes section, all other <action> entries specify a 
"dev" attribute, but this new entry omits it. Adding the dev attribute keeps 
this entry consistent with the surrounding release notes metadata.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to