code: void forcedUndeployScan() {
  
          if (acquireScanLock()) {
              try {
                  ROOT_LOGGER.tracef("Performing a post-boot forced undeploy scan for scan directory %s", deploymentDir.getAbsolutePath());
                  ScanContext scanContext = new ScanContext(deploymentOperations);
  
                  // Add remove actions to the plan for anything we count as
                  // deployed that we didn't find on the scan
                  for (Map.Entry<String, DeploymentMarker> missing : scanContext.toRemove.entrySet()) {
                      // remove successful deployment and left will be removed
                      if (scanContext.registeredDeployments.containsKey(missing.getKey())) {
                          scanContext.registeredDeployments.remove(missing.getKey());
                      }
                  }
                  Set<String> scannedDeployments = new HashSet<String>(scanContext.registeredDeployments.keySet());
                  scannedDeployments.removeAll(scanContext.persistentDeployments);
  
                  List<ScannerTask> scannerTasks = scanContext.scannerTasks;
                  for (String toUndeploy : scannedDeployments) {
                      scannerTasks.add(new UndeployTask(toUndeploy, deploymentDir, scanContext.scanStartTime, true));
                  }
                  try {
                      executeScannerTasks(scannerTasks, deploymentOperations, true);
                  } catch (InterruptedException e) {
                      Thread.currentThread().interrupt();
                  }
  
                  ROOT_LOGGER.tracef("Forced undeploy scan complete");
              } catch (Exception e) {
                  ROOT_LOGGER.scanException(e, deploymentDir.getAbsolutePath());
              } finally {
                  releaseScanLock();
              }
          }
      }
docs: Perform a post-boot scan to remove any deployments added during boot that failed to deploy properly.
  This method isn't private solely to allow a unit test in the same package to call it.