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


The following commit(s) were added to refs/heads/master by this push:
     new 4797d6b  Use SystemProperties instead of magic strings
4797d6b is described below

commit 4797d6bdde9640e01513dddc0e3b488bfca84edb
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sun Jul 20 15:12:27 2025 -0400

    Use SystemProperties instead of magic strings
---
 .../org/apache/commons/jxpath/JXPathContextFactory.java  | 16 ++++++----------
 .../apache/commons/jxpath/ri/parser/ParseException.java  |  4 +++-
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java 
b/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java
index 8b3ab82..69db0f1 100644
--- a/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java
+++ b/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java
@@ -69,20 +69,16 @@ public abstract class JXPathContextFactory {
      */
     private static String findFactory(final String property, final String 
defaultFactory) {
         // Use the factory ID system property first
-        try {
-            final String systemProp = System.getProperty(property);
-            if (systemProp != null) {
-                if (debug) {
-                    System.err.println("JXPath: found system property" + 
systemProp);
-                }
-                return systemProp;
+        final String systemProp = SystemProperties.getProperty(property);
+        if (systemProp != null) {
+            if (debug) {
+                System.err.println("JXPath: found system property" + 
systemProp);
             }
-        } catch (final SecurityException ignore) { // NOPMD
-            // Ignore
+            return systemProp;
         }
         // try to read from $java.home/lib/xml.properties
         try {
-            final Path javaHome = Paths.get(System.getProperty("java.home"));
+            final Path javaHome = Paths.get(SystemProperties.getJavaHome());
             final Path configFile = javaHome.resolve(Paths.get("lib", 
"jxpath.properties"));
             if (Files.exists(configFile)) {
                 final Properties props = new Properties();
diff --git 
a/src/main/java/org/apache/commons/jxpath/ri/parser/ParseException.java 
b/src/main/java/org/apache/commons/jxpath/ri/parser/ParseException.java
index d6d875f..9c53449 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/parser/ParseException.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/parser/ParseException.java
@@ -18,6 +18,8 @@
 
 package org.apache.commons.jxpath.ri.parser;
 
+import org.apache.commons.lang3.SystemProperties;
+
 /**
  * This exception is thrown when parse errors are encountered. You can 
explicitly create objects of this exception type by calling the method
  * generateParseException in the generated parser.
@@ -52,7 +54,7 @@ public class ParseException extends Exception {
     /**
      * The end of line string for this machine.
      */
-    protected String eol = System.getProperty("line.separator", "\n");
+    protected String eol = SystemProperties.getLineSeparator(() -> "\n");
 
     /**
      * The following constructors are for use by you for whatever purpose you 
can think of. Constructing the exception in this manner makes the exception 
behave

Reply via email to