Source:
<code>SecurityDomain(Builder builder, final LinkedHashMap<String, RealmInfo> realmMap) { this.realmMap = realmMap; this.defaultRealmName = builder.defaultRealmName; this.preRealmRewriter = builder.preRealmRewriter; this.realmMapper = builder.realmMapper; this.roleMapper = builder.roleMapper; this.permissionMapper = builder.permissionMapper; this.postRealmRewriter = builder.postRealmRewriter; this.principalDecoder = builder.principalDecoder; this.securityIdentityTransformer = builder.securityIdentityTransformer; this.trustedSecurityDomain = builder.trustedSecurityDomain; <START> this.scheduledExecutorService = builder.scheduledExecutorService; <END> final Map<String, RoleMapper> originalRoleMappers = builder.categoryRoleMappers; final Map<String, RoleMapper> copiedRoleMappers; if (originalRoleMappers.isEmpty()) { copiedRoleMappers = emptyMap(); } else if (originalRoleMappers.size() == 1) { final Map.Entry<String, RoleMapper> entry = originalRoleMappers.entrySet().iterator().next(); copiedRoleMappers = Collections.singletonMap(entry.getKey(), entry.getValue()); } else { copiedRoleMappers = new LinkedHashMap<>(originalRoleMappers); } this.categoryRoleMappers = copiedRoleMappers; final RealmInfo realmInfo = new RealmInfo(); anonymousIdentity = Assert.assertNotNull(securityIdentityTransformer.apply(new SecurityIdentity(this, AnonymousPrincipal.getInstance(), realmInfo, AuthorizationIdentity.EMPTY, copiedRoleMappers, SecurityIdentity.NO_PEER_IDENTITIES, IdentityCredentials.NONE, IdentityCredentials.NONE))); currentSecurityIdentity = ThreadLocal.withInitial(() -> anonymousIdentity); }</code><technical_language>If set, a default single-thread created, else (by reading) a potential NPE in day</technical_language>

Target:
SecurityDomain(Builder builder, final LinkedHashMap<String, RealmInfo> realmMap) { this.realmMap = realmMap; this.defaultRealmName = builder.defaultRealmName; this.preRealmRewriter = builder.preRealmRewriter; this.realmMapper = builder.realmMapper; this.roleMapper = builder.roleMapper; this.permissionMapper = builder.permissionMapper; this.postRealmRewriter = builder.postRealmRewriter; this.principalDecoder = builder.principalDecoder; this.securityIdentityTransformer = builder.securityIdentityTransformer; this.trustedSecurityDomain = builder.trustedSecurityDomain; final Map<String, RoleMapper> originalRoleMappers = builder.categoryRoleMappers; final Map<String, RoleMapper> copiedRoleMappers; if (originalRoleMappers.isEmpty()) { copiedRoleMappers = emptyMap(); } else if (originalRoleMappers.size() == 1) { final Map.Entry<String, RoleMapper> entry = originalRoleMappers.entrySet().iterator().next(); copiedRoleMappers = Collections.singletonMap(entry.getKey(), entry.getValue()); } else { copiedRoleMappers = new LinkedHashMap<>(originalRoleMappers); } this.categoryRoleMappers = copiedRoleMappers; final RealmInfo realmInfo = new RealmInfo(); anonymousIdentity = Assert.assertNotNull(securityIdentityTransformer.apply(new SecurityIdentity(this, AnonymousPrincipal.getInstance(), realmInfo, AuthorizationIdentity.EMPTY, copiedRoleMappers, SecurityIdentity.NO_PEER_IDENTITIES, IdentityCredentials.NONE, IdentityCredentials.NONE))); currentSecurityIdentity = ThreadLocal.withInitial(() -> anonymousIdentity); }