Skip to content

Commit 4c39aa2

Browse files
committed
Add org.apache.commons.lang3.SystemUtils.IS_OS_NETWARE
I still see Java code that special case Netware...
1 parent 5e4050c commit 4c39aa2

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/changes/changes.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ The <action> type attribute can be add,update,fix,remove.
5959
<action type="fix" dev="ggregory" due-to="Hassan A Hashim">[javadoc] Fix Javadocs in ClassUtils #1410.</action>
6060
<action type="fix" dev="ggregory" due-to="mfg92">[javadoc] Fix @deprecated link for StringUtils#startsWithAny #1424.</action>
6161
<!-- ADD -->
62-
<action type="fix" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.lang3.ArrayUtils.SOFT_MAX_ARRAY_LENGTH.</action>
62+
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.lang3.ArrayUtils.SOFT_MAX_ARRAY_LENGTH.</action>
63+
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.lang3.SystemUtils.IS_OS_NETWARE.</action>
6364
<!-- UPDATE -->
6465
<action type="update" dev="ggregory" due-to="Gary Gregory">[test] Bump org.apache.commons:commons-text from 1.13.1 to 1.14.0.</action>
6566
</release>

src/main/java/org/apache/commons/lang3/SystemUtils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,22 @@ public class SystemUtils {
16401640
*/
16411641
public static final boolean IS_OS_NET_BSD = getOsNameMatches("NetBSD");
16421642

1643+
/**
1644+
* The constant {@code true} if this is Netware.
1645+
* <p>
1646+
* The result depends on the value of the {@link #OS_NAME} constant.
1647+
* </p>
1648+
* <p>
1649+
* The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1650+
* </p>
1651+
* <p>
1652+
* This value is initialized when the class is loaded.
1653+
* </p>
1654+
*
1655+
* @since 3.19.0
1656+
*/
1657+
public static final boolean IS_OS_NETWARE = getOsNameMatches("Netware");
1658+
16431659
/**
16441660
* The constant {@code true} if this is OS/2.
16451661
* <p>

src/test/java/org/apache/commons/lang3/SystemUtilsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,29 @@ void test_IS_OS() {
153153
assertFalse(SystemUtils.IS_OS_SOLARIS);
154154
assertFalse(SystemUtils.IS_OS_LINUX);
155155
assertFalse(SystemUtils.IS_OS_MAC_OSX);
156+
assertFalse(SystemUtils.IS_OS_NETWARE);
156157
} else if (osName.startsWith("Windows")) {
157158
assertTrue(SystemUtils.IS_OS_WINDOWS);
158159
assertFalse(SystemUtils.IS_OS_ANDROID);
159160
assertFalse(SystemUtils.IS_OS_UNIX);
161+
assertFalse(SystemUtils.IS_OS_NETWARE);
160162
} else if (osName.startsWith("Solaris")) {
161163
assertTrue(SystemUtils.IS_OS_SOLARIS);
162164
assertTrue(SystemUtils.IS_OS_UNIX);
163165
assertFalse(SystemUtils.IS_OS_ANDROID);
164166
assertFalse(SystemUtils.IS_OS_WINDOWS);
167+
assertFalse(SystemUtils.IS_OS_NETWARE);
165168
} else if (osName.toLowerCase(Locale.ENGLISH).startsWith("linux")) {
166169
assertTrue(SystemUtils.IS_OS_LINUX);
167170
assertTrue(SystemUtils.IS_OS_UNIX);
168171
assertFalse(SystemUtils.IS_OS_WINDOWS);
172+
assertFalse(SystemUtils.IS_OS_NETWARE);
169173
} else if (osName.startsWith("Mac OS X")) {
170174
assertTrue(SystemUtils.IS_OS_MAC_OSX);
171175
assertTrue(SystemUtils.IS_OS_UNIX);
172176
assertFalse(SystemUtils.IS_OS_ANDROID);
173177
assertFalse(SystemUtils.IS_OS_WINDOWS);
178+
assertFalse(SystemUtils.IS_OS_NETWARE);
174179
// @formatter:off
175180
final boolean[] macOsValues = {
176181
SystemUtils.IS_OS_MAC_OSX_BIG_SUR,
@@ -204,16 +209,19 @@ void test_IS_OS() {
204209
assertFalse(SystemUtils.IS_OS_UNIX);
205210
assertFalse(SystemUtils.IS_OS_ANDROID);
206211
assertFalse(SystemUtils.IS_OS_WINDOWS);
212+
assertFalse(SystemUtils.IS_OS_NETWARE);
207213
} else if (osName.startsWith("SunOS")) {
208214
assertTrue(SystemUtils.IS_OS_SUN_OS);
209215
assertTrue(SystemUtils.IS_OS_UNIX);
210216
assertFalse(SystemUtils.IS_OS_ANDROID);
211217
assertFalse(SystemUtils.IS_OS_WINDOWS);
218+
assertFalse(SystemUtils.IS_OS_NETWARE);
212219
} else if (osName.startsWith("FreeBSD")) {
213220
assertTrue(SystemUtils.IS_OS_FREE_BSD);
214221
assertTrue(SystemUtils.IS_OS_UNIX);
215222
assertFalse(SystemUtils.IS_OS_ANDROID);
216223
assertFalse(SystemUtils.IS_OS_WINDOWS);
224+
assertFalse(SystemUtils.IS_OS_NETWARE);
217225
} else {
218226
System.err.println("Can't test IS_OS_ value: " + osName);
219227
}

0 commit comments

Comments
 (0)