frankiesardo / icepick

Android Instance State made easy
Eclipse Public License 1.0
3.75k stars 208 forks source link

Build fails with java.lang.ExceptionInInitializerError #107

Open seanabraham opened 7 years ago

seanabraham commented 7 years ago

I've seen many builds fail nondeterministically (with multiple modules and gradle running in parallel mode) with the following error:

error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider icepick.processor.IcepickProcessor could not be instantiated: java.lang.ExceptionInInitializerError

A cursory look through IcepickProcessor.java makes me think that there's potentially a race condition introduced because of the changing of classloaders. Thoughts, @frankiesardo?

seanabraham commented 7 years ago

I've seen this in multiple build systems actually, both Gradle and Buck. Here's are some stacktrace frames:

Caused by: java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at clojure.lang.RT.classForName(RT.java:2154)
    at clojure.lang.RT.classForName(RT.java:2163)
    at clojure.lang.RT.loadClassForName(RT.java:2182)
    at clojure.lang.RT.load(RT.java:436)
    at clojure.lang.RT.load(RT.java:412)
    at clojure.core$load$fn__5448.invoke(core.clj:5866)
    at clojure.core$load.doInvoke(core.clj:5865)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5671)
    at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
    at clojure.core$load_lib.doInvoke(core.clj:5710)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:632)
    at clojure.core$load_libs.doInvoke(core.clj:5749)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:634)
    at clojure.core$use.doInvoke(core.clj:5843)
    at clojure.lang.RestFn.invoke(RestFn.java:436)
    at stencil.parser$loading__5340__auto____127.invoke(parser.clj:1)
    at stencil.parser__init.load(Unknown Source)
    at stencil.parser__init.<clinit>(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
...

which eventually yields:


Caused by: java.lang.IllegalStateException: zip file closed
--
  | at java.util.zip.ZipFile.ensureOpen(ZipFile.java:669)
  | at java.util.zip.ZipFile.getEntry(ZipFile.java:309)
  | at java.util.jar.JarFile.getEntry(JarFile.java:240)
  | at sun.net.www.protocol.jar.URLJarFile.getEntry(URLJarFile.java:128)
  | at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:132)
  | at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
  | at clojure.lang.RT.lastModified(RT.java:388)
  | at clojure.lang.RT.load(RT.java:427)
  | at clojure.lang.RT.load(RT.java:412)
  | at clojure.core$load$fn__5448.invoke(core.clj:5866)
  | at clojure.core$load.doInvoke(core.clj:5865)
  | at clojure.lang.RestFn.invoke(RestFn.java:408)
  | at clojure.pprint__init.load(Unknown Source)
  | at clojure.pprint__init.<clinit>(Unknown Source)
  | ... 160 more
seanabraham commented 7 years ago

This Stackoverflow post further suggests this issue may manifest from how the classloaders are manipulated in IcepickProcess.java: https://stackoverflow.com/questions/22582962/illegalstateexception-zip-file-closed-during-file-write