Skip to content

Commit 09031c9

Browse files
committed
Use SystemProperties instead of a magic string lookup
1 parent f30c19e commit 09031c9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.apache.commons.compress.utils.ParsingUtils;
5454
import org.apache.commons.compress.utils.TimeUtils;
5555
import org.apache.commons.io.file.attribute.FileTimes;
56+
import org.apache.commons.lang3.SystemProperties;
5657

5758
/**
5859
* This class represents an entry in a Tar archive. It consists of the entry's header, as well as the entry's File. Entries can be instantiated in one of three
@@ -227,7 +228,7 @@ private static FileTime fileTimeFromOptionalSeconds(final long seconds) {
227228
*/
228229
private static String normalizeFileName(String fileName, final boolean preserveAbsolutePath) {
229230
if (!preserveAbsolutePath) {
230-
final String property = System.getProperty("os.name");
231+
final String property = SystemProperties.getOsName();
231232
if (property != null) {
232233
final String osName = property.toLowerCase(Locale.ROOT);
233234

src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@
4444

4545
import org.apache.commons.compress.AbstractTest;
4646
import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
47+
import org.apache.commons.lang3.SystemProperties;
4748
import org.junit.jupiter.api.Test;
4849
import org.junit.jupiter.api.condition.EnabledOnOs;
4950

5051
public class TarArchiveEntryTest implements TarConstants {
5152

52-
private static final String OS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
53+
private static final String OS = SystemProperties.getOsName().toLowerCase(Locale.ROOT);
5354
private static final String ROOT = OS.startsWith("windows") || OS.startsWith("netware") ? "C:\\" : "/";
5455

5556
private void assertGnuMagic(final TarArchiveEntry t) {

0 commit comments

Comments
 (0)