Why does the JndiLoginInitialContextFactory leak instances of SecurityAssociation$SubjectContext in JBoss?

Solution Verified - Updated -

Issue

  • During a profiling of our application we see the object count of SecurityAssociation$SubjectContext continually increasing over time.
  • We instantiate a new InitialContext (JndiLoginInitialContextFactory) with authentication information, then close it and this operation leaks SecurityAssociation$SubjectContext.

    public void onMessage(Message msg) {
      try {
        Properties env = new Properties();
        env.setProperty(Context.SECURITY_PRINCIPAL, "admin");
        env.setProperty(Context.SECURITY_CREDENTIALS, "admin");
        env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
        InitialContext ic = new InitialContext(env);
        ic.close();
      } catch (Exception e) {
        System.out.println(e.getMessage());
      }   
    }
    

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 4.2.x
    • 4.3.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.