Skip to content

Commit

Permalink
Workaround for Scala bug: scala/bug#2034 that has ben causing sporadi…
Browse files Browse the repository at this point in the history
…c test failures - the previous commit that addressed this couldn't catch the *error*.
  • Loading branch information
Gerard Murphy committed Mar 30, 2019
1 parent acf9b94 commit 7a7b5ed
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import scalacache.caffeine._
import scalacache.memoization._
import scalacache.modes.sync._

import scala.collection.JavaConversions._
import scala.collection.immutable
import scala.collection.mutable.{
Map => MutableMap,
Expand Down Expand Up @@ -199,13 +198,18 @@ object ImmutableObjectStorage {
Set(classOf[StateAcquisition], classOf[String], classOf[Class[_]])

def isNotToBeProxied(clazz: Class[_]): Boolean =
// Start with a workaround for: https://github.com/scala/bug/issues/2034 - if it throws,
// it's probably an inner class of some kind, so let's assume we don't want to proxy it.
Try { clazz.getSimpleName }.isFailure ||
try {
clazz.isSynthetic || clazz.isAnonymousClass || clazz.isLocalClass ||
Modifier.isFinal(clazz.getModifiers) || clazzesThatShouldNotBeProxied
.exists(_.isAssignableFrom(clazz)) || clazz.getSimpleName.startsWith(
"Function") || clazz.getSimpleName.startsWith("Tuple")
.exists(_.isAssignableFrom(clazz)) || clazz.getSimpleName.startsWith(
"Function") || clazz.getSimpleName.startsWith("Tuple")
} catch {
case _: InternalError =>
// Workaround: https://github.com/scala/bug/issues/2034 - if it throws,
// it's probably an inner class of some kind, so let's assume we don't
// want to proxy it.
true
}

private def createProxyClass[X <: AnyRef](clazz: Class[X]): Class[X] = {
// We should never end up having to make chains of delegating proxies!
Expand Down

0 comments on commit 7a7b5ed

Please sign in to comment.