SlideShare a Scribd company logo
1 of 21
Promises in Java:
Using Promises to Recover from Failure
BJ Hargrave
IBM
What is a
Promise?
2
3
• A Promise object holds the eventual result of a potentially asynchronous
task.
• A Promise is either unresolved or resolved.
• An unresolved Promise does not have the result of the associated task
available while a resolved Promise has the result of the associated task
available.
• A resolved Promise can be either resolved with a value, which means
the associated task completed successfully and supplied a result, or
resolved with a failure, which means the associated task completed
unsuccessfully and supplied an exception.
https://osgi.org/specification/osgi.cmpn/7.0.0/util.promise.html
Monadic
Chaining Promises
9
• Promises can be chained
• Methods on Promise can return a new Promise chained to the original promise
• Each promise in the chain is used to resolve the next promise in the chain with
some possible mutation of the result/failure
Chaining Example
10
Promise<String> name = getDownloadName();
Promise<URL> mirror = name.flatMap(p -> getMirror(p));
Promise<File> file = mirror.flatMap(p -> getFile(p));
Since we probably do not need the intermediate Promises, we can collapse
the chain into a single statement:
Promise<File> file = getDownloadName()
.flatMap(this::getMirror)
.flatMap(this::getFile);
Using Promises
to Recover from
Failure
11
Bnd
12
• Bnd is open source tooling to build OSGi bundles
• Bnd provides Eclipse, Maven, and Gradle plugins
• Bnd has support for Maven/Nexus, Eclipse P2, and other remote artifact
repositories
• https://github.com/bndtools/bnd
Bnd’s HttpClient
13
• For communications, Bnd has its own HttpClient class
• This is for historical reasons and to minimize dependencies on 3rd party
communications packages
• Recent reliability issues with P2 repositories on Eclipse’s download site caused
us to add retry support to the HttpClient class
• The HttpClient class already had synchronous and asynchronous request
methods
• The asynchronous request method already returns a Promise 
Changes to add Recovery support
14
• Change async method to add retry support
• Retry count with delay
• Timeout for connection and read hangs
• Server side 5XX errors and IOException failures
• Change sync method to use async method which now has retry support
• Uses a Promise blocking method to synchronously wait for result
• Through the “magic” of Promise chaining, we can further add checksum
validation and checksum failure retry logic
Recovery functions
Code
Coordinates
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.promise</artifactId>
<version>7.0.1</version>
</dependency>
CompletableFuture
18
• Introduced in Java 8 and expanded in Java 9
• A promise type in the Java platform but…
• Has a large and unwieldy API
• Odd method names
• Combines resolving promise with using promise
• Mutable
• Promise is a one-way latch – one-time resolve
• CompletableFuture can be resolved repeatedly - obtrude
19
CompletionStage Promise
thenApply map
thenCompose flatMap
exceptionally recover
handle then
thenRun onResolve
whenComplete onSuccess/onFailure
20
CompletableFuture Promise
supplyAsync/runAsync PromiseFactory.submit
allOf PromiseFactory.all
complete Deferred.resolve
completeExceptionally Deferred.fail
completedFuture PromiseFactory.resolved
failedFuture PromiseFactory.failed
<init> PromiseFactory.deferred
cancel X
delayedExecutor delay
orTimeout timeout
isDone isDone
get getValue/getFailure
Thanks!

More Related Content

Recently uploaded

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Promises in Java: Using Promises to Recover from Failure

  • 1. Promises in Java: Using Promises to Recover from Failure BJ Hargrave IBM
  • 3. 3 • A Promise object holds the eventual result of a potentially asynchronous task. • A Promise is either unresolved or resolved. • An unresolved Promise does not have the result of the associated task available while a resolved Promise has the result of the associated task available. • A resolved Promise can be either resolved with a value, which means the associated task completed successfully and supplied a result, or resolved with a failure, which means the associated task completed unsuccessfully and supplied an exception.
  • 5.
  • 6.
  • 7.
  • 9. Chaining Promises 9 • Promises can be chained • Methods on Promise can return a new Promise chained to the original promise • Each promise in the chain is used to resolve the next promise in the chain with some possible mutation of the result/failure
  • 10. Chaining Example 10 Promise<String> name = getDownloadName(); Promise<URL> mirror = name.flatMap(p -> getMirror(p)); Promise<File> file = mirror.flatMap(p -> getFile(p)); Since we probably do not need the intermediate Promises, we can collapse the chain into a single statement: Promise<File> file = getDownloadName() .flatMap(this::getMirror) .flatMap(this::getFile);
  • 11. Using Promises to Recover from Failure 11
  • 12. Bnd 12 • Bnd is open source tooling to build OSGi bundles • Bnd provides Eclipse, Maven, and Gradle plugins • Bnd has support for Maven/Nexus, Eclipse P2, and other remote artifact repositories • https://github.com/bndtools/bnd
  • 13. Bnd’s HttpClient 13 • For communications, Bnd has its own HttpClient class • This is for historical reasons and to minimize dependencies on 3rd party communications packages • Recent reliability issues with P2 repositories on Eclipse’s download site caused us to add retry support to the HttpClient class • The HttpClient class already had synchronous and asynchronous request methods • The asynchronous request method already returns a Promise 
  • 14. Changes to add Recovery support 14 • Change async method to add retry support • Retry count with delay • Timeout for connection and read hangs • Server side 5XX errors and IOException failures • Change sync method to use async method which now has retry support • Uses a Promise blocking method to synchronously wait for result • Through the “magic” of Promise chaining, we can further add checksum validation and checksum failure retry logic
  • 16. Code
  • 18. CompletableFuture 18 • Introduced in Java 8 and expanded in Java 9 • A promise type in the Java platform but… • Has a large and unwieldy API • Odd method names • Combines resolving promise with using promise • Mutable • Promise is a one-way latch – one-time resolve • CompletableFuture can be resolved repeatedly - obtrude
  • 19. 19 CompletionStage Promise thenApply map thenCompose flatMap exceptionally recover handle then thenRun onResolve whenComplete onSuccess/onFailure
  • 20. 20 CompletableFuture Promise supplyAsync/runAsync PromiseFactory.submit allOf PromiseFactory.all complete Deferred.resolve completeExceptionally Deferred.fail completedFuture PromiseFactory.resolved failedFuture PromiseFactory.failed <init> PromiseFactory.deferred cancel X delayedExecutor delay orTimeout timeout isDone isDone get getValue/getFailure

Editor's Notes

  1. HttpClient.send https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L209-L216 HttpClient.sendAsync https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L163-L207 RetryException in HttpClient.HttpConnection.doConnect https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L671-L673 https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L685-L704 Checksum in P2Indexer.fetch https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.repository/src/aQute/bnd/repository/p2/provider/P2Indexer.java#L209-L224 MavenRemoteRepository.fetch https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.repository/src/aQute/maven/provider/MavenRemoteRepository.java#L53-L101
  2. HttpClient.send https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L209-L216 HttpClient.sendAsync https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L163-L207 RetryException in HttpClient.HttpConnection.doConnect https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L671-L673 https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.bndlib/src/aQute/bnd/http/HttpClient.java#L685-L704 Checksum in P2Indexer.fetch https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.repository/src/aQute/bnd/repository/p2/provider/P2Indexer.java#L209-L224 MavenRemoteRepository.fetch https://github.com/bndtools/bnd/blob/8cc23644f75bbdbde12526500dd6444a504f875c/biz.aQute.repository/src/aQute/maven/provider/MavenRemoteRepository.java#L53-L101