Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6542529

Subject.doAsPrivileged creates unnecessary empty array of ProtectionDomains each time invoked

XMLWordPrintable

    • b16
    • sparc
    • solaris_10
    • Not verified

      javax.security.auth.Subject.doAsPrivileged (both overloaded methods) creates an
      empty array of ProtectionDomains each time it is invoked if the AccessControlContext
      parameter is null.

      This is unnecessary overhead, since this array is immutable and never changed. Instead
      the array should be a static and instantiated once and reused, ex:

          private static final ProtectionDomain[] EMPTY_PROTECTION_DOMAIN_SET =
              new ProtectionDomain[0];

      ...

              final AccessControlContext callerAcc =
                      (acc == null ?
                      new AccessControlContext(EMPTY_PROTECTION_DOMAIN_SET) :
      // new AccessControlContext(new ProtectionDomain[0]) :
                      acc);


      This shows up as a small issue when analyzing memory utilization of the App Server with
      a Security Manager enabled.

            mullan Sean Mullan
            mullan Sean Mullan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: