JDK-6542529 : Subject.doAsPrivileged creates unnecessary empty array of ProtectionDomains each time invoked
  • Type: Bug
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2007-04-04
  • Updated: 2011-05-02
  • Resolved: 2011-05-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b16Fixed
Related Reports
Relates :  
Description
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.

Comments
EVALUATION Yes, we should fix this.
29-06-2007