Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-270

DelegatingSubjectTest#testRunAs null pointer exception

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      jdk1.6.0_23

      Description

      When all the tests are run, the test DelegatingSubjectTest#testRunAs throws null pointer exception

      java.lang.NullPointerException
      at org.apache.shiro.mgt.SessionsSecurityManager.start(SessionsSecurityManager.java:121)
      at org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:306)
      at org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:295)
      at org.apache.shiro.mgt.DefaultSecurityManager.bind(DefaultSecurityManager.java:163)
      at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:284)
      at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:247)
      at org.apache.shiro.subject.DelegatingSubjectTest.testRunAs(DelegatingSubjectTest.java:157)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      If only DelegatingSubjectTest class tests are run, everything is OK.

      NOTE: point 3 of https://issues.apache.org/jira/browse/SHIRO-208 mentions similar issue.

      1. patch_test.txt
        0.6 kB
        Maria Jurcovicova

        Activity

        Hide
        meri Maria Jurcovicova added a comment -

        DelegatingSubjectTest crash because SecurityUtils.getSecurityManager() returns destroyed instance of security manager.

        The issue is caused by previous test VMSingletonDefaultSecurityManagerTest. It creates new SecurityManager and sets it as default security manager in SecurityUtils.setSecurityManager(sm). Later, it calls destroy method on new secrity manager instance, but never cleans it from SecurityUtils.

        The patch adds SecurityUtils.setSecurityManager(null); in the end of testVMSingleton method.

        Show
        meri Maria Jurcovicova added a comment - DelegatingSubjectTest crash because SecurityUtils.getSecurityManager() returns destroyed instance of security manager. The issue is caused by previous test VMSingletonDefaultSecurityManagerTest. It creates new SecurityManager and sets it as default security manager in SecurityUtils.setSecurityManager(sm). Later, it calls destroy method on new secrity manager instance, but never cleans it from SecurityUtils. The patch adds SecurityUtils.setSecurityManager(null); in the end of testVMSingleton method.
        Hide
        lhazlewood Les Hazlewood added a comment -

        Thanks for the issue!

        Show
        lhazlewood Les Hazlewood added a comment - Thanks for the issue!
        Hide
        lhazlewood Les Hazlewood added a comment -

        Closing with the 1.2.0 release.

        Show
        lhazlewood Les Hazlewood added a comment - Closing with the 1.2.0 release.

          People

          • Assignee:
            lhazlewood Les Hazlewood
            Reporter:
            meri Maria Jurcovicova
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development