Modify the fingerprinter not to use ConcurrentHashMap.computeIfAbsent() because we cannot guarantee that the cache is not reentered by the computation.

This commit is contained in:
Chris Rankin 2019-08-21 14:21:23 +01:00
parent a5d5e0d476
commit 99074b5a49

View File

@ -36,11 +36,15 @@ class TypeModellingFingerPrinter(
private val cache: MutableMap<TypeIdentifier, String> = 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)
}
}
/**