RFR: 8247995: Avoid use of a mapping function in Permissions.getPermissionCollection
Roger Riggs
Roger.Riggs at oracle.com
Mon Jun 22 21:03:14 UTC 2020
Hi Claes,
Its correct as is but I would have written it without duplicating the
'permsMap.get(p.getClass())' invocation
and as a single method (unless the inlining of
getPermissionCollection(p,create)) is important.
A patch on top of yours:
diff --git a/src/java.base/share/classes/java/security/Permissions.java
b/src/java.base/share/classes/java/security/Permissions.java
--- a/src/java.base/share/classes/java/security/Permissions.java
+++ b/src/java.base/share/classes/java/security/Permissions.java
@@ -229,20 +229,16 @@ implements Serializable
*/
private PermissionCollection getPermissionCollection(Permission p,
boolean createEmpty) {
+ PermissionCollection pc = permsMap.get(p.getClass());
if (!hasUnresolved && !createEmpty) {
// Collection not to be created
- return permsMap.get(p.getClass());
+ return pc;
}
- PermissionCollection pc = permsMap.get(p.getClass());
if (pc != null) {
// Collection already created
return pc;
}
- return createPermissionCollection(p, createEmpty);
- }
- private PermissionCollection createPermissionCollection(Permission p,
- boolean createEmpty) {
synchronized (permsMap) {
Class<?> c = p.getClass();
PermissionCollection pc = permsMap.get(c);
Thanks, Roger
On 6/22/20 11:04 AM, Claes Redestad wrote:
> Hi,
>
> this patch fixes a corner-case performance issue with
> Permissions.implies(Permission) by not needing to allocate a mapper
> function (or lambda) on each invocation of getPermissionCollection
> when there are unresolved permissions present.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8247995
> Patch: http://cr.openjdk.java.net/~redestad/8247995/open.00/
>
> Testing: tier1-2
>
> Thanks!
>
> /Claes
More information about the security-dev
mailing list