| 
45 | 45 | import java.util.LinkedHashMap;  | 
46 | 46 | import java.util.Map;  | 
47 | 47 | import java.util.Set;  | 
 | 48 | +import java.util.List;  | 
 | 49 | +import java.util.ArrayList;  | 
 | 50 | +import java.util.Collections;  | 
48 | 51 | 
 
  | 
49 | 52 | /* ------------------------------------------------------------ */  | 
50 | 53 | 
 
  | 
@@ -76,7 +79,7 @@ public class SeleniumProxyHandler extends AbstractHttpHandler {  | 
76 | 79 |       private final boolean proxyInjectionMode;  | 
77 | 80 |       private final boolean forceProxyChain;  | 
78 | 81 |       private boolean fakeCertsGenerated;  | 
79 |  | -      private DeleteDirectoryTask deleteDirectoryTask;  | 
 | 82 | +      private final List<DeleteDirectoryTask> deleteDirectoryTasks = Collections.synchronizedList(new ArrayList<DeleteDirectoryTask>());  | 
80 | 83 | 
 
  | 
81 | 84 |       // see docs for the lock object on SeleniumServer for information on this and why it is IMPORTANT!  | 
82 | 85 |       private Object shutdownLock;  | 
@@ -609,7 +612,8 @@ protected void wireUpSslWithCyberVilliansCA(String host, SslRelay listener) {  | 
609 | 612 |               final File root = tempDir.toFile();  | 
610 | 613 | 
 
  | 
611 | 614 |               // delete the temp directory when the VM stops or aborts  | 
612 |  | -              deleteDirectoryTask = new DeleteDirectoryTask(tempDir);  | 
 | 615 | +              DeleteDirectoryTask deleteDirectoryTask = new DeleteDirectoryTask(tempDir);  | 
 | 616 | +              deleteDirectoryTasks.add(deleteDirectoryTask);  | 
613 | 617 |               Runtime.getRuntime().addShutdownHook(new Thread(deleteDirectoryTask));  | 
614 | 618 | 
 
  | 
615 | 619 |               // copy the cybervillains cert files to the temp directory from the classpath  | 
@@ -637,8 +641,12 @@ protected void wireUpSslWithCyberVilliansCA(String host, SslRelay listener) {  | 
637 | 641 |       }  | 
638 | 642 | 
 
  | 
639 | 643 |       public void cleanSslWithCyberVilliansCA(){  | 
640 |  | -          if(deleteDirectoryTask != null) {  | 
641 |  | -              deleteDirectoryTask.run();  | 
 | 644 | +          synchronized (deleteDirectoryTasks) {  | 
 | 645 | +              if (!deleteDirectoryTasks.isEmpty()) {  | 
 | 646 | +                  for (DeleteDirectoryTask task : deleteDirectoryTasks) {  | 
 | 647 | +                      task.run();  | 
 | 648 | +                  }  | 
 | 649 | +              }  | 
642 | 650 |           }  | 
643 | 651 |       }  | 
644 | 652 | 
 
  | 
 | 
0 commit comments