You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/09/27 13:24:47 UTC

[commons-io] branch master updated (ea11270 -> d97a7c4)

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

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


    from ea11270  Remove old inline comment.
     new c5e0254  PathUtils.setReadOnly(Path, boolean, LinkOption...) readOnly argument is always assumed true on POSIX.
     new d97a7c4  Javadoc.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |   3 +
 .../java/org/apache/commons/io/file/PathUtils.java |  17 ++-
 .../commons/io/input/CharSequenceInputStream.java  | 154 ++++++++++-----------
 .../commons/io/file/PathUtilsDeleteFileTest.java   |  72 ++++++++--
 4 files changed, 152 insertions(+), 94 deletions(-)

[commons-io] 02/02: Javadoc.

Posted by gg...@apache.org.
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 d97a7c4cc12bcb413140b62508b6238b4920fc5c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 27 09:24:44 2021 -0400

    Javadoc.
    
    Better internal names.
    Format tweaks.
---
 .../commons/io/input/CharSequenceInputStream.java  | 154 ++++++++++-----------
 1 file changed, 75 insertions(+), 79 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java b/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java
index da45fa1..4c30c7e 100644
--- a/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java
@@ -31,8 +31,7 @@ import java.nio.charset.CodingErrorAction;
 import java.util.Objects;
 
 /**
- * {@link InputStream} implementation that can read from String, StringBuffer,
- * StringBuilder or CharBuffer.
+ * Implements an {@link InputStream} to read from String, StringBuffer, StringBuilder or CharBuffer.
  * <p>
  * <strong>Note:</strong> Supports {@link #mark(int)} and {@link #reset()}.
  * </p>
@@ -46,31 +45,30 @@ public class CharSequenceInputStream extends InputStream {
     private static final int NO_MARK = -1;
 
     private final CharsetEncoder charsetEncoder;
-    private final CharBuffer cbuf;
-    private final ByteBuffer bbuf;
+    private final CharBuffer cBuf;
+    private final ByteBuffer bBuf;
 
-    private int mark_cbuf; // position in cbuf
-    private int mark_bbuf; // position in bbuf
+    private int cBufMark; // position in cBuf
+    private int bBufMark; // position in bBuf
 
     /**
-     * Constructor, calls {@link #CharSequenceInputStream(CharSequence, Charset, int)}
-     * with a buffer size of 2048.
+     * Constructs a new instance with a buffer size of 2048.
      *
-     * @param cs the input character sequence
-     * @param charset the character set name to use
-     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character
+     * @param cs the input character sequence.
+     * @param charset the character set name to use.
+     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character.
      */
     public CharSequenceInputStream(final CharSequence cs, final Charset charset) {
         this(cs, charset, BUFFER_SIZE);
     }
 
     /**
-     * Constructor.
+     * Constructs a new instance.
      *
-     * @param cs the input character sequence
-     * @param charset the character set name to use
+     * @param cs the input character sequence.
+     * @param charset the character set name to use.
      * @param bufferSize the buffer size to use.
-     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character
+     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character.
      */
     public CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize) {
         // @formatter:off
@@ -79,32 +77,31 @@ public class CharSequenceInputStream extends InputStream {
             .onUnmappableCharacter(CodingErrorAction.REPLACE);
         // @formatter:on
         // Ensure that buffer is long enough to hold a complete character
-        this.bbuf = ByteBuffer.allocate(ReaderInputStream.checkMinBufferSize(charsetEncoder, bufferSize));
-        this.bbuf.flip();
-        this.cbuf = CharBuffer.wrap(cs);
-        this.mark_cbuf = NO_MARK;
-        this.mark_bbuf = NO_MARK;
+        this.bBuf = ByteBuffer.allocate(ReaderInputStream.checkMinBufferSize(charsetEncoder, bufferSize));
+        this.bBuf.flip();
+        this.cBuf = CharBuffer.wrap(cs);
+        this.cBufMark = NO_MARK;
+        this.bBufMark = NO_MARK;
     }
 
     /**
-     * Constructor, calls {@link #CharSequenceInputStream(CharSequence, String, int)}
-     * with a buffer size of 2048.
+     * Constructs a new instance with a buffer size of 2048.
      *
-     * @param cs the input character sequence
-     * @param charset the character set name to use
-     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character
+     * @param cs the input character sequence.
+     * @param charset the character set name to use.
+     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character.
      */
     public CharSequenceInputStream(final CharSequence cs, final String charset) {
         this(cs, charset, BUFFER_SIZE);
     }
 
     /**
-     * Constructor, calls {@link #CharSequenceInputStream(CharSequence, Charset, int)}.
+     * Constructs a new instance.
      *
-     * @param cs the input character sequence
-     * @param charset the character set name to use
+     * @param cs the input character sequence.
+     * @param charset the character set name to use.
      * @param bufferSize the buffer size to use.
-     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character
+     * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character.
      */
     public CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize) {
         this(cs, Charset.forName(charset), bufferSize);
@@ -114,7 +111,7 @@ public class CharSequenceInputStream extends InputStream {
      * Return an estimate of the number of bytes remaining in the byte stream.
      * @return the count of bytes that can be read without blocking (or returning EOF).
      *
-     * @throws IOException if an error occurs (probably not possible)
+     * @throws IOException if an error occurs (probably not possible).
      */
     @Override
     public int available() throws IOException {
@@ -122,7 +119,7 @@ public class CharSequenceInputStream extends InputStream {
         // per character, we can add the two to get a better estimate (e.g. if bbuf is empty)
         // Note that the previous implementation (2.4) could return zero even though there were
         // encoded bytes still available.
-        return this.bbuf.remaining() + this.cbuf.remaining();
+        return this.bBuf.remaining() + this.cBuf.remaining();
     }
 
     @Override
@@ -134,27 +131,27 @@ public class CharSequenceInputStream extends InputStream {
      * Fills the byte output buffer from the input char buffer.
      *
      * @throws CharacterCodingException
-     *             an error encoding data
+     *             an error encoding data.
      */
     private void fillBuffer() throws CharacterCodingException {
-        this.bbuf.compact();
-        final CoderResult result = this.charsetEncoder.encode(this.cbuf, this.bbuf, true);
+        this.bBuf.compact();
+        final CoderResult result = this.charsetEncoder.encode(this.cBuf, this.bBuf, true);
         if (result.isError()) {
             result.throwException();
         }
-        this.bbuf.flip();
+        this.bBuf.flip();
     }
 
     /**
      * {@inheritDoc}
-     * @param readlimit max read limit (ignored)
+     * @param readlimit max read limit (ignored).
      */
     @Override
     public synchronized void mark(final int readlimit) {
-        this.mark_cbuf = this.cbuf.position();
-        this.mark_bbuf = this.bbuf.position();
-        this.cbuf.mark();
-        this.bbuf.mark();
+        this.cBufMark = this.cBuf.position();
+        this.bBufMark = this.bBuf.position();
+        this.cBuf.mark();
+        this.bBuf.mark();
         // It would be nice to be able to use mark & reset on the cbuf and bbuf;
         // however the bbuf is re-used so that won't work
     }
@@ -167,11 +164,11 @@ public class CharSequenceInputStream extends InputStream {
     @Override
     public int read() throws IOException {
         for (;;) {
-            if (this.bbuf.hasRemaining()) {
-                return this.bbuf.get() & 0xFF;
+            if (this.bBuf.hasRemaining()) {
+                return this.bBuf.get() & 0xFF;
             }
             fillBuffer();
-            if (!this.bbuf.hasRemaining() && !this.cbuf.hasRemaining()) {
+            if (!this.bBuf.hasRemaining() && !this.cBuf.hasRemaining()) {
                 return EOF;
             }
         }
@@ -186,74 +183,73 @@ public class CharSequenceInputStream extends InputStream {
     public int read(final byte[] array, int off, int len) throws IOException {
         Objects.requireNonNull(array, "array");
         if (len < 0 || (off + len) > array.length) {
-            throw new IndexOutOfBoundsException("Array Size=" + array.length +
-                    ", offset=" + off + ", length=" + len);
+            throw new IndexOutOfBoundsException("Array Size=" + array.length + ", offset=" + off + ", length=" + len);
         }
         if (len == 0) {
             return 0; // must return 0 for zero length read
         }
-        if (!this.bbuf.hasRemaining() && !this.cbuf.hasRemaining()) {
+        if (!this.bBuf.hasRemaining() && !this.cBuf.hasRemaining()) {
             return EOF;
         }
         int bytesRead = 0;
         while (len > 0) {
-            if (this.bbuf.hasRemaining()) {
-                final int chunk = Math.min(this.bbuf.remaining(), len);
-                this.bbuf.get(array, off, chunk);
+            if (this.bBuf.hasRemaining()) {
+                final int chunk = Math.min(this.bBuf.remaining(), len);
+                this.bBuf.get(array, off, chunk);
                 off += chunk;
                 len -= chunk;
                 bytesRead += chunk;
             } else {
                 fillBuffer();
-                if (!this.bbuf.hasRemaining() && !this.cbuf.hasRemaining()) {
+                if (!this.bBuf.hasRemaining() && !this.cBuf.hasRemaining()) {
                     break;
                 }
             }
         }
-        return bytesRead == 0 && !this.cbuf.hasRemaining() ? EOF : bytesRead;
+        return bytesRead == 0 && !this.cBuf.hasRemaining() ? EOF : bytesRead;
     }
 
     @Override
     public synchronized void reset() throws IOException {
-        /*
-         * This is not the most efficient implementation, as it re-encodes from the beginning.
-         *
-         * Since the bbuf is re-used, in general it's necessary to re-encode the data.
-         *
-         * It should be possible to apply some optimisations however:
-         * + use mark/reset on the cbuf and bbuf. This would only work if the buffer had not been (re)filled since
-         * the mark. The code would have to catch InvalidMarkException - does not seem possible to check if mark is
-         * valid otherwise. + Try saving the state of the cbuf before each fillBuffer; it might be possible to
-         * restart from there.
-         */
-        if (this.mark_cbuf != NO_MARK) {
+        //
+        // This is not the most efficient implementation, as it re-encodes from the beginning.
+        //
+        // Since the bbuf is re-used, in general it's necessary to re-encode the data.
+        //
+        // It should be possible to apply some optimisations however:
+        // + use mark/reset on the cbuf and bbuf. This would only work if the buffer had not been (re)filled since
+        // the mark. The code would have to catch InvalidMarkException - does not seem possible to check if mark is
+        // valid otherwise. + Try saving the state of the cbuf before each fillBuffer; it might be possible to
+        // restart from there.
+        //
+        if (this.cBufMark != NO_MARK) {
             // if cbuf is at 0, we have not started reading anything, so skip re-encoding
-            if (this.cbuf.position() != 0) {
+            if (this.cBuf.position() != 0) {
                 this.charsetEncoder.reset();
-                this.cbuf.rewind();
-                this.bbuf.rewind();
-                this.bbuf.limit(0); // rewind does not clear the buffer
-                while(this.cbuf.position() < this.mark_cbuf) {
-                    this.bbuf.rewind(); // empty the buffer (we only refill when empty during normal processing)
-                    this.bbuf.limit(0);
+                this.cBuf.rewind();
+                this.bBuf.rewind();
+                this.bBuf.limit(0); // rewind does not clear the buffer
+                while(this.cBuf.position() < this.cBufMark) {
+                    this.bBuf.rewind(); // empty the buffer (we only refill when empty during normal processing)
+                    this.bBuf.limit(0);
                     fillBuffer();
                 }
             }
-            if (this.cbuf.position() != this.mark_cbuf) {
-                throw new IllegalStateException("Unexpected CharBuffer position: actual=" + cbuf.position() + " " +
-                        "expected=" + this.mark_cbuf);
+            if (this.cBuf.position() != this.cBufMark) {
+                throw new IllegalStateException("Unexpected CharBuffer position: actual=" + cBuf.position() + " " +
+                        "expected=" + this.cBufMark);
             }
-            this.bbuf.position(this.mark_bbuf);
-            this.mark_cbuf = NO_MARK;
-            this.mark_bbuf = NO_MARK;
+            this.bBuf.position(this.bBufMark);
+            this.cBufMark = NO_MARK;
+            this.bBufMark = NO_MARK;
         }
     }
 
     @Override
     public long skip(long n) throws IOException {
-        /*
-         * This could be made more efficient by using position to skip within the current buffer.
-         */
+        //
+        // This could be made more efficient by using position to skip within the current buffer.
+        //
         long skipped = 0;
         while (n > 0 && available() > 0) {
             this.read();

[commons-io] 01/02: PathUtils.setReadOnly(Path, boolean, LinkOption...) readOnly argument is always assumed true on POSIX.

Posted by gg...@apache.org.
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 c5e0254d88863d6e0808269a5e9bd3bd98e225ac
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 27 09:24:24 2021 -0400

    PathUtils.setReadOnly(Path, boolean, LinkOption...) readOnly argument is
    always assumed true on POSIX.
---
 src/changes/changes.xml                            |  3 +
 .../java/org/apache/commons/io/file/PathUtils.java | 17 ++---
 .../commons/io/file/PathUtilsDeleteFileTest.java   | 72 +++++++++++++++++++---
 3 files changed, 77 insertions(+), 15 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 971ff45..5fbe961 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -104,6 +104,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action issue="IO-638" dev="ggregory" type="fix" due-to="Gary Gregory">
         PathUtils.setReadOnly(Path, boolean, LinkOption...) should add READ_* file attributes when using POSIX.
       </action>
+      <action issue="IO-638" dev="ggregory" type="fix" due-to="Gary Gregory">
+        PathUtils.setReadOnly(Path, boolean, LinkOption...) readOnly argument is always assumed true on POSIX.
+      </action>
       <!-- ADD -->
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add BrokenReader.INSTANCE.
diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java
index 06131a2..f1bc728 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -1154,27 +1154,30 @@ public final class PathUtils {
         final List<Exception> causeList = new ArrayList<>(2);
         final DosFileAttributeView fileAttributeView = Files.getFileAttributeView(path, DosFileAttributeView.class, linkOptions);
         if (fileAttributeView != null) {
+            // Windows 10
             try {
                 fileAttributeView.setReadOnly(readOnly);
                 return path;
             } catch (final IOException e) {
-                // ignore for now, retry with PosixFileAttributeView
+                // Remember and retry with PosixFileAttributeView
                 causeList.add(e);
             }
         }
         final PosixFileAttributeView posixFileAttributeView = Files.getFileAttributeView(path, PosixFileAttributeView.class, linkOptions);
         if (posixFileAttributeView != null) {
-            // Works on Windows but not on Ubuntu:
-            // Files.setAttribute(path, "unix:readonly", readOnly, options);
-            // java.lang.IllegalArgumentException: 'unix:readonly' not recognized
+            // Not Windows 10
             final PosixFileAttributes readAttributes = posixFileAttributeView.readAttributes();
             final Set<PosixFilePermission> permissions = readAttributes.permissions();
             permissions.add(PosixFilePermission.OWNER_READ);
             permissions.add(PosixFilePermission.GROUP_READ);
             permissions.add(PosixFilePermission.OTHERS_READ);
-            permissions.remove(PosixFilePermission.OWNER_WRITE);
-            permissions.remove(PosixFilePermission.GROUP_WRITE);
-            permissions.remove(PosixFilePermission.OTHERS_WRITE);
+            List<PosixFilePermission> writePermissions = Arrays.asList(PosixFilePermission.OWNER_WRITE, PosixFilePermission.GROUP_WRITE,
+                PosixFilePermission.OTHERS_WRITE);
+            if (readOnly) {
+                permissions.removeAll(writePermissions);
+            } else {
+                permissions.addAll(writePermissions);
+            }
             try {
                 return Files.setPosixFilePermissions(path, permissions);
             } catch (final IOException e) {
diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java
index badc727..06505de 100644
--- a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java
+++ b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java
@@ -18,17 +18,23 @@
 package org.apache.commons.io.file;
 
 import static org.apache.commons.io.file.CounterAssertions.assertCounts;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assumptions.assumeFalse;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.LinkOption;
 import java.nio.file.NoSuchFileException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.nio.file.attribute.DosFileAttributeView;
+import java.nio.file.attribute.PosixFileAttributeView;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.Set;
 
 import org.apache.commons.io.file.Counters.PathCounters;
 import org.apache.commons.lang3.SystemUtils;
@@ -79,8 +85,7 @@ public class PathUtilsDeleteFileTest {
     @Test
     public void testDeleteFileDirectory1FileSize0() throws IOException {
         final String fileName = "file-size-0.bin";
-        PathUtils.copyFileToDirectory(
-                Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-0/" + fileName), tempDir);
+        PathUtils.copyFileToDirectory(Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-0/" + fileName), tempDir);
         assertCounts(0, 1, 0, PathUtils.deleteFile(tempDir.resolve(fileName)));
         // This will throw if not empty.
         Files.deleteIfExists(tempDir);
@@ -92,8 +97,7 @@ public class PathUtilsDeleteFileTest {
     @Test
     public void testDeleteFileDirectory1FileSize1() throws IOException {
         final String fileName = "file-size-1.bin";
-        PathUtils.copyFileToDirectory(
-                Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-1/" + fileName), tempDir);
+        PathUtils.copyFileToDirectory(Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-1/" + fileName), tempDir);
         assertCounts(0, 1, 1, PathUtils.deleteFile(tempDir.resolve(fileName)));
         // This will throw if not empty.
         Files.deleteIfExists(tempDir);
@@ -129,8 +133,7 @@ public class PathUtilsDeleteFileTest {
     @Test
     public void testDeleteReadOnlyFileDirectory1FileSize1() throws IOException {
         final String fileName = "file-size-1.bin";
-        PathUtils.copyFileToDirectory(
-            Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-1/" + fileName), tempDir);
+        PathUtils.copyFileToDirectory(Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-1/" + fileName), tempDir);
         final Path resolved = tempDir.resolve(fileName);
         PathUtils.setReadOnly(resolved, true);
         if (SystemUtils.IS_OS_WINDOWS) {
@@ -143,14 +146,67 @@ public class PathUtilsDeleteFileTest {
         Files.deleteIfExists(tempDir);
     }
 
+    @Test
+    public void testSetReadOnlyFile() throws IOException {
+        final Path resolved = tempDir.resolve("testSetReadOnlyFile.txt");
+
+        // TEMP HACK
+        assertTrue(Files.getFileAttributeView(resolved, DosFileAttributeView.class) != null);
+        assertTrue(Files.getFileAttributeView(resolved, PosixFileAttributeView.class) == null);
+
+        PathUtils.writeString(resolved, "test", StandardCharsets.UTF_8);
+        final boolean readable = Files.isReadable(resolved);
+        final boolean writable = Files.isWritable(resolved);
+        final boolean regularFile = Files.isRegularFile(resolved);
+        final boolean executable = Files.isExecutable(resolved);
+        final boolean hidden = Files.isHidden(resolved);
+        final boolean directory = Files.isDirectory(resolved);
+        final boolean symbolicLink = Files.isSymbolicLink(resolved);
+        // Sanity checks
+        assertTrue(readable);
+        assertTrue(writable);
+        // Test A
+        PathUtils.setReadOnly(resolved, false);
+        assertEquals(true, Files.isReadable(resolved));
+        assertEquals(true, Files.isWritable(resolved));
+        assertEquals(regularFile, Files.isReadable(resolved));
+        assertEquals(executable, Files.isExecutable(resolved));
+        assertEquals(hidden, Files.isHidden(resolved));
+        assertEquals(directory, Files.isDirectory(resolved));
+        assertEquals(symbolicLink, Files.isSymbolicLink(resolved));
+        // Test B
+        PathUtils.setReadOnly(resolved, true);
+        assertEquals(true, Files.isReadable(resolved));
+        assertEquals(false, Files.isWritable(resolved));
+        final DosFileAttributeView dosFileAttributeView = Files.getFileAttributeView(resolved, DosFileAttributeView.class);
+        if (dosFileAttributeView != null) {
+            assertTrue(dosFileAttributeView.readAttributes().isReadOnly());
+        }
+        final PosixFileAttributeView posixFileAttributeView = Files.getFileAttributeView(resolved, PosixFileAttributeView.class);
+        if (posixFileAttributeView != null) {
+            // Not Windows
+            final Set<PosixFilePermission> permissions = posixFileAttributeView.readAttributes().permissions();
+            assertFalse(permissions.contains(PosixFilePermission.GROUP_WRITE), () -> permissions.toString());
+            assertFalse(permissions.contains(PosixFilePermission.OTHERS_WRITE), () -> permissions.toString());
+            assertFalse(permissions.contains(PosixFilePermission.OWNER_WRITE), () -> permissions.toString());
+        }
+        assertEquals(regularFile, Files.isReadable(resolved));
+        assertEquals(executable, Files.isExecutable(resolved));
+        assertEquals(hidden, Files.isHidden(resolved));
+        assertEquals(directory, Files.isDirectory(resolved));
+        assertEquals(symbolicLink, Files.isSymbolicLink(resolved));
+        //
+        PathUtils.setReadOnly(resolved, false);
+        PathUtils.deleteFile(resolved);
+    }
+
     /**
      * Tests a directory with one file of size 1.
      */
     @Test
     public void testSetReadOnlyFileDirectory1FileSize1() throws IOException {
         final String fileName = "file-size-1.bin";
-        PathUtils.copyFileToDirectory(
-            Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-1/" + fileName), tempDir);
+        PathUtils.copyFileToDirectory(Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-1/" + fileName), tempDir);
         final Path resolved = tempDir.resolve(fileName);
         PathUtils.setReadOnly(resolved, true);
         if (SystemUtils.IS_OS_WINDOWS) {