Fix mutable api in PluginContainer (#1019)

This commit is contained in:
Guillaume Nodet 2023-03-09 21:14:48 +01:00 committed by GitHub
parent 93a0ecfd2d
commit dc8ec4c973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 1 deletions

View File

@ -624,7 +624,7 @@
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<version>4.0.0/4.1.0</version>
<code>
<![CDATA[
Map<String, Plugin> pluginMap;
@ -656,6 +656,31 @@
}
}
return pluginMap;
}
]]>
</code>
</codeSegment>
<codeSegment>
<version>4.2.0+</version>
<code>
<![CDATA[
volatile Map<String, Plugin> pluginMap;
/**
* @return a Map of plugins field with {@code Plugins#getKey()} as key
* @see Plugin#getKey()
*/
public Map<String, Plugin> getPluginsAsMap() {
if (pluginMap == null) {
synchronized (this) {
if (pluginMap == null) {
pluginMap = ImmutableCollections.copy(plugins.stream().collect(
java.util.stream.Collectors.toMap(
Plugin::getKey, java.util.function.Function.identity())));
}
}
}
return pluginMap;
}
]]>