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 2024/05/01 17:49:49 UTC

(commons-compress) branch master updated: Use SystemProperties instead of a magic string lookup

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-compress.git


The following commit(s) were added to refs/heads/master by this push:
     new 09031c918 Use SystemProperties instead of a magic string lookup
09031c918 is described below

commit 09031c918e046961bc6186fb853c5d424079daf1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed May 1 13:49:44 2024 -0400

    Use SystemProperties instead of a magic string lookup
---
 .../org/apache/commons/compress/archivers/tar/TarArchiveEntry.java     | 3 ++-
 .../org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index f64474199..1b4f8deac 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -53,6 +53,7 @@ import org.apache.commons.compress.utils.IOUtils;
 import org.apache.commons.compress.utils.ParsingUtils;
 import org.apache.commons.compress.utils.TimeUtils;
 import org.apache.commons.io.file.attribute.FileTimes;
+import org.apache.commons.lang3.SystemProperties;
 
 /**
  * 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 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
      */
     private static String normalizeFileName(String fileName, final boolean preserveAbsolutePath) {
         if (!preserveAbsolutePath) {
-            final String property = System.getProperty("os.name");
+            final String property = SystemProperties.getOsName();
             if (property != null) {
                 final String osName = property.toLowerCase(Locale.ROOT);
 
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
index ba9d0998d..65f9a3af0 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
@@ -44,12 +44,13 @@ import java.util.Random;
 
 import org.apache.commons.compress.AbstractTest;
 import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
+import org.apache.commons.lang3.SystemProperties;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.EnabledOnOs;
 
 public class TarArchiveEntryTest implements TarConstants {
 
-    private static final String OS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
+    private static final String OS = SystemProperties.getOsName().toLowerCase(Locale.ROOT);
     private static final String ROOT = OS.startsWith("windows") || OS.startsWith("netware") ? "C:\\" : "/";
 
     private void assertGnuMagic(final TarArchiveEntry t) {