Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. @Override
  2. public CompletableFuture<File> processDownload( final FileDownload fileDownload ) {
  3. Objects.requireNonNull( fileDownload );
  4. fileDownload.setDirectory( getTmpDirectoryPath() );
  5. CompletableFuture<File> future = CompletableFuture.supplyAsync( fileDownload, executorService );
  6. future... throwable -> {
  7. if ( throwable != null ) {
  8. logError( throwable );
  9. }
  10. ...
  11. return null; // client won't receive file.
  12. } );
  13. return future;
  14.  
  15. }
  16.  
  17. future = future.whenComplete((t, ex) -> {
  18. if (ex != null) {
  19. logException(ex);
  20. }
  21. });
  22.  
  23. future = future.handle((t, ex) -> {
  24. if (ex != null) {
  25. logException(ex);
  26. return null;
  27. } else {
  28. return t;
  29. }
  30. });
  31.  
  32. future = future.exceptionally(ex -> {
  33. logException(ex);
  34. return null;
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement