Source:
void setup(final ExecutableFlow flow) throws ExecutorManagerException { final ProjectFileHandler projectFileHandler = null; File tempDir = null; try { final ProjectDirectoryMetadata project = new ProjectDirectoryMetadata( flow.getProjectId(), flow.getVersion()); final long flowPrepStartTime = System.currentTimeMillis(); tempDir = downloadProjectIfNotExists(project, flow.getExecutionId()); LOGGER.info("Project is setup for execution {}", flow.getExecutionId()); long criticalSectionStartTime = -1; File execDir = null; synchronized (this) { LOGGER.info("Setting up execution dir for {}", flow.getExecutionId()); criticalSectionStartTime = System.currentTimeMillis(); if (!project.getInstalledDir().exists() && tempDir != null) { if (this.projectCacheCleaner.isPresent()) { this.projectCacheCleaner.get() .deleteProjectDirsIfNecessary(project.getDirSizeInByte()); } Files.move(tempDir.toPath(), project.getInstalledDir().toPath()); } final long start = System.currentTimeMillis(); execDir = setupExecutionDir(project.getInstalledDir(), flow); final long end = System.currentTimeMillis(); LOGGER.info("Setting up execution dir took sec(s)", execDir, (end - start) / 1000); } final long flowPrepCompletionTime = System.currentTimeMillis(); LOGGER.info("Flow preparation completed in sec(s), out ot which sec(s) was spent inside " + "critical section. [execid: {}, path: {}]", (flowPrepCompletionTime - flowPrepStartTime) / 1000, (flowPrepCompletionTime - criticalSectionStartTime) / 1000, flow.getExecutionId(), execDir.getPath()); } catch (final Exception ex) { FileIOUtils.deleteDirectorySilently(tempDir); LOGGER.error("Error in preparing flow execution {}", flow.getExecutionId(), ex); throw new ExecutorManagerException(ex); } catch (final Throwable t) { FileIOUtils.deleteDirectorySilently(tempDir); LOGGER.error("Error in preparing flow execution {}", flow.getExecutionId(), t); throw new ExecutorManagerException( "Error in preparing flow execution " + flow.getExecutionId(), t); } finally { if (projectFileHandler != null) { projectFileHandler.deleteLocalFile(); } } }

Target:
void setup(final ExecutableFlow flow) throws ExecutorManagerException { final ProjectFileHandler projectFileHandler = null; File tempDir = null; try { final ProjectDirectoryMetadata project = new ProjectDirectoryMetadata( flow.getProjectId(), flow.getVersion()); final long flowPrepStartTime = System.currentTimeMillis(); tempDir = downloadProjectIfNotExists(project, flow.getExecutionId()); LOGGER.info("Project is setup for execution {}", flow.getExecutionId()); long criticalSectionStartTime = -1; File execDir = null; synchronized (this) { LOGGER.info("Setting up execution dir for {}", flow.getExecutionId()); criticalSectionStartTime = System.currentTimeMillis(); if (!project.getInstalledDir().exists() && tempDir != null) { if (this.projectCacheCleaner.isPresent()) { this.projectCacheCleaner.get() .deleteProjectDirsIfNecessary(project.getDirSizeInByte()); } Files.move(tempDir.toPath(), project.getInstalledDir().toPath()); } final long start = System.currentTimeMillis(); execDir = setupExecutionDir(project.getInstalledDir(), flow); final long end = System.currentTimeMillis(); LOGGER.info("Setting up execution dir took sec(s)", execDir, (end - start) / 1000); } final long flowPrepCompletionTime = System.currentTimeMillis(); LOGGER.info("Flow preparation completed in sec(s), out ot which sec(s) was spent inside " + "critical section. [execid: {}, path: {}]", (flowPrepCompletionTime - flowPrepStartTime) / 1000, (flowPrepCompletionTime - criticalSectionStartTime) / 1000, flow.getExecutionId(), execDir.getPath()); } catch (final Exception ex) { FileIOUtils.deleteDirectorySilently(tempDir); LOGGER.error("Error in preparing flow execution {}", flow.getExecutionId(), ex); throw new ExecutorManagerException(ex); } finally { if (projectFileHandler != null) { projectFileHandler.deleteLocalFile(); } } }