Skip to content

Commit

Permalink
Merge pull request #321 from chemicwepn/master
Browse files Browse the repository at this point in the history
change deleteDirectoryTask to a List
  • Loading branch information
jekh committed Sep 13, 2015
2 parents 61ee3bb + a6ebd13 commit ed2454a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions browsermob-core/src/main/java/net/lightbody/bmp/proxy/selenium/SeleniumProxyHandler.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

/* ------------------------------------------------------------ */

Expand Down Expand Up @@ -76,7 +79,7 @@ public class SeleniumProxyHandler extends AbstractHttpHandler {
private final boolean proxyInjectionMode;
private final boolean forceProxyChain;
private boolean fakeCertsGenerated;
private DeleteDirectoryTask deleteDirectoryTask;
private final List<DeleteDirectoryTask> deleteDirectoryTasks = Collections.synchronizedList(new ArrayList<DeleteDirectoryTask>());

// see docs for the lock object on SeleniumServer for information on this and why it is IMPORTANT!
private Object shutdownLock;
Expand Down Expand Up @@ -609,7 +612,8 @@ protected void wireUpSslWithCyberVilliansCA(String host, SslRelay listener) {
final File root = tempDir.toFile();

// delete the temp directory when the VM stops or aborts
deleteDirectoryTask = new DeleteDirectoryTask(tempDir);
DeleteDirectoryTask deleteDirectoryTask = new DeleteDirectoryTask(tempDir);
deleteDirectoryTasks.add(deleteDirectoryTask);
Runtime.getRuntime().addShutdownHook(new Thread(deleteDirectoryTask));

// copy the cybervillains cert files to the temp directory from the classpath
Expand Down Expand Up @@ -637,8 +641,12 @@ protected void wireUpSslWithCyberVilliansCA(String host, SslRelay listener) {
}

public void cleanSslWithCyberVilliansCA(){
if(deleteDirectoryTask != null) {
deleteDirectoryTask.run();
synchronized (deleteDirectoryTasks) {
if (!deleteDirectoryTasks.isEmpty()) {
for (DeleteDirectoryTask task : deleteDirectoryTasks) {
task.run();
}
}
}
}

Expand Down

0 comments on commit ed2454a

Please sign in to comment.