Skip to content

CodeServer doesn't close log files after writing, tries to delete parent directory #10272

@niloc132

Description

@niloc132

I tried to use 2.13 with my project. Compiling and running by using the eclipse plugin.
I got the 404 Errors, and tried the suggested method to add -server com.google.gwt.dev.shell.JettyLauncher.
This did not work, because of

Unable to load server class com.google.gwt.dev.shell.JettyLauncher by fully qualified name or from the service loader
java.lang.ClassNotFoundException: com.google.gwt.dev.shell.JettyLauncher

Seems like the package name is wrong. Should be com.google.gwt.dev.shell.jetty.JettyLauncher.

After fixing that, i get this error:

Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   Module setup completed in 6203 ms
java.nio.file.FileSystemException: D:\temp\system\gwt-codeserver-6436482415766710969\me.jhost.webapp\compile-1: failed to delete one or more files; see suppressed exceptions for details
	at com.google.gwt.thirdparty.guava.common.io.MoreFiles.throwDeleteFailed(MoreFiles.java:803)
	at com.google.gwt.thirdparty.guava.common.io.MoreFiles.deleteRecursively(MoreFiles.java:554)
	at com.google.gwt.dev.codeserver.OutboxDir.create(OutboxDir.java:91)
	at com.google.gwt.dev.codeserver.CodeServer.makeOutboxTable(CodeServer.java:182)
	at com.google.gwt.dev.codeserver.CodeServer.start(CodeServer.java:151)
	at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:104)
	at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:55)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at com.google.gwt.dev.shell.SuperDevListener.runCodeServer(SuperDevListener.java:118)
	at com.google.gwt.dev.shell.SuperDevListener.start(SuperDevListener.java:97)
	at com.google.gwt.dev.DevMode.ensureCodeServerListener(DevMode.java:705)
	at com.google.gwt.dev.DevModeBase.doStartup(DevModeBase.java:778)
	at com.google.gwt.dev.DevMode.doStartup(DevMode.java:599)
	at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:880)
	at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:698)
	at com.google.gwt.dev.DevMode.main(DevMode.java:476)
	Suppressed: java.nio.file.FileSystemException: D:\temp\system\gwt-codeserver-6436482415766710969\me.jhost.webapp\compile-1\compile.log: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird
		at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
		at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
		at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
		at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:275)
		at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105)
		at java.base/java.nio.file.Files.delete(Files.java:1152)
		at com.google.gwt.thirdparty.guava.common.io.MoreFiles.deleteRecursivelyInsecure(MoreFiles.java:678)
		at com.google.gwt.thirdparty.guava.common.io.MoreFiles.deleteDirectoryContentsInsecure(MoreFiles.java:698)
		at com.google.gwt.thirdparty.guava.common.io.MoreFiles.deleteRecursivelyInsecure(MoreFiles.java:671)
		at com.google.gwt.thirdparty.guava.common.io.MoreFiles.deleteRecursively(MoreFiles.java:543)
		... 17 more

The german message (Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird) translates to something like 'The Process can not access the file, because it is used by another process'.
I've checked that, but the folder has just been created by launching the app. Never had an issue like that with older GWT Releases.

Originally posted by @keinhaar in #10271

Root cause appears to be that PrintWriterTreeLogger instance do not close the PrintWriter they create, and then the same process tries to delete the file that's still technically held open. This isnt a regression per se - it has always been wrong - but it is a new problem now that we're stricter about actually cleaning up after ourselves.

Alternative fix is we could clean the "outbox" dir before we create the dummy compile entry, so that the compiler hasn't had a chance to write to it yet. That would better solve the immediate problem, and would sidestep any other leaked FDs during startup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions