twitter / scalding

A Scala API for Cascading
http://twitter.com/scalding
Apache License 2.0
3.5k stars 706 forks source link

Wrap findReferencedClasses in try catch #1694

Closed piyushnarang closed 7 years ago

piyushnarang commented 7 years ago

While trying out the new Scalding release internally, noticed we have some unit test failures due to the findReferencedClasses method throwing the following exception: java.lang.RuntimeException: error reading Scala signature of com.twitter.testpackage.MyTest: error reading Scala signature of org.scalatest.mock.package: assertion failed: unsafe symbol JMockCycle (child of <none>) in runtime reflection universe. Doesn't seem like the test is directly referencing the JMockCycle (seems to be mixing in MockitoSugar). Adding a dependency on org.jmock seems to work around the issue, but it seems like it would be nice to catch exceptions thrown in this method and not fail the job / test.

Exception:

java.lang.RuntimeException: error reading Scala signature of com.twitter.testpackage.MyTest: error reading Scala signature of org.scalatest.mock.package: assertion failed: unsafe symbol JMockCycle (child of <none>) in runtime reflection universe
  at scala.reflect.internal.pickling.UnPickler.unpickle(UnPickler.scala:46)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.unpickleClass(JavaMirrors.scala:619)
  at scala.reflect.runtime.SymbolLoaders$TopClassCompleter$$anonfun$complete$1.apply$mcV$sp(SymbolLoaders.scala:28)
  at scala.reflect.runtime.SymbolLoaders$TopClassCompleter$$anonfun$complete$1.apply(SymbolLoaders.scala:25)
  at scala.reflect.runtime.SymbolLoaders$TopClassCompleter$$anonfun$complete$1.apply(SymbolLoaders.scala:25)
  at scala.reflect.internal.SymbolTable.slowButSafeEnteringPhaseNotLaterThan(SymbolTable.scala:263)
  at scala.reflect.runtime.SymbolLoaders$TopClassCompleter.complete(SymbolLoaders.scala:25)
  at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1535)
  at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$8.scala$reflect$runtime$SynchronizedSymbols$SynchronizedSymbol$$super$info(SynchronizedSymbols.scala:168)
  at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anonfun$info$1.apply(SynchronizedSymbols.scala:127)
  at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anonfun$info$1.apply(SynchronizedSymbols.scala:127)
  at scala.reflect.runtime.Gil$class.gilSynchronized(Gil.scala:19)
  at scala.reflect.runtime.JavaUniverse.gilSynchronized(JavaUniverse.scala:16)
  at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$class.gilSynchronizedIfNotThreadsafe(SynchronizedSymbols.scala:123)
  at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$8.gilSynchronizedIfNotThreadsafe(SynchronizedSymbols.scala:168)
  at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$class.info(SynchronizedSymbols.scala:127)
  at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$8.info(SynchronizedSymbols.scala:168)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$coreLookup$1(JavaMirrors.scala:992)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$lookupClass$1(JavaMirrors.scala:998)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$classToScala1(JavaMirrors.scala:1003)
  at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToScala$1.apply(JavaMirrors.scala:980)
  at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToScala$1.apply(JavaMirrors.scala:980)
  at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$toScala$1.apply(JavaMirrors.scala:97)
  at scala.reflect.runtime.TwoWayCaches$TwoWayCache$$anonfun$toScala$1.apply(TwoWayCaches.scala:38)
  at scala.reflect.runtime.Gil$class.gilSynchronized(Gil.scala:19)
  at scala.reflect.runtime.JavaUniverse.gilSynchronized(JavaUniverse.scala:16)
  at scala.reflect.runtime.TwoWayCaches$TwoWayCache.toScala(TwoWayCaches.scala:33)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.toScala(JavaMirrors.scala:95)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.classToScala(JavaMirrors.scala:980)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.classSymbol(JavaMirrors.scala:196)
  at scala.reflect.runtime.JavaMirrors$JavaMirror.classSymbol(JavaMirrors.scala:54)
  at com.twitter.scalding.ReferencedClassFinder$.findReferencedClasses(ReferencedClassFinder.scala:38)
  at com.twitter.scalding.Job.reflectedClasses(Job.scala:203)
  at com.twitter.scalding.Job.config(Job.scala:191)
  at com.twitter.scalding.Job.executionContext(Job.scala:223)
  at com.twitter.scalding.Job.buildFlow(Job.scala:231)
  at com.twitter.scalding.Job.run(Job.scala:302)
  at com.twitter.scalding.JobTest.runJob(JobTest.scala:218)
  at com.twitter.scalding.JobTest.run(JobTest.scala:153)
johnynek commented 7 years ago

👍

piyushnarang commented 7 years ago

Thanks @johnynek, I noticed another test failure due to a slightly different error:

1) FeedbackSnapshotPipe should return empty when input is not serialized correctly(com.twitter.b2c.analytics.pipes.FeedbackSnapshotPipeSpec)
                     scala.reflect.internal.Symbols$CyclicReference: illegal cyclic reference involving object InterfaceAudience

That seems to be of type Throwable. I'm going to update the PR to just catch throwable.

fwbrasil commented 7 years ago

The second error seems to be a scala bug: https://issues.scala-lang.org/browse/SI-10129.

piyushnarang commented 7 years ago

@fwbrasil - updated, please take a look.