-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Use Java collections" #539
Conversation
This reverts commit 3e4b3b4.
Sorry about this, I didn't consider the re-entrancy of these caching methods.
override def getOrElseUpdate(key: K, defaultValue: => V): V = {
val hash = table.elemHashCode(key)
val i = table.index(hash)
val firstEntry = table.findEntry0(key, i)
if (firstEntry != null) firstEntry.value
else {
val table0 = table.table
val default = defaultValue
// Avoid recomputing index if the `defaultValue()` hasn't triggered
// a table resize.
val newEntryIndex = if (table0 eq table.table) i else table.index(hash)
val e = table.createNewEntry(key, default)
// Repeat search
// because evaluation of `default` can bring entry with `key`
val secondEntry = table.findEntry0(key, newEntryIndex)
if (secondEntry == null) table.addEntry0(e, newEntryIndex)
else secondEntry.value = default
default
}
} Whereas the Java collections consider it a programming error and fail fast. |
I believe @jvican is going to try reworking Zinc to compute the hashes directly without first creating this structure, so reverting is and waiting for that work seems like a good course of action. |
I think this mostly means that we need to add automated testing on JDK 10 sooner rather than later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe @jvican is going to try reworking Zinc to compute the hashes directly without first creating this structure, so reverting is and waiting for that work seems like a good course of action.
This is indeed correct, I'm working on it.
Thanks for the quick review guys. |
This reverts commit 52959c9.
Fixes #538
The use of
java.util.HashMap
causesjava.util.ConcurrentModificationException
on JDK 9 and JDK 10. This is likely becauseprocessType
recursively end up callingprocessType
while modifyingtypeCache
.