Skip to content

Commit 4797d6b

Browse files
committed
Use SystemProperties instead of magic strings
1 parent 1b3b5b9 commit 4797d6b

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,16 @@ public abstract class JXPathContextFactory {
6969
*/
7070
private static String findFactory(final String property, final String defaultFactory) {
7171
// Use the factory ID system property first
72-
try {
73-
final String systemProp = System.getProperty(property);
74-
if (systemProp != null) {
75-
if (debug) {
76-
System.err.println("JXPath: found system property" + systemProp);
77-
}
78-
return systemProp;
72+
final String systemProp = SystemProperties.getProperty(property);
73+
if (systemProp != null) {
74+
if (debug) {
75+
System.err.println("JXPath: found system property" + systemProp);
7976
}
80-
} catch (final SecurityException ignore) { // NOPMD
81-
// Ignore
77+
return systemProp;
8278
}
8379
// try to read from $java.home/lib/xml.properties
8480
try {
85-
final Path javaHome = Paths.get(System.getProperty("java.home"));
81+
final Path javaHome = Paths.get(SystemProperties.getJavaHome());
8682
final Path configFile = javaHome.resolve(Paths.get("lib", "jxpath.properties"));
8783
if (Files.exists(configFile)) {
8884
final Properties props = new Properties();

src/main/java/org/apache/commons/jxpath/ri/parser/ParseException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
package org.apache.commons.jxpath.ri.parser;
2020

21+
import org.apache.commons.lang3.SystemProperties;
22+
2123
/**
2224
* This exception is thrown when parse errors are encountered. You can explicitly create objects of this exception type by calling the method
2325
* generateParseException in the generated parser.
@@ -52,7 +54,7 @@ public class ParseException extends Exception {
5254
/**
5355
* The end of line string for this machine.
5456
*/
55-
protected String eol = System.getProperty("line.separator", "\n");
57+
protected String eol = SystemProperties.getLineSeparator(() -> "\n");
5658

5759
/**
5860
* 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

0 commit comments

Comments
 (0)