Skip to content

Commit

Permalink
fix #218 by closing thread pool
Browse files Browse the repository at this point in the history
  • Loading branch information
willr3 committed Jul 7, 2024
1 parent 99a7bff commit 9da3391
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/io/hyperfoil/tools/qdup/Local.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,18 @@ public boolean upload(String path, String destination, Host host) {
} else if (!host.isLocal() && host.hasContainerId()){
logger.info("Local.upload({},{}:{})", path, host.getSafeString(), destination);
Host remoteHost = host.withoutContainer();
ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
AbstractShell shell = AbstractShell.getShell(
remoteHost,
"",
new ScheduledThreadPoolExecutor(1),
stpe,
new SecretFilter(),
false);
String remoteDestination = shell.shSync("mktemp -d");
boolean uploaded = upload(path,remoteDestination,remoteHost);
if(!uploaded){
logger.error("failed to upload "+path+" to remote host as part of upload to "+host);
stpe.shutdownNow();
return false;
}
File localFile = new File(path);
Expand All @@ -133,6 +135,7 @@ public boolean upload(String path, String destination, Host host) {
List<String> populated = Cmd.populateList(json,host.getUpload()).stream().filter(v->v!=null && !v.isBlank()).collect(Collectors.toUnmodifiableList());
if(Cmd.hasPatternReference(populated, StringUtil.PATTERN_PREFIX)){
logger.error("failed to populate remote upload pattern: "+populated.stream().collect(Collectors.joining(" "))+"\nhost: "+remoteHost);
stpe.shutdownNow();
return false;
}
String mergedUpload = populated.stream().collect(Collectors.joining(" "));
Expand All @@ -141,6 +144,7 @@ public boolean upload(String path, String destination, Host host) {
//cleanup the folder we created on the remoteHost
String rmResponse = shell.shSync("rm -rf "+remoteDestination);
//
stpe.shutdownNow();
return true;
} else {
logger.info("Local.upload({},{}:{})", path, host.getSafeString(), destination);
Expand Down

0 comments on commit 9da3391

Please sign in to comment.