Skip to content

Commit

Permalink
Modify the fingerprinter not to use ConcurrentHashMap.computeIfAbsent…
Browse files Browse the repository at this point in the history
…() because we cannot guarantee that the cache is not reentered by the computation.
  • Loading branch information
chrisr3 committed Aug 23, 2019
1 parent a5d5e0d commit 99074b5
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

/**
Expand Down

0 comments on commit 99074b5

Please sign in to comment.