Lukasz Lenart created WW-5804:
---------------------------------

             Summary: Struts Boot: make temp directory cleanup on close and 
shutdown best-effort
                 Key: WW-5804
                 URL: https://issues.apache.org/jira/browse/WW-5804
             Project: Struts 2
          Issue Type: Bug
          Components: Core
            Reporter: Lukasz Lenart
             Fix For: 7.6.0


Follow-up to [WW-5791|https://issues.apache.org/jira/browse/WW-5791] (review of 
PR [#2053|https://github.com/apache/struts/pull/2053]).

{{StrutsBootServer#close()}} runs {{deleteRecursively(baseDir)}} and then 
{{removeShutdownHook()}} in a {{finally}} block. {{deleteRecursively}} throws 
{{UncheckedIOException}} on the first file it cannot delete (for example a 
transient Windows file lock), which:
* stops deleting the remaining files,
* skips {{removeShutdownHook()}}, so the hook keeps a reference to the closed 
server,
* masks the exception from {{tomcat.stop()}} / {{tomcat.destroy()}}, if there 
was one.

The same {{close()}} is the JVM shutdown hook ({{new Thread(this::close, 
...)}}), so any failure there ends as an uncaught exception printed at JVM exit.

Expected:
* deletion attempts every path and reports failures as suppressed exceptions 
instead of aborting;
* {{removeShutdownHook()}} always runs;
* {{close()}} keeps throwing for {{AutoCloseable}} / try-with-resources 
callers, while the shutdown hook catches and logs instead.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to