提交 8fa79061 编写于 作者: A Alexander Akbashev 提交者: Oliver Gondža

[FIX JENKINS-48349] Cache permission id to avoid allocating of new strings

Every request that comes from Jelly is checked against Permissions.
As result it leads to a call of `getId` method that produces the new string.
Usually it's not a problem, but in case of stop-the-world pause user requests are accumulated.
So, once pause is finished, we forcibly allocated tons of strings for
every request. That leads to new stop-the-world pause. (And this cycle
can repeat multiple times)

(cherry picked from commit b2c40cb9)
上级 0e5db018
......@@ -68,6 +68,9 @@ public final class Permission {
public final @Nonnull PermissionGroup group;
// if some plugin serialized old version of this class using XStream, `id` can be null
private final @CheckForNull String id;
/**
* Human readable ID of the permission.
*
......@@ -158,6 +161,7 @@ public final class Permission {
this.impliedBy = impliedBy;
this.enabled = enable;
this.scopes = ImmutableSet.copyOf(scopes);
this.id = owner.getName() + '.' + name;
group.add(this);
ALL.add(this);
......@@ -222,7 +226,10 @@ public final class Permission {
* @see #fromId(String)
*/
public @Nonnull String getId() {
return owner.getName()+'.'+name;
if (id == null) {
return owner.getName() + '.' + name;
}
return id;
}
@Override public boolean equals(Object o) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册