@@ -15,33 +15,36 @@ public class TaskRunner {
1515 this .doShutdown = doShutdown ;
1616 }
1717
18- private String taskGetNumItemsFromRequest () {
18+ private String taskGetNumItemsFromRequest () throws Exception {
1919 String result = "" ;
2020 try {
2121 result = new Worker ().doWork (taskDelayInMillis , "taskGetNumItemsFromRequest" , "numitems-5150" );
2222 } catch (Exception ex ) {
2323 System .err .println ("TRACER TaskRunner num-items caught ex: " + ex );
24+ throw ex ;
2425 }
2526 return result ;
2627 }
2728
28- private String taskGetPriceFromDB () {
29+ private String taskGetPriceFromDB () throws Exception {
2930 String result = "" ;
3031 try {
3132 result = new Worker ().doWork (taskDelayInMillis , "taskGetPriceFromDB" , "price-6160" );
3233 } catch (Exception ex ) {
3334 System .err .println ("TRACER TaskRunner get-price caught ex: " + ex );
35+ throw ex ;
3436 }
3537 return result ;
3638 }
3739
3840 public String run () throws Exception {
39- var result = "" ;
41+ var result = "error" ;
42+
4043 try (var scope = new StructuredTaskScope .ShutdownOnFailure ()) {
4144 var numOrders = scope .fork (() -> taskGetNumItemsFromRequest ());
4245 var price = scope .fork (() -> taskGetPriceFromDB ());
4346
44- try { Thread .sleep (500L ); } catch (Exception ex ) {}
47+ try { Thread .sleep (1000L ); } catch (Exception ex ) {}
4548
4649 if (doShutdown ) {
4750 System .out .println ("TRACER TaskRunner shutting down" );
@@ -51,17 +54,11 @@ public String run() throws Exception {
5154 }
5255
5356 scope .join ();
57+ scope .throwIfFailed ();
5458
55- try {
56- scope .throwIfFailed ();
59+ result = numOrders .resultNow () + " " + price .resultNow ();
5760
58- result = numOrders .resultNow () + " " + price .resultNow ();
59- } catch (Exception ex ) {
60- if (ex != null ) {
61- System .err .println ("TRACER TaskRunner inner caught ex: " + ex .getClass ());
62- System .err .println ("TRACER TaskRunner inner caught ex: " + ex .getMessage ());
63- }
64- }
61+ System .out .println ("TRACER TaskRunner post result" );
6562 } catch (Exception ex ) {
6663 if (ex != null ) {
6764 System .err .println ("TRACER TaskRunner caught ex: " + ex .getClass ());
0 commit comments