@Override
    public <T> T execute(final Object[] args, final Class<T> clazz, final boolean failOnError) {
        if (lock.tryLock()) {
            try {
                LOGGER.trace("Beginning to execute script [{}]", this);
                val binding = BINDING_THREAD_LOCAL.get();
                if (compiledScript == null) {
                    compiledScript = ScriptingUtils.parseGroovyShellScript(binding, script);
                }
                if (binding != null && !binding.isEmpty()) {
                    LOGGER.trace("Setting binding [{}]", binding);
                    compiledScript.setBinding(new Binding(binding));
                }
                LOGGER.trace("Current binding [{}]", compiledScript.getBinding());
                val result = ScriptingUtils.executeGroovyShellScript(compiledScript, clazz);
                LOGGER.debug("Groovy script [{}] returns result [{}]", this, result);
                return result;
            } catch (final GroovyRuntimeException e) {
                LoggingUtils.error(LOGGER, e);
            } finally {
                BINDING_THREAD_LOCAL.remove();
                if (compiledScript != null) {
                    compiledScript.setBinding(new Binding(Map.of()));
                }
                LOGGER.trace("Completed script execution [{}]", this);
                lock.unlock();
            }
        }
        return null;
    }
This is {@link GroovyShellScript}.

@author Misagh Moayyed
@since 6.0.0
core/cas-server-core-scripting/src/main/java/org/apereo/cas/util/scripting/GroovyShellScript.java