FileSystem.getCurrent() does not return the correct enum.
MODIFY
src/changes/changes.xml
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>

MODIFY
src/main/java/org/apache/commons/io/FileSystem.java
src/main/java/org/apache/commons/io/FileSystem.java
*/
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 static FileSystem getCurrent() {
* @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);
}
/**

MODIFY
src/test/java/org/apache/commons/io/FileSystemTestCase.java
src/test/java/org/apache/commons/io/FileSystemTestCase.java
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()) {

[IO-677] FileSystem.getCurrent() does not return the correct enum.