Skip to content

Commit cfd4d86

Browse files
committed
Merge branch 'master' of https://ggregory@gitbox.apache.org/repos/asf/commons-io.git
2 parents 52971e4 + 858f5cf commit cfd4d86

12 files changed

Lines changed: 257 additions & 290 deletions

File tree

src/changes/changes.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ The <action> type attribute can be add,update,fix,remove.
103103
<action dev="ggregory" type="fix" due-to="Elliotte Rusty Harold, Gary Gregory">Clarify and correct EndianUtils and SwappedDataInputStream API doc #566.</action>
104104
<action dev="ggregory" type="fix" due-to="Elliotte Rusty Harold">Add characterization test for copying a symlinked directory #570.</action>
105105
<action dev="ggregory" type="fix" due-to="Gary Gregory">RandomAccessFileInputStream.builder().get() now throws ISE instead of NPE.</action>
106+
<action dev="ggregory" type="fix" issue="IO-845" due-to="Elliotte Rusty Harold">Test links to targets outside the source directory #571.</action>
107+
<action dev="ggregory" type="fix" due-to="Elliotte Rusty Harold">Focus Javadoc on current version rather than past versions #573, #574.</action>
106108
<!-- Add -->
107109
<action dev="ggregory" type="add" due-to="Gary Gregory">Add and use PathUtils.getFileName(Path, Function&lt;Path, R&gt;).</action>
108110
<action dev="ggregory" type="add" due-to="Gary Gregory">Add and use PathUtils.getFileNameString().</action>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@
186186
*
187187
* <p>
188188
* This example provides a public {@code cancel()} method that can be called by another thread to stop the
189-
* processing. A typical example use-case would be a cancel button on a GUI. Calling this method sets a
190-
* <a href="https://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#36930"> volatile</a> flag to ensure
191-
* it will work properly in a multi-threaded environment. The flag is returned by the {@code handleIsCancelled()}
192-
* method, which will cause the walk to stop immediately. The {@code handleCancelled()} method will be the next,
193-
* and last, callback method received once cancellation has occurred.
189+
* processing. A typical example use-case is a cancel button on a GUI. Calling this method sets a
190+
* <a href='https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#d5e12277'>(@code volatile}</a>
191+
* flag to ensure it works properly in a multi-threaded environment.
192+
* The flag is returned by the {@code handleIsCancelled()} method, which causes the walk to stop
193+
* immediately. The {@code handleCancelled()} method will be the next, and last, callback method received once cancellation has occurred.
194194
* </p>
195195
*
196196
* <pre>

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,10 @@ List<String> performCommand(final String[] cmdAttribs, final int max, final Dura
473473
//
474474
// This method does what it can to avoid the 'Too many open files' error
475475
// based on trial and error and these links:
476-
// https://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692
477-
// https://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4801027
478-
// https://forum.java.sun.com/thread.jspa?threadID=533029&messageID=2572018
479-
// however, it's still not perfect as the JDK support is so poor
480-
// (see commons-exec or Ant for a better multithreaded multi-OS solution)
476+
// https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4784692
477+
// https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4801027
478+
// However, it's still not perfect as the JDK support is so poor.
479+
// (See commons-exec or Ant for a better multithreaded multi-OS solution.)
481480
//
482481
final Process proc = openProcess(cmdAttribs);
483482
final Thread monitor = ThreadMonitor.start(timeout);

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

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ static String decodeUrl(final String url) {
11841184
i += 3;
11851185
} while (i < n && url.charAt(i) == '%');
11861186
continue;
1187-
} catch (final RuntimeException ignored) {
1187+
} catch (final IndexOutOfBoundsException | NumberFormatException ignored) {
11881188
// malformed percent-encoded octet, fall through and
11891189
// append characters literally
11901190
} finally {
@@ -2690,8 +2690,7 @@ public static String readFileToString(final File file, final Charset charsetName
26902690
* @throws NullPointerException if file is {@code null}.
26912691
* @throws IOException if an I/O error occurs, including when the file does not exist, is a directory rather than a
26922692
* regular file, or for some other reason why the file cannot be opened for reading.
2693-
* @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
2694-
* .UnsupportedEncodingException} in version 2.2 if the named charset is unavailable.
2693+
* @throws java.nio.charset.UnsupportedCharsetException if the named charset is unavailable.
26952694
* @since 2.3
26962695
*/
26972696
public static String readFileToString(final File file, final String charsetName) throws IOException {
@@ -2740,8 +2739,7 @@ public static List<String> readLines(final File file, final Charset charset) thr
27402739
* @throws NullPointerException if file is {@code null}.
27412740
* @throws IOException if an I/O error occurs, including when the file does not exist, is a directory rather than a
27422741
* regular file, or for some other reason why the file cannot be opened for reading.
2743-
* @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
2744-
* .UnsupportedEncodingException} in version 2.2 if the named charset is unavailable.
2742+
* @throws java.nio.charset.UnsupportedCharsetException if the named charset is unavailable.
27452743
* @since 1.1
27462744
*/
27472745
public static List<String> readLines(final File file, final String charsetName) throws IOException {
@@ -3058,11 +3056,8 @@ private static String[] toSuffixes(final String... extensions) {
30583056

30593057
/**
30603058
* Implements behavior similar to the Unix "touch" utility. Creates a new file with size 0, or, if the file exists, just
3061-
* updates the file's modified time.
3062-
* <p>
3063-
* NOTE: As from v1.3, this method throws an IOException if the last modified date of the file cannot be set. Also, as
3064-
* from v1.3 this method creates parent directories if they do not exist.
3065-
* </p>
3059+
* updates the file's modified time. This method throws an IOException if the last modified date
3060+
* of the file cannot be set. It creates parent directories if they do not exist.
30663061
*
30673062
* @param file the File to touch.
30683063
* @throws NullPointerException if the parameter is {@code null}.
@@ -3211,8 +3206,7 @@ public static void write(final File file, final CharSequence data, final String
32113206
* @param append if {@code true}, then the data will be added to the
32123207
* end of the file rather than overwriting
32133208
* @throws IOException in case of an I/O error
3214-
* @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
3215-
* .UnsupportedEncodingException} in version 2.2 if the encoding is not supported by the VM
3209+
* @throws java.nio.charset.UnsupportedCharsetException if the encoding is not supported by the VM
32163210
* @since 2.1
32173211
*/
32183212
public static void write(final File file, final CharSequence data, final String charsetName, final boolean append) throws IOException {
@@ -3223,10 +3217,7 @@ public static void write(final File file, final CharSequence data, final String
32233217

32243218
/**
32253219
* Writes a byte array to a file creating the file if it does not exist.
3226-
* <p>
3227-
* NOTE: As from v1.3, the parent directories of the file will be created
3228-
* if they do not exist.
3229-
* </p>
3220+
* The parent directories of the file will be created if they do not exist.
32303221
*
32313222
* @param file the file to write to
32323223
* @param data the content to write to the file
@@ -3353,10 +3344,7 @@ public static void writeLines(final File file, final Collection<?> lines, final
33533344
* Writes the {@code toString()} value of each item in a collection to
33543345
* the specified {@link File} line by line.
33553346
* The specified character encoding and the default line ending will be used.
3356-
* <p>
3357-
* NOTE: As from v1.3, the parent directories of the file will be created
3358-
* if they do not exist.
3359-
* </p>
3347+
* The parent directories of the file will be created if they do not exist.
33603348
*
33613349
* @param file the file to write to
33623350
* @param charsetName the name of the requested charset, {@code null} means platform default
@@ -3391,10 +3379,7 @@ public static void writeLines(final File file, final String charsetName, final C
33913379
* Writes the {@code toString()} value of each item in a collection to
33923380
* the specified {@link File} line by line.
33933381
* The specified character encoding and the line ending will be used.
3394-
* <p>
3395-
* NOTE: As from v1.3, the parent directories of the file will be created
3396-
* if they do not exist.
3397-
* </p>
3382+
* The parent directories of the file will be created if they do not exist.
33983383
*
33993384
* @param file the file to write to
34003385
* @param charsetName the name of the requested charset, {@code null} means platform default
@@ -3461,10 +3446,7 @@ public static void writeStringToFile(final File file, final String data, final b
34613446

34623447
/**
34633448
* Writes a String to a file creating the file if it does not exist.
3464-
* <p>
3465-
* NOTE: As from v1.3, the parent directories of the file will be created
3466-
* if they do not exist.
3467-
* </p>
3449+
* The parent directories of the file will be created if they do not exist.
34683450
*
34693451
* @param file the file to write
34703452
* @param data the content to write to the file
@@ -3478,7 +3460,8 @@ public static void writeStringToFile(final File file, final String data, final C
34783460
}
34793461

34803462
/**
3481-
* Writes a String to a file creating the file if it does not exist.
3463+
* Writes a String to a file, creating the file if it does not exist.
3464+
* The parent directories of the file are created if they do not exist.
34823465
*
34833466
* @param file the file to write
34843467
* @param data the content to write to the file
@@ -3495,11 +3478,8 @@ public static void writeStringToFile(final File file, final String data, final C
34953478
}
34963479

34973480
/**
3498-
* Writes a String to a file creating the file if it does not exist.
3499-
* <p>
3500-
* NOTE: As from v1.3, the parent directories of the file will be created
3501-
* if they do not exist.
3502-
* </p>
3481+
* Writes a String to a file, creating the file if it does not exist.
3482+
* The parent directories of the file are created if they do not exist.
35033483
*
35043484
* @param file the file to write
35053485
* @param data the content to write to the file
@@ -3512,16 +3492,16 @@ public static void writeStringToFile(final File file, final String data, final S
35123492
}
35133493

35143494
/**
3515-
* Writes a String to a file creating the file if it does not exist.
3495+
* Writes a String to a file, creating the file if it does not exist.
3496+
* The parent directories of the file are created if they do not exist.
35163497
*
35173498
* @param file the file to write
35183499
* @param data the content to write to the file
35193500
* @param charsetName the name of the requested charset, {@code null} means platform default
35203501
* @param append if {@code true}, then the String will be added to the
35213502
* end of the file rather than overwriting
35223503
* @throws IOException in case of an I/O error
3523-
* @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
3524-
* .UnsupportedEncodingException} in version 2.2 if the encoding is not supported by the VM
3504+
* @throws java.nio.charset.UnsupportedCharsetException if the encoding is not supported by the VM
35253505
* @since 2.1
35263506
*/
35273507
public static void writeStringToFile(final File file, final String data, final String charsetName, final boolean append) throws IOException {

0 commit comments

Comments
 (0)