@@ -414,7 +414,9 @@ public void init() {
414414 ctx .json (context .get ().workflow .getWorkflowContext ());
415415 } catch (WorkflowError e ) {
416416 Log .err ("Failed to load workflow" , e );
417- ctx .status (400 ).json (Map .of ("message" , "Failed to load workflow: " + e .getMessage ()));
417+ HashMap <String , String > result = new HashMap <>();
418+ result .put ("message" , "Failed to load workflow: " + e .getMessage ());
419+ ctx .status (400 ).json (result );
418420 }
419421 });
420422
@@ -444,25 +446,30 @@ public void init() {
444446 gameStats .put ("unitsCreated" , Vars .state .stats .unitsCreated );
445447 gameStats .put ("wavesLasted" , Vars .state .stats .wavesLasted );
446448
447- data .put ("executors" , java .util .Map .of (
448- "backgroundExecutor" , context .get ().BACKGROUND_TASK_EXECUTOR .toString (), //
449- "backgroundScheduler" , context .get ().BACKGROUND_SCHEDULER .toString ()//
450- ));
449+ HashMap <String , String > executors = new HashMap <>();
450+ executors .put ("backgroundExecutor" , context .get ().BACKGROUND_TASK_EXECUTOR .toString ());
451+ executors .put ("backgroundScheduler" , context .get ().BACKGROUND_SCHEDULER .toString ());
452+
453+ data .put ("executors" , executors );
451454
452455 data .put ("gameStats" , gameStats );
453456 data .put ("locales" , Vars .locales );
454457 data .put ("threads" ,
455458 Thread .getAllStackTraces ().keySet ().stream ()
456459 .sorted ((a , b ) -> a .getName ().compareTo (b .getName ()))
457- .map (thread -> java .util .Map .of (
458- "id" , thread .getId (),
459- "name" , thread .getName (),
460- "state" , thread .getState ().name (),
461- "group" ,
462- thread .getThreadGroup () == null ? "null" : thread .getThreadGroup ().getName (),
463- "stacktrace" ,
464- Arrays .asList (thread .getStackTrace ()).stream ().map (stack -> stack .toString ())
465- .collect (Collectors .toList ())))
460+ .map (thread -> {
461+ HashMap <String , Object > info = new HashMap <>();
462+
463+ info .put ("id" , thread .getId ());
464+ info .put ("name" , thread .getName ());
465+ info .put ("state" , thread .getState ().name ());
466+ info .put ("group" , thread .getThreadGroup () == null ? "null"
467+ : thread .getThreadGroup ().getName ());
468+ info .put ("stacktrace" , Arrays .asList (thread .getStackTrace ()).stream ()
469+ .map (stack -> stack .toString ()).collect (Collectors .toList ()));
470+
471+ return info ;
472+ })
466473 .collect (Collectors .toList ()));
467474
468475 data .put ("activeRequest" , activeRequests .values ());
@@ -474,14 +481,18 @@ public void init() {
474481 maps .add (tags );
475482 });
476483 data .put ("maps" ,
477- Vars .maps .all ().map (map -> java .util .Map .of (
478- "name" , map .name (), //
479- "author" , map .author (), //
480- "file" , map .file .absolutePath (),
481- "tags" , map .tags ,
482- "description" , map .description (),
483- "width" , map .width ,
484- "height" , map .height )).list ());
484+ Vars .maps .all ().map (map -> {
485+ HashMap <String , Object > info = new HashMap <>();
486+ info .put ("name" , map .name ()); //
487+ info .put ("author" , map .author ()); //
488+ info .put ("file" , map .file .absolutePath ());
489+ info .put ("tags" , map .tags );
490+ info .put ("description" , map .description ());
491+ info .put ("width" , map .width );
492+ info .put ("height" , map .height );
493+
494+ return info ;
495+ }).list ());
485496 data .put ("mods" , Vars .mods .list ().map (mod -> mod .meta .toString ()).list ());
486497 data .put ("votes" , context .get ().voteHandler .votes );
487498
@@ -499,7 +510,9 @@ public void init() {
499510 ctx .json (res );
500511 });
501512
502- app .sse ("workflow/events" , client -> {
513+ app .sse ("workflow/events" , client ->
514+
515+ {
503516 client .keepAlive ();
504517 client .sendComment ("connected" );
505518
@@ -514,8 +527,9 @@ public void init() {
514527 Log .err ("Unhandled api exception" , exception );
515528
516529 try {
517- var result = java .util .Map .of ("message" ,
518- exception .getMessage () == null ? "Unknown error" : exception .getMessage ());
530+
531+ HashMap <String , Object > result = new HashMap <>();
532+ result .put ("message" , exception .getMessage () == null ? "Unknown error" : exception .getMessage ());
519533 ctx .status (500 ).json (result );
520534 } catch (Exception e ) {
521535 Log .err ("Failed to create error response" , e );
0 commit comments