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


The following commit(s) were added to refs/heads/master by this push:
     new 8ed8dc2  [IO-677] FileSystem.getCurrent() does not return the correct 
enum.
8ed8dc2 is described below

commit 8ed8dc261f101d18f86a9f92b004d5381774fa1c
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Jul 27 20:04:19 2020 -0400

    [IO-677] FileSystem.getCurrent() does not return the correct enum.
---
 src/changes/changes.xml                                   |  5 ++++-
 src/main/java/org/apache/commons/io/FileSystem.java       |  4 +---
 .../java/org/apache/commons/io/FileSystemTestCase.java    | 15 +++++++++++++++
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5921d15..2fe0c12 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -63,7 +63,7 @@ The <action> type attribute can be add,update,fix,remove.
         CharSequenceReader.skip should return 0 instead of EOF on stream end 
#123.
       </action>
       <action dev="ggregory" type="fix" due-to="Rob Spoor">
-        Implement CharSequenceReader.ready #122.
+        Implement CharSequenceReader.ready() #122.
       </action>
       <action issue="IO-669" dev="ggregory" type="fix" due-to="XenoAmess, Gary 
Gregory">
         Fix code smells; fix typos #115.
@@ -80,6 +80,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action issue="IO-675" dev="ggregory" type="fix" due-to="Gary Gregory">
         InfiniteCircularInputStream throws a divide-by-zero exception when 
reading if its input buffer is size 0.
       </action>
+      <action issue="IO-677" dev="ggregory" type="fix" due-to="Gary Gregory">
+        FileSystem.getCurrent() does not return the correct enum.
+      </action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         maven-checkstyle-plugin 3.1.0 -> 3.1.1.
       </action>
diff --git a/src/main/java/org/apache/commons/io/FileSystem.java 
b/src/main/java/org/apache/commons/io/FileSystem.java
index 1c52935..f3e07a1 100644
--- a/src/main/java/org/apache/commons/io/FileSystem.java
+++ b/src/main/java/org/apache/commons/io/FileSystem.java
@@ -116,8 +116,6 @@ public enum FileSystem {
      */
     private static final boolean IS_OS_WINDOWS = 
getOsMatchesName(OS_NAME_WINDOWS_PREFIX);
 
-    private static final String OS_NAME = getSystemProperty("os.name");
-
     /**
      * Gets the current file system.
      *
@@ -144,7 +142,7 @@ public enum FileSystem {
      * @return true if matches, or false if not or can't determine
      */
     private static boolean getOsMatchesName(final String osNamePrefix) {
-        return isOsNameMatch(OS_NAME, osNamePrefix);
+        return isOsNameMatch(getSystemProperty("os.name"), osNamePrefix);
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/io/FileSystemTestCase.java 
b/src/test/java/org/apache/commons/io/FileSystemTestCase.java
index cdf83d5..6325cbf 100644
--- a/src/test/java/org/apache/commons/io/FileSystemTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileSystemTestCase.java
@@ -21,10 +21,25 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import org.apache.commons.lang3.SystemUtils;
 import org.junit.jupiter.api.Test;
 
 public class FileSystemTestCase {
 
+    
+    @Test
+    public void testGetCurrent() {
+        if (SystemUtils.IS_OS_WINDOWS) {
+            assertEquals(FileSystem.WINDOWS, FileSystem.getCurrent());
+        }
+        if (SystemUtils.IS_OS_LINUX) {
+            assertEquals(FileSystem.LINUX, FileSystem.getCurrent());
+        }
+        if (SystemUtils.IS_OS_MAC_OSX) {
+            assertEquals(FileSystem.MAC_OSX, FileSystem.getCurrent());
+        }
+    }
+
     @Test
     public void testSorted() {
         for (final FileSystem fs : FileSystem.values()) {

Reply via email to