scala-java8-compat icon indicating copy to clipboard operation
scala-java8-compat copied to clipboard

Override mutating CompletableFuture methods to throw UOE

Open viktorklang opened this issue 10 years ago • 12 comments

In private class CF[T] extends CompletableFuture[T] with (Try[T] => Unit) { as an example. So if a Java user downcasts to CompletableFuture, it won't go haywire.

viktorklang avatar Mar 27 '14 10:03 viktorklang

@viktorklang Is this still relevant if we start to support toCompletableFuture as proposed in #49 ?

retronym avatar Jul 28 '15 12:07 retronym

No, I am still unsure what the actual behavior will be once we have 2 disparate completion venues (this Issue wants to remove one of the venues).

What's your thinking on how it ought to work?

viktorklang avatar Jul 28 '15 14:07 viktorklang

I'm not 100% sure what problem we're trying to solve: I'd appreciate a test case to show what you mean by haywire.

Do you mean that a user might expect the following assertion to hold?

val p = Promise[String]()
val cs = toJava(p.future)
cs.asInstanceOf[CompletionStage].complete("done")
assert(p.isComplete)

That was what I was trying to explore in https://github.com/retronym/scala-java8-compat/commit/98054150e505dd1796273da9f270b12c5965c4c8

retronym avatar Jul 29 '15 05:07 retronym

What happens when both the s.c.Future and the CompletableFuture gets completed, in different ordering? What happens when obtrudeValue / obtrudeException is used?

viktorklang avatar Jul 29 '15 07:07 viktorklang

I think the semantics should be the same as if two places complete a completablefuture.

retronym avatar Jul 29 '15 07:07 retronym

@retronym But obtrude has different semantics?

viktorklang avatar Jul 29 '15 08:07 viktorklang

I would really appreciate some help to get this right. As I'm not an expert in this domain, but I do understand test cases, would you be able to contribute some (passing or failing)? Otherwise, please assume I know nothing and elaborate a little bit more with your review comments :)

retronym avatar Jul 29 '15 08:07 retronym

I won't be able to have a look at it until next week, if that's OK?

viktorklang avatar Jul 29 '15 08:07 viktorklang

No probs, this isn't urgent, I just wanted to get the ball rolling.

retronym avatar Jul 29 '15 08:07 retronym

Great, ping me on monday so we can see how to deal with this.

viktorklang avatar Jul 29 '15 08:07 viktorklang

@viktorklang @retronym It's well past monday, just figured you would want a ping anyway?

ryantheleach avatar Nov 05 '15 11:11 ryantheleach

LOL

Thanks @ryantheleach, I'll have a look at it when I can (swamped this week). :)

viktorklang avatar Nov 05 '15 11:11 viktorklang