<div dir="ltr"><div class="markdown-here-wrapper" style=""><blockquote style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:0px 0px 1.2em!important"> don’t think there would be even an easy way around this, because you<br>can’t reasonably create a common base type for the two results</p>
</blockquote>
<p style="margin:0px 0px 1.2em!important">I don’t think I understand your point, STS receives the parameter of the return type, so you can do <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">STS#handleSuccess(T result, ...)</code>.<br>And similarly, you don’t have a parameter for the exception type so you can’t do this for <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">STS#handleFailure</code></p>
<blockquote style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:0px 0px 1.2em!important">why the <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">Callable</code> is being passed around</p>
</blockquote>
<p style="margin:0px 0px 1.2em!important">It can, by using type-checks in some custom STS implementation, but I agree that it shouldn’t be the normal behavior.</p>
<div title="MDH:Jmd0O8KgCgrCoGRvbid0IHRoaW5rIHRoZXJlIHdvdWxkIGJlIGV2ZW4gYW4gZWFzeSB3YXkgYXJv
dW5kIHRoaXMsIGJlY2F1c2UgeW91PGJyPmNhbid0IHJlYXNvbmFibHkgY3JlYXRlIGEgY29tbW9u
IGJhc2UgdHlwZSBmb3IgdGhlIHR3byByZXN1bHRzPGRpdj48YnI+PC9kaXY+PGRpdj5JIGRvbid0
IHRoaW5rIEkgdW5kZXJzdGFuZCB5b3VyIHBvaW50LCBTVFMgcmVjZWl2ZXMgdGhlIHBhcmFtZXRl
ciBvZiB0aGUgcmV0dXJuIHR5cGUsIHNvIHlvdSBjYW4gZG8gYFNUUyNoYW5kbGVTdWNjZXNzKFQg
cmVzdWx0LCAuLi4pYC48L2Rpdj48ZGl2PkFuZCBzaW1pbGFybHksIHlvdSBkb24ndCBoYXZlIGEg
cGFyYW1ldGVyIGZvciB0aGUgZXhjZXB0aW9uIHR5cGUgc28geW91IGNhbid0IGRvIHRoaXMgZm9y
IGBTVFMjaGFuZGxlRmFpbHVyZWA8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PiZndDsgd2h5IHRo
ZSBgQ2FsbGFibGVgIGlzIGJlaW5nIHBhc3NlZCBhcm91bmQ8L2Rpdj48ZGl2Pjxicj48L2Rpdj48
ZGl2Pkl0IGNhbiwgYnkgdXNpbmcgdHlwZS1jaGVja3MgaW4gc29tZSBjdXN0b20gU1RTIGltcGxl
bWVudGF0aW9uLCBidXQgSSBhZ3JlZSB0aGF0IGl0IHNob3VsZG4ndCBiZSB0aGUgbm9ybWFsIGJl
aGF2aW9yLjwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, May 14, 2023 at 8:22 PM Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com" target="_blank">attila.kelemen85@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> If we are already on the subject, as you stated, STS#handleComplete has only 2 possible states, success and failure, so why not completely separate them:<br>
><br>
> STS#handleSuccess(T result, Callable task [, boolean cancelled])<br>
> STS#handleFailure(Throwable exception, Callable task [, boolean cancelled]) (note that we can’t use parameterize exception here)<br>
><br>
<br>
I don't think there would be even an easy way around this, because you<br>
can't reasonably create a common base type for the two results<br>
(previously - as Rémi said - I thought sealed interfaces would be<br>
solution, but that is impossible due to the generic parameter), unless<br>
you pass the `TaskHandle` where you could call the appropriate method<br>
based on the state.<br>
<br>
Also, I'm not even sure why the `Callable` is being passed around<br>
here. What is STS supposed to do with that? It can't really use it as<br>
an ID, because you might be running the same `Callable` instance<br>
multiple times. Also, passing it just makes you nervous wrapping it<br>
(which you might be forced to do in some cases). If a feature of being<br>
able to distinguish between tasks is needed, then `fork` should allow<br>
associating an additional custom object with the submitted `Callable`.<br>
But - to me - it seems that is going too far with STS.<br>
</blockquote></div><br clear="all"><div><br></div><span>-- </span><br><div dir="ltr"><div dir="ltr">Holo The Wise Wolf Of Yoitsu</div></div>