diff --git a/src/main/java/org/commonjava/indy/service/archive/controller/ArchiveController.java b/src/main/java/org/commonjava/indy/service/archive/controller/ArchiveController.java index 9eb1ccc..5736cbd 100644 --- a/src/main/java/org/commonjava/indy/service/archive/controller/ArchiveController.java +++ b/src/main/java/org/commonjava/indy/service/archive/controller/ArchiveController.java @@ -59,14 +59,13 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -171,7 +170,7 @@ public void generate( HistoricalContentDTO content ) } recordInProgress( buildConfigId ); - Future future = generateExecutor.submit( () -> { + CompletableFuture future = CompletableFuture.runAsync( () -> { try { doGenerate( content ); @@ -189,27 +188,16 @@ public void generate( HistoricalContentDTO content ) buildConfigLocks.remove( buildConfigId ); logger.info( "<< { + // If timeout happens on generation, cancel and remove the status to make sure following generation + removeStatus( buildConfigId ); + cleanupBCWorkspace( buildConfigId ); + logger.error( "Generation timeout for buildConfigId {}", buildConfigId ); + return null; + } ); } }