Make JNA calls optional
The introduction of max number of processes and max size virtual memory checks inadvertently made JNA non-optional on OS X and Linux. This commit wraps these calls in a check to see if JNA is available so that JNA remains optional. Closes #17492
This commit is contained in:
parent
410147c754
commit
e85535724e
|
@ -133,9 +133,8 @@ final class Bootstrap {
|
||||||
// we've already logged this.
|
// we've already logged this.
|
||||||
}
|
}
|
||||||
|
|
||||||
JNANatives.trySetMaxNumberOfThreads();
|
Natives.trySetMaxNumberOfThreads();
|
||||||
|
Natives.trySetMaxSizeVirtualMemory();
|
||||||
JNANatives.trySetMaxSizeVirtualMemory();
|
|
||||||
|
|
||||||
// init lucene random seed. it will use /dev/urandom where available:
|
// init lucene random seed. it will use /dev/urandom where available:
|
||||||
StringHelper.randomId();
|
StringHelper.randomId();
|
||||||
|
|
|
@ -99,6 +99,22 @@ final class Natives {
|
||||||
JNANatives.trySeccomp(tmpFile);
|
JNANatives.trySeccomp(tmpFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void trySetMaxNumberOfThreads() {
|
||||||
|
if (!JNA_AVAILABLE) {
|
||||||
|
logger.warn("cannot getrlimit RLIMIT_NPROC because JNA is not available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JNANatives.trySetMaxNumberOfThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void trySetMaxSizeVirtualMemory() {
|
||||||
|
if (!JNA_AVAILABLE) {
|
||||||
|
logger.warn("cannot getrlimit RLIMIT_AS beacuse JNA is not available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JNANatives.trySetMaxSizeVirtualMemory();
|
||||||
|
}
|
||||||
|
|
||||||
static boolean isSeccompInstalled() {
|
static boolean isSeccompInstalled() {
|
||||||
if (!JNA_AVAILABLE) {
|
if (!JNA_AVAILABLE) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue