This code uses the double-checked lock pattern:
public C getConfigurable(@Nullable final UUID kbTenantId) {
if (kbTenantId != null && !this.configuredTenants.contains(kbTenantId)) {
synchronized(this.configuredTenants) {
if (!this.configuredTenants.contains(kbTenantId)) {
this.configure(kbTenantId);
this.configuredTenants.add(kbTenantId);
}
}
}
return (C)this.pluginTenantConfigurable.get(kbTenantId);
}
However configuredTenants can potentially be modified by a different thread while contains is called out side the synchronization block. AFAIK, this is not thread safe.