[MDSAL-229] mdsal-dom-api: get rid of CheckedFuture Created: 25/Jan/17  Updated: 06/Aug/18  Resolved: 06/Aug/18

Status: Resolved
Project: mdsal
Component/s: None
Affects Version/s: None
Fix Version/s: Fluorine

Type: Epic Priority: Medium
Reporter: Robert Varga Assignee: Tom Pantelis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Relates
relates to MDSAL-283 Action support in MDSAL DOM Resolved
relates to MDSAL-284 Support Actions in Binding v2 runtime Resolved
relates to MDSAL-337 WriteTransaction.submit() should retu... Resolved

 Description   

CheckedFuture is being removed from Guava, which means that we need to make an API-incompatible change before we can upgrade.

mdsal-dom-api is one of the affected APIs, which needs cooperation with downstreams.



 Comments   
Comment by Robert Varga [ 26/Jan/17 ]

We have three options here:

1) The approach we have taken in Binding V2, where we have an explicit callback interface of two methods

2) Augment 1) with using BiConsumer<Throwable, T result>, allowing the use of lambdas, but having callers having to check failures first

3) Switch to using java.util.CompletionStage

Options 1&2 have the benefit of not being tied to a particular Future-like contract, hence are open to bridging:

RpcService s;
CompletableFuture<T> f = new CompletableFuture();

s.invokeRpc(..., (t, r) -> {
if (t != null)

{ f.completeExceptionally(t); }

else

{ f.complete(r); }

}

With the same approach being possible for Guava, Scala and others. It also does not give semblance of having a synchronous get() interface.

CompletionStage is similarly flexible, with converters for Scala being readily available – but has one wrinkle, that of CompletionStage#toCompletableFuture(). That method exposes complete(), which is not appropriate and can actually be not implemented. This would leave us vulnerable to users assuming CompletionStages can be converted and that being broken when a different implementation is substituted.

I think I prefer #2 as the core API with a library of utilities bridging callbacks to popular Future-likes:

RpcService s:
ListenableFuture<T> f = GuavaRpcServiceAdaptor.invokeRpc(s, ...);

where GuavaRpcServiceAdaptor will provide briding to the future, which can then be composited as usual.

Comment by OpenDaylight Release [ 03/May/18 ]

Since the bug is unassigned I'm currently assigning it to you.

Please assign to the relevant person. 

Generated at Wed Feb 07 20:09:09 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.