Skip to content

Commit 1d2b754

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents c74f241 + bfb06f8 commit 1d2b754

7 files changed

Lines changed: 339 additions & 44 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ The <action> type attribute can be add,update,fix,remove.
6363
<action type="fix" dev="ggregory" due-to="Martin Wiesner">Fix typos in Javadoc of FileUtils and related test classes #833.</action>
6464
<action type="fix" dev="ggregory" due-to="Daniel Vega, Gary Gregory" issue="IO-887">WriterOutputStream from a builder fails on malformed or unmappable input bytes.</action>
6565
<action type="fix" dev="ggregory" due-to="Gary Gregory">BoundedReader now extends ProxyReader.</action>
66+
<action type="fix" dev="ggregory" due-to="Peter De Maeyer, Gary Gregory" issue="IO-885">Path visits follow links #832.</action>
6667
<!-- ADD -->
6768
<action type="add" dev="ggregory" due-to="Gary Gregory, Piotr P. Karwasz">Add and use IOUtils.closeQuietlySuppress(Closeable, Throwable) #818.</action>
6869
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ProxyWriter.setReference(Writer).</action>

src/main/java/org/apache/commons/io/LineIterator.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,7 @@ public static void closeQuietly(final LineIterator iterator) {
8282
*/
8383
@SuppressWarnings("resource") // Caller closes Reader
8484
public LineIterator(final Reader reader) {
85-
Objects.requireNonNull(reader, "reader");
86-
if (reader instanceof BufferedReader) {
87-
bufferedReader = (BufferedReader) reader;
88-
} else {
89-
bufferedReader = new BufferedReader(reader);
90-
}
85+
bufferedReader = IOUtils.buffer(Objects.requireNonNull(reader, "reader"));
9186
}
9287

9388
/**

src/main/java/org/apache/commons/io/file/CountingPathVisitor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import org.apache.commons.io.file.Counters.PathCounters;
3030
import org.apache.commons.io.filefilter.IOFileFilter;
31-
import org.apache.commons.io.filefilter.SymbolicLinkFileFilter;
3231
import org.apache.commons.io.filefilter.TrueFileFilter;
3332
import org.apache.commons.io.function.IOBiFunction;
3433

@@ -152,7 +151,7 @@ static UnaryOperator<Path> defaultDirectoryTransformer() {
152151
}
153152

154153
static IOFileFilter defaultFileFilter() {
155-
return new SymbolicLinkFileFilter(FileVisitResult.TERMINATE, FileVisitResult.CONTINUE);
154+
return TrueFileFilter.INSTANCE;
156155
}
157156

158157
static PathCounters defaultPathCounters() {

src/test/java/org/apache/commons/io/FileUtilsTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,10 +2986,10 @@ void testSizeOfDirectory() throws Exception {
29862986
// Create a cyclic symlink
29872987
final Path linkPath = createCircularSymbolicLink(file);
29882988
try {
2989-
assertEquals(TEST_DIRECTORY_SIZE, FileUtils.sizeOfDirectory(file), "Unexpected directory size");
2989+
// Different result value depending on the Java version and operating system, but should not throw an exception or loop infinitely.
2990+
FileUtils.sizeOfDirectory(file);
29902991
} finally {
29912992
Files.deleteIfExists(linkPath);
2992-
assertDelete(true, file);
29932993
}
29942994
}
29952995

@@ -3014,7 +3014,8 @@ void testSizeOfDirectoryAsBigInteger() throws Exception {
30143014
assertMkdir(true, file);
30153015
final Path linkPath = createCircularSymbolicLink(file);
30163016
try {
3017-
assertEquals(TEST_DIRECTORY_SIZE_BI, FileUtils.sizeOfDirectoryAsBigInteger(file), "Unexpected directory size");
3017+
// Different result value depending on the Java version and operating system, but should not throw an exception or loop infinitely.
3018+
FileUtils.sizeOfDirectoryAsBigInteger(file);
30183019
assertDelete(false, file);
30193020
assertMkdir(false, file);
30203021
final File nonEmptyFile = new File(file, "non-emptyFile" + System.nanoTime());
@@ -3025,12 +3026,12 @@ void testSizeOfDirectoryAsBigInteger() throws Exception {
30253026
} finally {
30263027
IOUtils.closeQuietly(output);
30273028
}
3028-
assertEquals(TEST_DIRECTORY_SIZE_GT_ZERO_BI, FileUtils.sizeOfDirectoryAsBigInteger(file), "Unexpected directory size");
3029+
// Different result value depending on the Java version and operating system, but should not throw an exception or loop infinitely.
3030+
FileUtils.sizeOfDirectoryAsBigInteger(file);
30293031
assertDelete(true, nonEmptyFile);
30303032
assertDelete(false, file);
30313033
} finally {
30323034
Files.deleteIfExists(linkPath);
3033-
assertDelete(true, file);
30343035
}
30353036
}
30363037

0 commit comments

Comments
 (0)