Skip to content

Commit

Permalink
Merge pull request #403 from cherylking/fixesForTempConfigDir
Browse files Browse the repository at this point in the history
Make handling of temp config dir better and tolerate exceptions during shutdown/cleanup
  • Loading branch information
cherylking authored Jun 8, 2023
2 parents 328dcef + c2b9fcb commit ae4d20e
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@ public void cleanUpServerEnv() {
// Delete server.env file
serverEnvFile.delete();
}
} catch (IOException e) {
} catch (Exception e) {
error("Could not retrieve server.env: " + e.getMessage());
}
}
Expand All @@ -2036,7 +2036,7 @@ public void cleanUpTempConfig() {
try {
FileUtils.deleteDirectory(tempConfig);
debug("Successfully deleted liberty:dev temporary configuration folder");
} catch (IOException e) {
} catch (Exception e) {
warn("Could not delete liberty:dev temporary configuration folder: " + e.getMessage());
}
}
Expand All @@ -2050,7 +2050,7 @@ public void cleanUpTempDockerfile() {
try {
Files.delete(tempDockerfilePath);
debug("Successfully deleted dev mode temporary Dockerfile");
} catch (IOException e) {
} catch (Exception e) {
warn("Could not delete dev mode temporary Dockerfile: " + e.getMessage());
}
}
Expand Down Expand Up @@ -2078,30 +2078,34 @@ public void run() {
}

private void runShutdownHook(final ThreadPoolExecutor executor) {
if (!calledShutdownHook.getAndSet(true)) {

if (trackingMode == FileTrackMode.POLLING || trackingMode == FileTrackMode.NOT_SET) {
disablePolling();
}

setDevStop(true);
cleanUpTempConfig();
cleanUpServerEnv();

if (hotkeyReader != null) {
hotkeyReader.shutdown();
}

// shutdown tests
executor.shutdown();
try {
if (!calledShutdownHook.getAndSet(true)) {

// stopping server
if (container) {
cleanUpTempDockerfile();
stopContainer();
} else {
stopServer();
if (trackingMode == FileTrackMode.POLLING || trackingMode == FileTrackMode.NOT_SET) {
disablePolling();
}

setDevStop(true);
cleanUpTempConfig();
cleanUpServerEnv();

if (hotkeyReader != null) {
hotkeyReader.shutdown();
}

// shutdown tests
executor.shutdown();

// stopping server
if (container) {
cleanUpTempDockerfile();
stopContainer();
} else {
stopServer();
}
}
} catch (Exception e) {
warn("Received exception during server shutdown and cleanup: " + e.getMessage());
}
}

Expand Down Expand Up @@ -4552,12 +4556,14 @@ public void installFeaturesToTempDir(File fileChanged, File srcDir, String targe
FileUtils.copyDirectory(serverDirectory, tempConfig, new FileFilter() {
public boolean accept(File pathname) {
String name = pathname.getName();
String parent = pathname.getParentFile().getName();
String serverDirName = serverDirectory.getName();
// skip:
// - ignore list
// - workarea and logs dirs from the server directory, since those can be
// - workarea, messaging and logs dirs from the server directory, since those can be
// changing
boolean skip = ignoreFileOrDir(pathname)
|| (pathname.isDirectory() && (name.equals("workarea") || name.equals("logs")));
boolean skip = ignoreFileOrDir(pathname) || (pathname.isDirectory() &&
(name.equals("workarea") || name.equals("logs") || (name.equals("messaging") && parent.equals(serverDirName))));
return !skip;
}
}, true);
Expand Down

0 comments on commit ae4d20e

Please sign in to comment.