mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
ENT-1903: Isolate the WeakHashMap reference. (#3221)
This commit is contained in:
parent
356b22fa44
commit
76918de656
@ -114,14 +114,33 @@ class MapSerializer(private val declaredType: ParameterizedType, factory: Serial
|
||||
}
|
||||
|
||||
internal fun Class<*>.checkSupportedMapType() {
|
||||
checkHashMap()
|
||||
checkWeakHashMap()
|
||||
checkDictionary()
|
||||
}
|
||||
|
||||
private fun Class<*>.checkHashMap() {
|
||||
if (HashMap::class.java.isAssignableFrom(this) && !LinkedHashMap::class.java.isAssignableFrom(this)) {
|
||||
throw IllegalArgumentException(
|
||||
"Map type $this is unstable under iteration. Suggested fix: use java.util.LinkedHashMap instead.")
|
||||
} else if (WeakHashMap::class.java.isAssignableFrom(this)) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The [WeakHashMap] class does not exist within the DJVM, and so we need
|
||||
* to isolate this reference.
|
||||
*/
|
||||
private fun Class<*>.checkWeakHashMap() {
|
||||
if (WeakHashMap::class.java.isAssignableFrom(this)) {
|
||||
throw IllegalArgumentException("Weak references with map types not supported. Suggested fix: "
|
||||
+ "use java.util.LinkedHashMap instead.")
|
||||
} else if (Dictionary::class.java.isAssignableFrom(this)) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun Class<*>.checkDictionary() {
|
||||
if (Dictionary::class.java.isAssignableFrom(this)) {
|
||||
throw IllegalArgumentException(
|
||||
"Unable to serialise deprecated type $this. Suggested fix: prefer java.util.map implementations")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user