sandynz commented on code in PR #24558:
URL: https://github.com/apache/shardingsphere/pull/24558#discussion_r1209657748
##########
infra/util/src/main/java/org/apache/shardingsphere/infra/util/spi/ShardingSphereServiceLoader.java:
##########
@@ -70,7 +80,17 @@ private Collection<T> load() {
@SuppressWarnings("unchecked")
public static <T> Collection<T> getServiceInstances(final Class<T>
serviceInterface) {
ShardingSphereServiceLoader<?> result = LOADERS.get(serviceInterface);
- return (Collection<T>) (null != result ? result.getServiceInstances()
: LOADERS.computeIfAbsent(serviceInterface,
ShardingSphereServiceLoader::new).getServiceInstances());
+ if (null != result) {
+ return (Collection<T>) result.getServiceInstances();
+ }
+ synchronized (LOAD_LOCKS[serviceInterface.hashCode() %
LOAD_LOCKS_COUNT]) {
Review Comment:
Sorry, I missed this message before.
`serviceInterface` might be synchronized here and in other places, I'm
afraid there might be synchronization issue, so I use dedicated lock here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]