Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-6363

NullPointerException while executing a script on non secured cache located in secured container

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 9.0.0.Final
    • None
    • Tasks
    • None

      NullPointerException is thrown while executing a script on non secured cache which is located in secured container.

      The exception is:

      java.security.PrivilegedActionException: java.lang.NullPointerException
      	at org.infinispan.security.Security.doAs(Security.java:145)
      	at org.infinispan.scripting.SecureScriptingTest.test(SecureScriptingTest.java:142)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
      	at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
      	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
      	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
      	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      	at org.testng.TestRunner.privateRun(TestRunner.java:767)
      	at org.testng.TestRunner.run(TestRunner.java:617)
      	at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
      	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
      	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
      	at org.testng.SuiteRunner.run(SuiteRunner.java:254)
      	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
      	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
      	at org.testng.TestNG.run(TestNG.java:1057)
      	at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
      	at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:122)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
      Caused by: java.lang.NullPointerException
      	at org.infinispan.scripting.impl.ScriptingManagerImpl.runScript(ScriptingManagerImpl.java:152)
      	at org.infinispan.scripting.SecureScriptingTest$8.run(SecureScriptingTest.java:145)
      	at org.infinispan.scripting.SecureScriptingTest$8.run(SecureScriptingTest.java:142)
      	at org.infinispan.security.Security.doAs(Security.java:143)
      	... 29 more
      

      The test is:

      public void test() throws ExecutionException, InterruptedException, PrivilegedActionException {
            Security.doAs(ADMIN, new PrivilegedAction<Void>() {
               @Override
               public Void run() {
                  cacheManager.defineConfiguration("nonSecuredCache", TestCacheManagerFactory.getDefaultCacheConfiguration(true).build());
                  return null;
               }
            });
      
            cache("nonSecuredCache").put("a", "value");
            assertEquals("value", cacheManager.getCache("nonSecuredCache").get("a"));
      
            String result = Security.doAs(RUNNER, new PrivilegedExceptionAction<String>() {
               @Override
               public String run() throws Exception {
                  return (String) scriptingManager.runScript("test.js", new TaskContext().addParameter("a", "a").cache(cache("nonSecuredCache"))).get();
               }
            });
            assertEquals("a", result);
            assertEquals("a", cacheManager.getCache("nonSecuredCache").get("a"));
         }
      

              vjuranek@redhat.com Vojtech Juranek
              amanukya@redhat.com Anna Manukyan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: