mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-12 20:16:07 +00:00
fix[graalvm]: detect graalVM environment
This commit is contained in:
1 parent
e32b796f56
commit
699f25e579
3 files changed
+18
-1
No files matched your search
@@ -15,6 +15,7 @@ package com.zfoo.boot;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.zfoo.boot.graalvm.GraalvmProtocolHints;
|
||||
import com.zfoo.boot.graalvm.GraalvmStorageHints;
|
||||
import com.zfoo.protocol.util.GraalVmUtils;
|
||||
import com.zfoo.protocol.util.JsonUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -37,6 +38,7 @@ public class BootAutoConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
public ObjectMapper getObjectMapper() {
|
||||
logger.info("Jackson auto config successfully!");
|
||||
logger.info("GraalVM environment [{}]", GraalVmUtils.isGraalVM());
|
||||
return JsonUtils.MAPPER;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
package com.zfoo.protocol.util;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -29,7 +31,20 @@ public abstract class GraalVmUtils {
|
||||
, System.getProperty("java.vendor.url", "")
|
||||
, System.getProperty("org.graalvm.nativeimage.imagecode", "")
|
||||
);
|
||||
GRAALVM = properties.stream().map(it -> it.toLowerCase()).anyMatch(it -> it.contains("graalvm"));
|
||||
var graalvm = properties.stream().map(it -> it.toLowerCase()).anyMatch(it -> it.contains("graalvm"));
|
||||
if (!graalvm) {
|
||||
// If the graalvm keyword is not included, it must not be a Graal VM environment.
|
||||
GRAALVM = false;
|
||||
} else {
|
||||
InputStream graalvmInputStream = null;
|
||||
try {
|
||||
// graalvm environment must not include YHOy5hWaRXNxJuSg.CZgueirdE9x6sOUl file
|
||||
graalvmInputStream = ClassUtils.getFileFromClassPath("YHOy5hWaRXNxJuSg.CZgueirdE9x6sOUl");
|
||||
} catch (IOException e) {
|
||||
}
|
||||
GRAALVM = graalvmInputStream == null;
|
||||
IOUtils.closeIO(graalvmInputStream);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isGraalVM() {
|
||||
|
||||
Whitespace-only changes.
Reference in new issue
Block a user