feat : 模拟执行报错

This commit is contained in:
clay
2024-09-19 05:08:45 +08:00
parent cfddc12cc9
commit 6290495df4
3 changed files with 29 additions and 3 deletions

View File

@@ -100,7 +100,8 @@ public class JavaCodeEngine {
// 设置安全检查器
System.setSecurityManager(securityManager);
// 执行方法并返回结果
return ConsoleCapture.capture(() -> method.invoke(null, args));
return new EngineResult(method.invoke(null, args), null);
// return ConsoleCapture.capture(() -> method.invoke(null, args));
} catch (CustomException e) {
EngineResult result = new EngineResult();
result.setSuccess(Boolean.FALSE);
@@ -279,7 +280,7 @@ public class JavaCodeEngine {
}
public void remove(){
public void remove() {
clazz = null;
classLoader = null;
}

View File

@@ -4,7 +4,6 @@ import cn.fateverse.common.code.console.ConsoleCapture;
import cn.fateverse.common.code.lock.SegmentLock;
import cn.fateverse.common.code.model.EngineResult;
import cn.fateverse.common.core.exception.CustomException;
import com.alibaba.fastjson2.JSON;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;

View File

@@ -0,0 +1,26 @@
# Spring
spring:
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 162.14.111.170:8848
namespace: clay
dubbo:
registry:
parameters:
namespace: dubbo-clay
code:
java:
class-path: E:\home\clay\code\
seata:
service:
grouplist:
seata-server: 192.168.31.102:8091
registry:
nacos:
namespace: clay
config:
apollo:
namespace: clay