@ -41,7 +41,6 @@ import java.util.Optional;
import java.util.UUID ;
import java.util.concurrent.Executor ;
import java.util.concurrent.ExecutorService ;
import java.util.concurrent.Executors ;
import java.util.concurrent.locks.ReentrantLock ;
@Slf4j
@ -65,6 +64,9 @@ public class NashornJsInvokeService extends AbstractJsInvokeService {
@Value ( "${js.local.max_cpu_time}" )
private long maxCpuTime ;
@Value ( "${js.local.max_memory}" )
private long maxMemory ;
@Getter
@Value ( "${js.local.max_errors}" )
private int maxErrors ;
@ -107,12 +109,13 @@ public class NashornJsInvokeService extends AbstractJsInvokeService {
@Override
public void init ( ) {
super . init ( ) ;
jsExecutor = MoreExecutors . listeningDecorator ( Executors . newWorkStealingPool ( jsExecutorThreadPoolSize ) ) ;
jsExecutor = MoreExecutors . listeningDecorator ( ThingsBoard Executors. newWorkStealingPool ( jsExecutorThreadPoolSize , "nashorn-js-executor" ) ) ;
if ( useJsSandbox ) {
sandbox = NashornSandboxes . create ( ) ;
monitorExecutorService = ThingsBoardExecutors . newWorkStealingPool ( monitorThreadPoolSize , "nashorn-js-monitor" ) ;
sandbox . setExecutor ( monitorExecutorService ) ;
sandbox . setMaxCPUTime ( maxCpuTime ) ;
sandbox . setMaxMemory ( maxMemory ) ;
sandbox . allowNoBraces ( false ) ;
sandbox . allowLoadFunctions ( true ) ;
sandbox . setMaxPreparedStatements ( 30 ) ;