I'm working with Play Framework 2.2.x, and it seems that Scala IDE keeps file handles opened.
- IDE: Eclipse Luna 4.4.1
- Scala IDE: 4.1.0.nightly-2_11-201412090608-ef40916
(The problem is also present with Kepler, and with the older versions of Scala IDE)
Sometimes, when a Play Framework dependency have to be updated in its repository, it can't be done due to a lock on a file (locked by Eclipse process).
- The file (jar) is present in the project build path.
- The Play commands are called outside the Eclipse process.
I don't know how to reproduce it every time (I do not have a test scenario), but using a tool called file-leak-detector (http://file-leak-detector.kohsuke.org/), I've seen this stack trace, maybe this is the problem:
- IDE: Eclipse Luna 4.4.1
- Scala IDE: 4.1.0.nightly-2_11-201412090608-ef40916
(The problem is also present with Kepler, and with the older versions of Scala IDE)
Sometimes, when a Play Framework dependency have to be updated in its repository, it can't be done due to a lock on a file (locked by Eclipse process).
- The file (jar) is present in the project build path.
- The Play commands are called outside the Eclipse process.
I don't know how to reproduce it every time (I do not have a test scenario), but using a tool called file-leak-detector (http://file-leak-detector.kohsuke.org/), I've seen this stack trace, maybe this is the problem:
C:\play-2.2.1\repository\cache\commons\commons-bean\jars\commons-bean-1.1.0-SNAPSHOT.jar by thread:org.scalaide.ui.internal.reconciliation.ScalaReconciler on Fri Dec 12 11:23:13 CET 2014
at java.util.zip.ZipFile.<init>(ZipFile.java:146)
at java.util.zip.ZipFile.<init>(ZipFile.java:159)
at scala.reflect.io.FileZipArchive.liftedTree1$1(ZipArchive.scala:127)
at scala.reflect.io.FileZipArchive.x$1$lzycompute(ZipArchive.scala:126)
at scala.reflect.io.FileZipArchive.x$1(ZipArchive.scala:123)
at scala.reflect.io.FileZipArchive.root$lzycompute(ZipArchive.scala:123)
at scala.reflect.io.FileZipArchive.root(ZipArchive.scala:123)
at scala.reflect.io.FileZipArchive.iterator(ZipArchive.scala:152)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.reflect.io.AbstractFile.foreach(AbstractFile.scala:91)
at scala.tools.nsc.util.DirectoryClassPath.traverse(ClassPath.scala:277)
at scala.tools.nsc.util.DirectoryClassPath.x$15$lzycompute(ClassPath.scala:299)
at scala.tools.nsc.util.DirectoryClassPath.x$15(ClassPath.scala:299)
at scala.tools.nsc.util.DirectoryClassPath.packages$lzycompute(ClassPath.scala:299)
at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:299)
at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:264)
at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
at scala.collection.Iterator$class.foreach(Iterator.scala:750)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.tools.nsc.util.MergedClassPath.packages$lzycompute(ClassPath.scala:358)
at scala.tools.nsc.util.MergedClassPath.packages(ClassPath.scala:353)
at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply$mcV$sp(SymbolLoaders.scala:270)
at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply(SymbolLoaders.scala:261)
at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply(SymbolLoaders.scala:261)
at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235)
at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader.doComplete(SymbolLoaders.scala:261)
at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:212)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1483)
at scala.reflect.internal.Mirrors$RootsBase.init(Mirrors.scala:256)
at scala.tools.nsc.Global.rootMirror$lzycompute(Global.scala:74)
at scala.tools.nsc.Global.rootMirror(Global.scala:72)
at scala.tools.nsc.Global.rootMirror(Global.scala:40)
at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1389)
at scala.tools.nsc.Global$Run.<init>(Global.scala:1216)
at scala.tools.nsc.interactive.Global$TyperRun.<init>(Global.scala:1204)
at scala.tools.nsc.interactive.Global.newTyperRun(Global.scala:1227)
at scala.tools.nsc.interactive.Global.<init>(Global.scala:293)
at org.scalaide.core.internal.compiler.ScalaPresentationCompiler.<init>(ScalaPresentationCompiler.scala:71)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.liftedTree1$1(PresentationCompilerProxy.scala:158)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.create(PresentationCompilerProxy.scala:157)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.initialize(PresentationCompilerProxy.scala:122)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.obtainPc$1(PresentationCompilerProxy.scala:84)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.internal(PresentationCompilerProxy.scala:104)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.apply(PresentationCompilerProxy.scala:62)
at org.scalaide.core.compiler.InteractiveCompilationUnit$class.forceReconcile(InteractiveCompilationUnit.scala:151)
at org.scalaide.core.internal.jdt.model.ScalaSourceFile.forceReconcile(ScalaSourceFile.scala:73)
at org.scalaide.ui.internal.reconciliation.ScalaReconcilingStrategy.reconcile(ScalaReconcilingStrategy.scala:48)
at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Leave a comment
on 2014-12-15 10:33 *
By Simon Schäfer
Summary changed from File leak to Files can't be updated out of Eclipse when their project is imported
Description changed from Hello,
I'm working with Pla... to I'm working with Play Frame...
Status changed from New to Accepted
I saw this problem multiple times by myself but never found out where it comes from. This file leak detector is interesting, maybe it helps to localize the problem.
Maybe this is related to the class scala.reflect.io.ZipArchive which instanciates a ZipFile (and in the JDK, a new instance of ZipFile opens a handle).
It could be changed to something like
final class FileZipArchive(file: JFile) extends ZipArchive(file) {
def iterator: Iterator[Entry] = {
val zipFile = new ZipFile(file)
val root = new DirEntry("/")
val dirs = mutable.HashMap[String, DirEntry]("/" -> root)
val enum = zipFile.entries()
while (enum.hasMoreElements) {
[...]
}
[...]
}
It could be changed to something like
final class FileZipArchive(file: JFile) extends ZipArchive(file) {
def iterator: Iterator[Entry] = {
val root = new DirEntry("/")
val dirs = mutable.HashMap[String, DirEntry]("/" -> root)
var zipFile:ZipFile = null
try {
zipFile = new ZipFile(file)
val enum = zipFile.entries()
while (enum.hasMoreElements) {
[...]
}
}
finally {
if (zipFile != null) {
try {
zipFile.close()
}
catch {
case ioe: IOException => { }
}
}
}
[...]
}
on 2014-12-16 02:10 *
By Iulian Dragos
Unfortunately I think this is a hard one to fix. The Scala compiler keeps these jars open in memory, and the OS won't allow you to change them (I think this is a Windows-specific issue). @gkossakowski, @mpociecha do you think the new classpath implementation in scalac will fix this too?
on 2014-12-16 03:39 *
By gkossakowski
Unfortunately not. Flat classpath still uses scala.reflect.io.ZipArchive underneath so it shares the same problem as with the old classpath. However, the new design doesn't assume any laziness in implementation so flat classpath could read jars eagerly and close the file.
No file chosen
You have an empty file field. Please select or remove it.
Name | Size |
---|