This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 2a0718fc784753544e294f66a56a83eef7a0ea5f
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Oct 8 11:55:01 2023 -0400

    Sort members
---
 .../apache/commons/io/channels/FileChannels.java   | 14 +++----
 .../io/output/DeferredFileOutputStream.java        | 44 ++++++++++----------
 .../io/output/ThresholdingOutputStream.java        | 14 +++----
 .../java/org/apache/commons/io/FileUtilsTest.java  | 36 ++++++++--------
 .../java/org/apache/commons/io/IOUtilsTest.java    | 18 ++++----
 .../org/apache/commons/io/input/TailerTest.java    | 20 ++++-----
 .../commons/io/input/XmlStreamReaderTest.java      | 48 +++++++++++-----------
 .../io/jmh/PathUtilsContentEqualsBenchmark.java    | 14 +++----
 .../io/output/ThresholdingOutputStreamTest.java    |  8 ++--
 9 files changed, 108 insertions(+), 108 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/channels/FileChannels.java 
b/src/main/java/org/apache/commons/io/channels/FileChannels.java
index b6e2811e..468c85b4 100644
--- a/src/main/java/org/apache/commons/io/channels/FileChannels.java
+++ b/src/main/java/org/apache/commons/io/channels/FileChannels.java
@@ -31,13 +31,6 @@ import org.apache.commons.io.IOUtils;
  */
 public final class FileChannels {
 
-    /**
-     * Don't instantiate.
-     */
-    private FileChannels() {
-        // no-op
-    }
-
     /**
      * Tests if two RandomAccessFiles contents are equal.
      *
@@ -84,4 +77,11 @@ public final class FileChannels {
     private static long size(final FileChannel channel) throws IOException {
         return channel != null ? channel.size() : 0;
     }
+
+    /**
+     * Don't instantiate.
+     */
+    private FileChannels() {
+        // no-op
+    }
 }
diff --git 
a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java 
b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
index d4dc19e9..4a2b9fb2 100644
--- a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
@@ -264,28 +264,6 @@ public class DeferredFileOutputStream extends 
ThresholdingOutputStream {
         this.currentOutputStream = memoryOutputStream;
     }
 
-    /**
-     * Constructs an instance of this class which will trigger an event at the 
specified threshold, and save data either to a file beyond that point.
-     *
-     * @param threshold         The number of bytes at which to trigger an 
event.
-     * @param outputFile        The file to which data is saved beyond the 
threshold.
-     * @param prefix            Prefix to use for the temporary file.
-     * @param suffix            Suffix to use for the temporary file.
-     * @param directory         Temporary file directory.
-     * @param initialBufferSize The initial size of the in memory buffer.
-     * @throws IllegalArgumentException if initialBufferSize &lt; 0.
-     */
-    private DeferredFileOutputStream(final int threshold, final Path 
outputFile, final String prefix, final String suffix, final Path directory,
-            final int initialBufferSize) {
-        super(threshold);
-        this.outputPath = toPath(outputFile, null);
-        this.prefix = prefix;
-        this.suffix = suffix;
-        this.directory = toPath(directory, PathUtils::getTempDirectory);
-        this.memoryOutputStream = new 
ByteArrayOutputStream(checkBufferSize(initialBufferSize));
-        this.currentOutputStream = memoryOutputStream;
-    }
-
     /**
      * Constructs an instance of this class which will trigger an event at the 
specified threshold, and save data to a file beyond that point.
      *
@@ -316,6 +294,28 @@ public class DeferredFileOutputStream extends 
ThresholdingOutputStream {
         this(threshold, null, Objects.requireNonNull(prefix, "prefix"), 
suffix, directory, initialBufferSize);
     }
 
+    /**
+     * Constructs an instance of this class which will trigger an event at the 
specified threshold, and save data either to a file beyond that point.
+     *
+     * @param threshold         The number of bytes at which to trigger an 
event.
+     * @param outputFile        The file to which data is saved beyond the 
threshold.
+     * @param prefix            Prefix to use for the temporary file.
+     * @param suffix            Suffix to use for the temporary file.
+     * @param directory         Temporary file directory.
+     * @param initialBufferSize The initial size of the in memory buffer.
+     * @throws IllegalArgumentException if initialBufferSize &lt; 0.
+     */
+    private DeferredFileOutputStream(final int threshold, final Path 
outputFile, final String prefix, final String suffix, final Path directory,
+            final int initialBufferSize) {
+        super(threshold);
+        this.outputPath = toPath(outputFile, null);
+        this.prefix = prefix;
+        this.suffix = suffix;
+        this.directory = toPath(directory, PathUtils::getTempDirectory);
+        this.memoryOutputStream = new 
ByteArrayOutputStream(checkBufferSize(initialBufferSize));
+        this.currentOutputStream = memoryOutputStream;
+    }
+
     /**
      * Constructs an instance of this class which will trigger an event at the 
specified threshold, and save data to a temporary file beyond that point. The
      * initial buffer size will default to 32 bytes which is 
ByteArrayOutputStream's default buffer size.
diff --git 
a/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java 
b/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java
index 1d8a3a03..8102eb58 100644
--- a/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java
@@ -149,11 +149,10 @@ public class ThresholdingOutputStream extends 
OutputStream {
      *
      * @return The underlying output stream.
      * @throws IOException if an error occurs.
-     * @deprecated Use {@link #getOutputStream()}.
+     * @since 2.14.0
      */
-    @Deprecated
-    protected OutputStream getStream() throws IOException {
-        return getOutputStream();
+    protected OutputStream getOutputStream() throws IOException {
+        return outputStreamGetter.apply(this);
     }
 
     /**
@@ -162,10 +161,11 @@ public class ThresholdingOutputStream extends 
OutputStream {
      *
      * @return The underlying output stream.
      * @throws IOException if an error occurs.
-     * @since 2.14.0
+     * @deprecated Use {@link #getOutputStream()}.
      */
-    protected OutputStream getOutputStream() throws IOException {
-        return outputStreamGetter.apply(this);
+    @Deprecated
+    protected OutputStream getStream() throws IOException {
+        return getOutputStream();
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java 
b/src/test/java/org/apache/commons/io/FileUtilsTest.java
index b89d4124..62fb8f50 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -2445,6 +2445,24 @@ public class FileUtilsTest extends AbstractTempDirTest {
         assertThrows(IOException.class, () -> 
FileUtils.readFileToByteArray(file));
     }
 
+    @Test
+    public void testReadFileToString_Errors() {
+        assertThrows(NullPointerException.class, () -> 
FileUtils.readFileToString(null));
+        assertThrows(IOException.class, () -> FileUtils.readFileToString(new 
File("non-exsistent")));
+        assertThrows(IOException.class, () -> 
FileUtils.readFileToString(tempDirFile));
+        assertThrows(UnsupportedCharsetException.class, () -> 
FileUtils.readFileToString(tempDirFile, "unsupported-charset"));
+    }
+
+    @Test
+    @EnabledIf("isPosixFilePermissionsSupported")
+    public void testReadFileToString_IOExceptionOnPosixFileSystem() throws 
Exception {
+        final File file = TestUtils.newFile(tempDirFile, "cant-read.txt");
+        TestUtils.createFile(file, 100);
+        Files.setPosixFilePermissions(file.toPath(), 
PosixFilePermissions.fromString("---------"));
+
+        assertThrows(IOException.class, () -> 
FileUtils.readFileToString(file));
+    }
+
     @Test
     public void testReadFileToStringWithDefaultEncoding() throws Exception {
         final File file = new File(tempDirFile, "read.obj");
@@ -2464,24 +2482,6 @@ public class FileUtilsTest extends AbstractTempDirTest {
         assertEquals("Hello /u1234", data);
     }
 
-    @Test
-    public void testReadFileToString_Errors() {
-        assertThrows(NullPointerException.class, () -> 
FileUtils.readFileToString(null));
-        assertThrows(IOException.class, () -> FileUtils.readFileToString(new 
File("non-exsistent")));
-        assertThrows(IOException.class, () -> 
FileUtils.readFileToString(tempDirFile));
-        assertThrows(UnsupportedCharsetException.class, () -> 
FileUtils.readFileToString(tempDirFile, "unsupported-charset"));
-    }
-
-    @Test
-    @EnabledIf("isPosixFilePermissionsSupported")
-    public void testReadFileToString_IOExceptionOnPosixFileSystem() throws 
Exception {
-        final File file = TestUtils.newFile(tempDirFile, "cant-read.txt");
-        TestUtils.createFile(file, 100);
-        Files.setPosixFilePermissions(file.toPath(), 
PosixFilePermissions.fromString("---------"));
-
-        assertThrows(IOException.class, () -> 
FileUtils.readFileToString(file));
-    }
-
     @Test
     public void testReadLines() throws Exception {
         final File file = TestUtils.newFile(tempDirFile, "lines.txt");
diff --git a/src/test/java/org/apache/commons/io/IOUtilsTest.java 
b/src/test/java/org/apache/commons/io/IOUtilsTest.java
index 0a3e7d39..69a8b29e 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTest.java
@@ -1749,6 +1749,15 @@ public class IOUtilsTest {
         }
     }
 
+    @Test
+    public void testWriteLines() throws IOException {
+        final String[] data = {"The", "quick"};
+        final ByteArrayOutputStream out = new ByteArrayOutputStream();
+        IOUtils.writeLines(Arrays.asList(data), "\n", out, "UTF-16");
+        final String result = new String(out.toByteArray(), 
StandardCharsets.UTF_16);
+        assertEquals("The\nquick\n", result);
+    }
+
     @Test
     public void testWriteLittleString() throws IOException {
         final String data = "\uD83D";
@@ -1761,13 +1770,4 @@ public class IOUtilsTest {
         }
     }
 
-    @Test
-    public void testWriteLines() throws IOException {
-        final String[] data = {"The", "quick"};
-        final ByteArrayOutputStream out = new ByteArrayOutputStream();
-        IOUtils.writeLines(Arrays.asList(data), "\n", out, "UTF-16");
-        final String result = new String(out.toByteArray(), 
StandardCharsets.UTF_16);
-        assertEquals("The\nquick\n", result);
-    }
-
 }
diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java 
b/src/test/java/org/apache/commons/io/input/TailerTest.java
index f0e1f340..bc5cffd1 100644
--- a/src/test/java/org/apache/commons/io/input/TailerTest.java
+++ b/src/test/java/org/apache/commons/io/input/TailerTest.java
@@ -265,16 +265,6 @@ public class TailerTest {
         }
     }
 
-    @Test
-    public void testCreatorWithDelayAndFromStartWithReopen() throws Exception {
-        final File file = new File(temporaryFolder, 
"tailer-create-with-delay-and-from-start-with-reopen.txt");
-        createFile(file, 0);
-        final TestTailerListener listener = new TestTailerListener(1);
-        try (Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, 
false, false)) {
-            validateTailer(listener, file);
-        }
-    }
-
     @Test
     public void testCreateWithDelay() throws Exception {
         final File file = new File(temporaryFolder, 
"tailer-create-with-delay.txt");
@@ -325,6 +315,16 @@ public class TailerTest {
         }
     }
 
+    @Test
+    public void testCreatorWithDelayAndFromStartWithReopen() throws Exception {
+        final File file = new File(temporaryFolder, 
"tailer-create-with-delay-and-from-start-with-reopen.txt");
+        createFile(file, 0);
+        final TestTailerListener listener = new TestTailerListener(1);
+        try (Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, 
false, false)) {
+            validateTailer(listener, file);
+        }
+    }
+
     /*
      * Tests [IO-357][Tailer] InterruptedException while the thread is 
sleeping is silently ignored.
      */
diff --git a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java 
b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
index 4c9fc0ad..63d587a8 100644
--- a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
@@ -168,6 +168,14 @@ public class XmlStreamReaderTest {
         return new ByteArrayInputStream(baos.toByteArray());
     }
 
+    private void parseCharset(final String hdr, final String enc, final 
IOFunction<InputStream, XmlStreamReader> factory) throws Exception {
+        try (final InputStream stream = new 
ByteArrayInputStream(hdr.getBytes(StandardCharsets.UTF_8))) {
+            try (final XmlStreamReader xml = factory.apply(stream)) {
+                assertEquals(enc.toUpperCase(Locale.ROOT), xml.getEncoding(), 
enc);
+            }
+        }
+    }
+
     public void testAlternateDefaultEncoding(final String contentType, final 
String bomEnc, final String streamEnc, final String prologEnc,
             final String alternateEnc) throws Exception {
         try (InputStream is = getXmlInputStream(bomEnc, prologEnc == null ? 
XML1 : XML3, streamEnc, prologEnc);
@@ -282,6 +290,8 @@ public class XmlStreamReaderTest {
         assertThrows(NullPointerException.class, () -> new 
XmlStreamReader((URL) null));
     }
 
+    // XML Stream generator
+
     @Test
     public void testEncodingAttributeXML() throws Exception {
         try (InputStream is = new 
ByteArrayInputStream(ENCODING_ATTRIBUTE_XML.getBytes(StandardCharsets.UTF_8));
@@ -300,8 +310,6 @@ public class XmlStreamReaderTest {
         }
     }
 
-    // XML Stream generator
-
     @Test
     public void testHttp() throws Exception {
         // niallp 2010-10-06 - remove following 2 tests - I reinstated
@@ -437,6 +445,20 @@ public class XmlStreamReaderTest {
         }
     }
 
+    @ParameterizedTest(name = "{0}")
+    @MethodSource(CharsetsTest.AVAIL_CHARSETS)
+    public void testIO_815(final String csName) throws Exception {
+        final MessageFormat fmt = new MessageFormat("<?xml version=\"1.0\" 
encoding=''{0}''?>\n<root>text</root>");
+        final IOFunction<InputStream, XmlStreamReader> factoryCtor = 
XmlStreamReader::new;
+        final IOFunction<InputStream, XmlStreamReader> factoryBuilder = stream 
-> XmlStreamReader.builder().setInputStream(stream).get();
+        parseCharset(fmt.format(new Object[] { csName }), csName, factoryCtor);
+        parseCharset(fmt.format(new Object[] { csName }), csName, 
factoryBuilder);
+        for (final String alias : Charset.forName(csName).aliases()) {
+            parseCharset(fmt.format(new Object[] { alias }), alias, 
factoryCtor);
+            parseCharset(fmt.format(new Object[] { alias }), alias, 
factoryBuilder);
+        }
+    }
+
     // Turkish language has specific rules to convert dotted and dotless i 
character.
     @Test
     @DefaultLocale(language = "tr")
@@ -577,28 +599,6 @@ public class XmlStreamReaderTest {
         testRawNoBomValid(UTF_8);
     }
 
-    private void parseCharset(final String hdr, final String enc, final 
IOFunction<InputStream, XmlStreamReader> factory) throws Exception {
-        try (final InputStream stream = new 
ByteArrayInputStream(hdr.getBytes(StandardCharsets.UTF_8))) {
-            try (final XmlStreamReader xml = factory.apply(stream)) {
-                assertEquals(enc.toUpperCase(Locale.ROOT), xml.getEncoding(), 
enc);
-            }
-        }
-    }
-
-    @ParameterizedTest(name = "{0}")
-    @MethodSource(CharsetsTest.AVAIL_CHARSETS)
-    public void testIO_815(final String csName) throws Exception {
-        final MessageFormat fmt = new MessageFormat("<?xml version=\"1.0\" 
encoding=''{0}''?>\n<root>text</root>");
-        final IOFunction<InputStream, XmlStreamReader> factoryCtor = 
XmlStreamReader::new;
-        final IOFunction<InputStream, XmlStreamReader> factoryBuilder = stream 
-> XmlStreamReader.builder().setInputStream(stream).get();
-        parseCharset(fmt.format(new Object[] { csName }), csName, factoryCtor);
-        parseCharset(fmt.format(new Object[] { csName }), csName, 
factoryBuilder);
-        for (final String alias : Charset.forName(csName).aliases()) {
-            parseCharset(fmt.format(new Object[] { alias }), alias, 
factoryCtor);
-            parseCharset(fmt.format(new Object[] { alias }), alias, 
factoryBuilder);
-        }
-    }
-
     protected void testRawNoBomValid(final String encoding) throws Exception {
         InputStream is = getXmlInputStream("no-bom", XML1, encoding, encoding);
         XmlStreamReader xmlReader = new XmlStreamReader(is, false);
diff --git 
a/src/test/java/org/apache/commons/io/jmh/PathUtilsContentEqualsBenchmark.java 
b/src/test/java/org/apache/commons/io/jmh/PathUtilsContentEqualsBenchmark.java
index b45016ae..20e49e71 100644
--- 
a/src/test/java/org/apache/commons/io/jmh/PathUtilsContentEqualsBenchmark.java
+++ 
b/src/test/java/org/apache/commons/io/jmh/PathUtilsContentEqualsBenchmark.java
@@ -91,13 +91,6 @@ public class PathUtilsContentEqualsBenchmark {
         return res;
     }
 
-    @Benchmark
-    public boolean[] testProposal_contentEquals() throws IOException {
-        final boolean[] res = new boolean[1];
-        res[0] = newFileContentEquals(bigFile1, bigFile2);
-        return res;
-    }
-
     @Benchmark
     public void testCurrent_fileContentEquals_Blackhole(final Blackhole 
blackhole) throws IOException {
         for (int i = 0; i < 5; i++) {
@@ -107,6 +100,13 @@ public class PathUtilsContentEqualsBenchmark {
         }
     }
 
+    @Benchmark
+    public boolean[] testProposal_contentEquals() throws IOException {
+        final boolean[] res = new boolean[1];
+        res[0] = newFileContentEquals(bigFile1, bigFile2);
+        return res;
+    }
+
     @Benchmark
     public void testProposal_contentEquals_Blackhole(final Blackhole 
blackhole) throws IOException {
         for (int i = 0; i < 5; i++) {
diff --git 
a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java 
b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java
index dd1299e0..080a4927 100644
--- 
a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test;
 public class ThresholdingOutputStreamTest {
 
     @Test
-    public void testSetByteCount_Stream() throws Exception {
+    public void testSetByteCount_OutputStream() throws Exception {
         final AtomicBoolean reached = new AtomicBoolean(false);
         try (ThresholdingOutputStream tos = new ThresholdingOutputStream(3) {
             {
@@ -41,7 +41,7 @@ public class ThresholdingOutputStreamTest {
             }
 
             @Override
-            protected OutputStream getStream() throws IOException {
+            protected OutputStream getOutputStream() throws IOException {
                 return new ByteArrayOutputStream(4);
             }
 
@@ -58,7 +58,7 @@ public class ThresholdingOutputStreamTest {
     }
 
     @Test
-    public void testSetByteCount_OutputStream() throws Exception {
+    public void testSetByteCount_Stream() throws Exception {
         final AtomicBoolean reached = new AtomicBoolean(false);
         try (ThresholdingOutputStream tos = new ThresholdingOutputStream(3) {
             {
@@ -66,7 +66,7 @@ public class ThresholdingOutputStreamTest {
             }
 
             @Override
-            protected OutputStream getOutputStream() throws IOException {
+            protected OutputStream getStream() throws IOException {
                 return new ByteArrayOutputStream(4);
             }
 

Reply via email to