Skip to content

Commit 4fb8f62

Browse files
committed
ProviderAPI.kt using synchronized map.
Signed-off-by: Pavel Erokhin (MairwunNx) <[email protected]>
1 parent 506d4c5 commit 4fb8f62

File tree

1 file changed

+9
-2
lines changed
  • src/main/kotlin/com/mairwunnx/projectessentials/core/api/v1/providers

1 file changed

+9
-2
lines changed

src/main/kotlin/com/mairwunnx/projectessentials/core/api/v1/providers/ProviderAPI.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import com.mairwunnx.projectessentials.core.api.v1.configuration.IConfiguration
77
import com.mairwunnx.projectessentials.core.api.v1.module.IModule
88
import com.mairwunnx.projectessentials.core.api.v1.providersMarker
99
import org.apache.logging.log4j.LogManager
10+
import java.util.*
11+
import kotlin.collections.HashMap
12+
1013

1114
/**
1215
* Provider API class. If you build new module
@@ -16,7 +19,9 @@ import org.apache.logging.log4j.LogManager
1619
*/
1720
object ProviderAPI {
1821
private val logger = LogManager.getLogger()
19-
private val providers = mutableMapOf<ProviderType, MutableList<Class<*>>>()
22+
private val providers = Collections.synchronizedMap(
23+
HashMap<ProviderType, MutableList<Class<*>>>()
24+
)
2025

2126
/**
2227
* Adds target provider. (provider type will determine automatically)
@@ -54,7 +59,9 @@ object ProviderAPI {
5459
* @since 2.0.0-SNAPSHOT.1.
5560
*/
5661
fun addProvider(type: ProviderType, clazz: Class<*>) {
57-
providers[type]?.add(clazz) ?: providers.put(type, mutableListOf(clazz))
62+
synchronized(providers) {
63+
providers[type]?.add(clazz) ?: providers.put(type, mutableListOf(clazz))
64+
}
5865
}
5966

6067
/**

0 commit comments

Comments
 (0)