diff --git a/serialization/src/main/kotlin/net/corda/serialization/internal/model/TypeModellingFingerPrinter.kt b/serialization/src/main/kotlin/net/corda/serialization/internal/model/TypeModellingFingerPrinter.kt index 7077eecce1..b0ac855d34 100644 --- a/serialization/src/main/kotlin/net/corda/serialization/internal/model/TypeModellingFingerPrinter.kt +++ b/serialization/src/main/kotlin/net/corda/serialization/internal/model/TypeModellingFingerPrinter.kt @@ -36,11 +36,15 @@ class TypeModellingFingerPrinter( private val cache: MutableMap = DefaultCacheProvider.createCache() override fun fingerprint(typeInformation: LocalTypeInformation): String = - cache.computeIfAbsent(typeInformation.typeIdentifier) { - FingerPrintingState( - customTypeDescriptorLookup, - FingerprintWriter(debugEnabled)).fingerprint(typeInformation) - } + /* + * We cannot use ConcurrentMap.computeIfAbsent() here because it requires + * that the map not be re-entered during the computation function. And + * the Fingerprinter cannot guarantee that. + */ + cache.getOrPut(typeInformation.typeIdentifier) { + FingerPrintingState(customTypeDescriptorLookup, FingerprintWriter(debugEnabled)) + .fingerprint(typeInformation) + } } /**