<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Long time no see,</div><div><br></div><div>So I moved one of my applications to the new API, and I don't really know what else to say other than it works for me. The only thing I'm not a fan of is the interrupted exception when calling join. Because of the interrupted exception I find myself creating a wrapper class like this:</div><div><br><div style="background-color:rgb(28,31,34);padding:0px 0px 0px 2px"><div style="color:rgb(248,248,242);font-family:"Comic Mono";white-space:pre-wrap"><p style="margin:0px"><span style="color:rgb(241,41,113)">public</span> <span style="color:rgb(241,41,113)">class</span> <span style="color:rgb(86,216,240)">STSWrapper</span> <span style="color:rgb(241,41,113)">implements</span> <span style="color:rgb(209,151,217)">AutoCloseable</span> <span style="color:rgb(216,216,216)">{</span></p><p style="margin:0px"><br></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">private</span> <span style="color:rgb(241,41,113)">final</span> <span style="color:rgb(209,151,217)">StructuredTaskScope</span><span style="color:rgb(216,216,216)"><</span><span style="color:rgb(191,164,164)">Object</span><span style="color:rgb(216,216,216)">,</span> <span style="color:rgb(191,164,164)">Void</span><span style="color:rgb(216,216,216)">></span> <span style="color:rgb(123,225,42)">scope</span> <span style="color:rgb(216,216,216)">=</span> <span style="text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(244,200,45)">StructuredTaskScope</span><span style="color:rgb(216,216,216)">.</span><span style="color:rgb(190,214,255);background-color:rgb(65,65,4)">open</span><span style="color:rgb(216,216,216)">();</span></p><p style="margin:0px"><br></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">public</span> <span style="color:rgb(216,216,216)"><</span><span style="color:rgb(191,164,164)">T</span><span style="color:rgb(216,216,216)">></span> <span style="color:rgb(209,151,217)">Supplier</span><span style="color:rgb(216,216,216)"><</span><span style="color:rgb(191,164,164)">T</span><span style="color:rgb(216,216,216)">></span> <span style="color:rgb(123,225,42)">fork</span><span style="color:rgb(216,216,216)">(</span><span style="color:rgb(209,151,217)">Callable</span><span style="color:rgb(216,216,216)"><?</span> <span style="color:rgb(241,41,113)">extends</span> <span style="color:rgb(191,164,164)">T</span><span style="color:rgb(216,216,216)">></span> <span style="color:rgb(121,171,255)">task</span><span style="color:rgb(216,216,216)">)</span> <span style="color:rgb(216,216,216)">{</span></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">return</span> <span style="color:rgb(123,225,42)">scope</span><span style="color:rgb(216,216,216)">.</span><span style="color:rgb(190,214,255)">fork</span><span style="color:rgb(216,216,216)">(</span><span style="color:rgb(121,171,255)">task</span><span style="color:rgb(216,216,216)">);</span></p><p style="margin:0px"> <span style="color:rgb(216,216,216)">}</span></p><p style="margin:0px"><br></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">public</span> <span style="color:rgb(216,216,216)"><</span><span style="color:rgb(191,164,164)">T</span><span style="color:rgb(216,216,216)">></span> <span style="color:rgb(209,151,217)">Supplier</span><span style="color:rgb(216,216,216)"><</span><span style="color:rgb(191,164,164)">T</span><span style="color:rgb(216,216,216)">></span> <span style="color:rgb(123,225,42)">fork</span><span style="color:rgb(216,216,216)">(</span><span style="color:rgb(209,151,217)">Runnable</span> <span style="color:rgb(121,171,255)">task</span><span style="color:rgb(216,216,216)">)</span> <span style="color:rgb(216,216,216)">{</span></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">return</span> <span style="color:rgb(123,225,42)">scope</span><span style="color:rgb(216,216,216)">.</span><span style="color:rgb(190,214,255)">fork</span><span style="color:rgb(216,216,216)">(</span><span style="color:rgb(121,171,255)">task</span><span style="color:rgb(216,216,216)">);</span></p><p style="margin:0px"> <span style="color:rgb(216,216,216)">}</span></p><p style="margin:0px"><br></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">public</span> <span style="color:rgb(241,41,113)">void</span> <span style="color:rgb(123,225,42)">join</span><span style="color:rgb(216,216,216)">()</span> <span style="color:rgb(216,216,216)">{</span></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">try</span> <span style="color:rgb(216,216,216)">{</span></p><p style="margin:0px"> <span style="color:rgb(123,225,42)">scope</span><span style="color:rgb(216,216,216)">.</span><span style="color:rgb(190,214,255)">join</span><span style="color:rgb(216,216,216)">();</span></p><p style="margin:0px"> <span style="color:rgb(216,216,216)">}</span> <span style="color:rgb(241,41,113)">catch</span> <span style="color:rgb(216,216,216)">(</span><span style="color:rgb(241,41,113)">final</span> <span style="color:rgb(86,216,240)">InterruptedException</span> <span style="color:rgb(241,41,113)">e</span><span style="color:rgb(216,216,216)">)</span> <span style="color:rgb(216,216,216)">{</span></p><p style="margin:0px"> <span style="color:rgb(86,216,240)">Thread</span><span style="color:rgb(216,216,216)">.</span><span style="color:rgb(190,214,255)">currentThread</span><span style="color:rgb(216,216,216)">().</span><span style="color:rgb(255,255,255)">interrupt</span><span style="color:rgb(216,216,216)">();</span></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">throw</span> <span style="color:rgb(241,41,113)">new</span> <span style="color:rgb(255,255,255)">IllegalStateException</span><span style="color:rgb(216,216,216)">(</span><span style="color:rgb(231,248,242)">e</span><span style="color:rgb(216,216,216)">);</span></p><p style="margin:0px"> <span style="color:rgb(216,216,216)">}</span></p><p style="margin:0px"> <span style="color:rgb(216,216,216)">}</span></p><p style="margin:0px"><br></p><p style="margin:0px"> <span style="color:rgb(255,255,255)">@</span><span style="color:rgb(255,255,255)">Override</span></p><p style="margin:0px"> <span style="color:rgb(241,41,113)">public</span> <span style="color:rgb(241,41,113)">void</span> <span style="color:rgb(123,225,42)">close</span><span style="color:rgb(216,216,216)">()</span> <span style="color:rgb(216,216,216)">{</span></p><p style="margin:0px"> <span style="color:rgb(123,225,42)">scope</span><span style="color:rgb(216,216,216)">.</span><span style="color:rgb(190,214,255)">close</span><span style="color:rgb(216,216,216)">();</span></p><p style="margin:0px"> <span style="color:rgb(216,216,216)">}</span></p><p style="margin:0px"><span style="color:rgb(216,216,216)">}</span></p><p style="font-size:18pt;margin:0px"></p></div></div></div><div><br></div><div>I assume there are good reasons to not make it like CompletableFuture's unchecked join method, so if nothing can be done I'll just leave it at that.<br><br>The application itself is nothing but an orchestration api where we make downstream calls to other services to get and combine data. I didn't test anything other than the default joiner because if any of the calls fail we want to terminate the request immediately (they were also all different types). I didn't need to check the state of the individual tasks, so I used a supplier for the wrapper.</div><div><br>Most of the other services I work on follow similar requirements so I don't think I'll be able to test any other joiners other than the default on real services.<br><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Cheers, Josiah.</div></div><input name="virtru-metadata" type="hidden" value="{"email-policy":{"disableCopyPaste":false,"disablePrint":false,"disableForwarding":false,"enableNoauth":false,"expires":false,"sms":false,"expirationNum":1,"expirationUnit":"days","expirationDate":null,"isManaged":false},"attachments":{},"compose-id":"1","compose-window":{"secure":false}}"></div>
</div>
</div>