querydsl / codegen

Java/Scala Code generation tool
Apache License 2.0
23 stars 22 forks source link

Synchronize class generation to prevent corruption #19

Closed johnktims closed 10 years ago

johnktims commented 10 years ago
java.lang.ClassFormatError: Extra bytes at the end of class file Q_01686498692_02056817302_032091036
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
 at com.mysema.codegen.MemClassLoader.findClass(MemClassLoader.java:60)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
 at com.mysema.codegen.AbstractEvaluatorFactory.createEvaluator(AbstractEvaluatorFactory.java:130)

 at com.mysema.codegen.AbstractEvaluatorFactory.createEvaluator(AbstractEvaluatorFactory.java:94)
 at com.mysema.query.collections.DefaultEvaluatorFactory.create(DefaultEvaluatorFactory.java:125)
 at com.mysema.query.collections.DefaultQueryEngine.project(DefaultQueryEngine.java:234)
 at com.mysema.query.collections.DefaultQueryEngine.evaluateSingleSource(DefaultQueryEngine.java:192)
 at com.mysema.query.collections.DefaultQueryEngine.list(DefaultQueryEngine.java:91)
 at com.mysema.query.collections.AbstractCollQuery.list(AbstractCollQuery.java:202)

can occur when multiple threads attempt to generate classes simultaneously.

Link to original issue: https://groups.google.com/forum/#!topic/querydsl/ud4ow-siCn8

johnktims commented 10 years ago

I've created a tiny project using Spring Boot to show the issue. Do notice that I've created a copy of the com.mysema.codegen.AbstractEvaluatorFactory and put it on the classpath in my project with the contents of my pull request.

https://github.com/johnktims/querydsl-extra-bytes

timowest commented 10 years ago

Thanks for the pull request. The synchronization could be fine tuned a bit more in the future, but this already helps.