Skip to content

Commit

Permalink
meh, make it thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewparmet committed Jun 12, 2024
1 parent 1421ef4 commit 37f9638
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import protokt.v1.GeneratedMessage
import protokt.v1.Message
import protokt.v1.google.protobuf.RuntimeContext
import protokt.v1.google.protobuf.toDynamicMessage
import java.util.Collections
import java.util.concurrent.ConcurrentHashMap
import kotlin.reflect.full.findAnnotation

@Beta
Expand All @@ -43,9 +45,10 @@ class Validator @JvmOverloads constructor(

private val failFast = config.isFailFast

private val evaluatorsByFullTypeName = mutableMapOf<String, Evaluator>()
private val descriptors = mutableSetOf<Descriptor>()
private val evaluatorsByFullTypeName = ConcurrentHashMap<String, Evaluator>()
private val descriptors = Collections.newSetFromMap(ConcurrentHashMap<Descriptor, Boolean>())

@Volatile
private var runtimeContext = RuntimeContext(emptyList())

fun load(descriptor: Descriptor) {
Expand Down

0 comments on commit 37f9638

Please sign in to comment.