[
https://issues.apache.org/jira/browse/ARTEMIS-1058?focusedWorklogId=186358&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-186358
]
ASF GitHub Bot logged work on ARTEMIS-1058:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 17/Jan/19 15:44
Start Date: 17/Jan/19 15:44
Worklog Time Spent: 10m
Work Description: clebertsuconic commented on pull request #2473:
ARTEMIS-1058 Jars in web tmp dir locked on Windows
URL: https://github.com/apache/activemq-artemis/pull/2473#discussion_r248722829
##########
File path:
artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
##########
@@ -237,28 +236,39 @@ public void start() throws Exception {
public void internalStop() throws Exception {
server.stop();
if (webContexts != null) {
+
File tmpdir = null;
+ StringBuilder strBuilder = new StringBuilder();
+ boolean found = false;
for (WebAppContext context : webContexts) {
tmpdir = context.getTempDirectory();
- if (tmpdir != null && !context.isPersistTempDirectory()) {
+ if (tmpdir != null && tmpdir.exists() &&
!context.isPersistTempDirectory()) {
//tmpdir will be removed by deleteOnExit()
- //somehow when broker is stopped and restarted quickly
- //this tmpdir won't get deleted sometimes
- boolean fileDeleted = TimeUtils.waitOnBoolean(false, 5000,
tmpdir::exists);
-
- if (!fileDeleted) {
- //because the execution order of shutdown hooks are
- //not determined, so it's possible that the deleteOnExit
- //is executed after this hook, in that case we force a
delete.
- FileUtil.deleteDirectory(tmpdir);
- logger.debug("Force to delete temporary file on shutdown: "
+ tmpdir.getAbsolutePath());
- if (tmpdir.exists()) {
- ActiveMQWebLogger.LOGGER.tmpFileNotDeleted(tmpdir);
- }
+ //However because the URLClassLoader never release/close its
opened
+ //jars the jar file won't be able to get deleted on Windows
platform
+ //until after the process fully terminated. To fix this here
arranges
+ //a separate process to try clean up the temp dir
+ FileUtil.deleteDirectory(tmpdir);
+ if (tmpdir.exists()) {
+ ActiveMQWebLogger.LOGGER.tmpFileNotDeleted(tmpdir);
+ strBuilder.append(tmpdir);
+ strBuilder.append(",");
+ found = true;
}
}
}
+
+ if (found) {
+ String artemisHome = System.getProperty("artemis.home");
Review comment:
you're wrong actually,
WebServerComponent is getting the artemisInstance and artemisHome as
parameters.
It is important you don't use the variable here as you may break embedded
cases.
We use things like this on our testsuite as well. so, you can use a property
to store what's passed from the configure method, and use the variable directly
here instead.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 186358)
Time Spent: 10m
Remaining Estimate: 0h
> Jars in web tmp dir locked on Windows
> -------------------------------------
>
> Key: ARTEMIS-1058
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1058
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Components: Broker
> Affects Versions: 1.5.3
> Environment: Windows
> Reporter: Howard Gao
> Assignee: Howard Gao
> Priority: Minor
> Fix For: unscheduled
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The embedded jetty web server's WebAppClassloader holds up webapp's jar files
> and does not release them after close. For that reason the web app's temp dir
> cannot be cleaned up on Windows. (Other platforms like Linux doesn't prevent
> a force delete of files even they are not released).
> As long as this behavior exists we need to have a workaround to let
> the tmp dir be cleaned up.
> It is possible that we use a 'customized' classloader to replace jetty's
> WebAppClassloader, in which we manually iterate every JarFile resources
> and close them.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)