-
Notifications
You must be signed in to change notification settings - Fork 90
Failure to delete temp files when running in Spring Context #26
Description
I have wired up a PostgresService to be used in our Spring context-based tests. It is Lifecycle aware (it implements Lifecycle) and is started through start() method and stopped through a stop method which calls
process.stop();
When the test completes and the context is shutting down, I get an IllegalStateException, and the temporary files created at startup are not deleted. It seems to occur when a shutdown hook is added to clean up the files:
2016-02-26 15:09:00,992 [Thread-6] INFO de.flapdoodle.embed.process.runtime.ProcessControl - execSuccess: true [kill, -2, 69506] 2016-02-26 15:09:01,157 [Thread-6] WARN de.flapdoodle.embed.process.io.file.Files - could not delete /var/folders/22/1f6xflcj60qgv_27xwtyxr1m0000gn/T/postgresql-embed-4f4bcf51-7ba0-401d-8a1d-ecf5f55bb1ba/db-content-0ca454b3-56c3-4b75-88ba-d5ad911f7fd9. Will try to delete it again when program exits. 2016-02-26 15:09:01,159 [Thread-47] INFO com.anzcro.o3.util.db.PostgresService - STOPPED EMBEDDED POSTGRES 2016-02-26 15:09:01,159 [Thread-47] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@26aa12dd: defining beans [propertyPlaceholderConfigurerBusinessBase,postgresService,...]; root of factory hierarchy Exception in thread "Thread-6" java.lang.IllegalStateException: Shutdown in progress at java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66) at java.lang.Runtime.addShutdownHook(Runtime.java:211) at de.flapdoodle.embed.process.io.file.FileCleaner.forceDeleteOnExit(FileCleaner.java:52) at de.flapdoodle.embed.process.io.file.Files.forceDelete(Files.java:125) at ru.yandex.qatools.embed.postgresql.PostgresProcess.deleteTempFiles(PostgresProcess.java:157) at ru.yandex.qatools.embed.postgresql.PostgresProcess.stopInternal(PostgresProcess.java:117) at de.flapdoodle.embed.process.runtime.AbstractProcess.stop(AbstractProcess.java:170) at de.flapdoodle.embed.process.runtime.AbstractProcess$JobKiller.run(AbstractProcess.java:243) at java.lang.Thread.run(Thread.java:745)
It looks like it's failing to register the shutdown hook that deletes the files.