Skip to content

Make ListenableFuture lambda compliant [SPR-11820] #16440

@spring-projects-issues

Description

@spring-projects-issues

Sébastien Deleuze opened SPR-11820 and commented

When building a Spring 4 / Java 8 application, we can't use lambda with ListenableFuture since ListenableFutureCallback is not a functional interface (2 methods to implement).

5 proposals to improve this:

  1. Modify ListenableFutureCallback: it will break API so it is not an option (even if it would be the cleaner solution)
  2. Add another method to ListenableFuture with a callback parameter with just one method like mongoDB MongoFuture and SingleResultCallback.
  3. Add new fluent methods to ListenableFuture with single method callbacks allowing to write code like listenableFuture.onSuccess(...).onFailure(...)
  4. Add default implementation to ListenableFutureCallback#onFailure() interface : not possible since it would require Java 8 for main code
  5. Change nothing and wait for a future version of Spring that will require Java 8 and use native CompletableFuture

My prefered solution is the 3rd.

Any feedback or advice ?


Affects: 4.0.5

Issue Links:

Referenced from: commits 4e25a14, 86e8bda

1 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions