Ehcache disk store unclean shutdown

后端 未结 3 2008
轮回少年
轮回少年 2020-12-14 13:20

I\'m using a cache with disk store persistence. On subsequent reruns of the app I\'m getting the following error:

net.sf.ehcache.store.DiskStore deleteIndexI         


        
3条回答
  •  暖寄归人
    2020-12-14 13:48

    Try setting the system property: net.sf.ehcache.enableShutdownHook=true

    So, either you can add the following line in the beginning of your program: System.setProperty("net.sf.ehcache.enableShutdownHook","true");

    Or, from the command line to pass the property: java -Dnet.sf.ehcache.enableShutdownHook=true ...

    Note, the ehcache website does mention some caution when using this shutdown hook: Shutting Down Ehcache

    When a shutdown hook will run, and when it will not

    The shutdown hook runs when:

    • a program exists normally. e.g. System.exit() is called, or the last non-daemon thread exits
    • the Virtual Machine is terminated. e.g. CTRL-C. This corresponds to kill -SIGTERM pid or kill -15 pid on Unix systems.

    The shutdown hook will not run when:

    • the Virtual Machine aborts
    • A SIGKILL signal is sent to the Virtual Machine process on Unix systems. e.g. kill -SIGKILL pid or kill -9 pid
    • A TerminateProcess call is sent to the process on Windows systems.

    Hope it works :)

提交回复
热议问题