code: @SneakyThrows
      public static <T> T executeGroovyScript(final Resource groovyScript,
                                              final String methodName,
                                              final Object[] args,
                                              final Class<T> clazz,
                                              final boolean failOnError) {
  
          if (groovyScript == null || StringUtils.isBlank(methodName)) {
              return null;
          }
  
          try {
              return AccessController.doPrivileged((PrivilegedAction<T>) () -> getGroovyResult(groovyScript, methodName, args, clazz, failOnError));
          } catch (final Exception e) {
              var cause = (Throwable) null;
              if (e instanceof PrivilegedActionException) {
                  cause = PrivilegedActionException.class.cast(e).getException();
              } else {
                  cause = e;
              }
  
              if (failOnError) {
                  throw cause;
              }
              LOGGER.error(cause.getMessage(), cause);
          }
          return null;
      }
docs: Execute groovy script t.
  
  @param <T>          the type parameter
  @param groovyScript the groovy script
  @param methodName   the method name
  @param args         the args
  @param clazz        the clazz
  @param failOnError  the fail on error
  @return the t