Skip to content

Apache Lucene open-source search software

LUCENE-7135: work around security manager when checking for 32/64 bit JVM

Mike McCandless813b6855656e
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 5a6601b6048..385a9aecc23 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -110,6 +110,10 @@ Bug Fixes
* LUCENE-7429: AnalyzerWrapper can now modify the normalization chain too and
DelegatingAnalyzerWrapper does the right thing automatically. (Adrien Grand)
+* Lucene's check for 32 or 64 bit JVM now works around security
+ manager blocking access to some properties (Aaron Madlon-Kay via
+ Mike McCandless)
+
Improvements
* LUCENE-7439: FuzzyQuery now matches all terms within the specified
diff --git a/lucene/core/src/java/org/apache/lucene/util/Constants.java b/lucene/core/src/java/org/apache/lucene/util/Constants.java
index 7df0efca4c5..e6a96096616 100644
--- a/lucene/core/src/java/org/apache/lucene/util/Constants.java
+++ b/lucene/core/src/java/org/apache/lucene/util/Constants.java
@@ -68,15 +68,17 @@ public final class Constants {
JVM_MINOR_VERSION = 0;
}
boolean is64Bit = false;
- final String x = System.getProperty("sun.arch.data.model");
- if (x != null) {
- is64Bit = x.contains("64");
- } else {
- if (OS_ARCH != null && OS_ARCH.contains("64")) {
- is64Bit = true;
- } else {
- is64Bit = false;
+ String datamodel = null;
+ try {
+ datamodel = System.getProperty("sun.arch.data.model");
+ if (datamodel != null) {
+ is64Bit = datamodel.contains("64");
}
+ } catch (SecurityException ex) {}
+ if (datamodel == null && OS_ARCH != null && OS_ARCH.contains("64")) {
+ is64Bit = true;
+ } else {
+ is64Bit = false;
}
JRE_IS_64BIT = is64Bit;
}