@@ -519,10 +519,93 @@ public List<String> generateHandlerCall(boolean kt) {
519519 statement (indent (controllerIndent ), var (kt ), "c = this.factory.apply(ctx)" , semicolon (kt )));
520520
521521 // Leverage shared WebRoute logic for casting and type erasure!
522+ // Pass 'true' for isRpcWrapper so it safely casts List<Movie?> to List<Movie>
522523 String call = buildMethodCall (kt , paramList .toString (), false , true );
523524 boolean nullable = kt && isNullableKotlinReturn ();
524525
525- if (returnType .isVoid ()) {
526+ if (reactive != null ) {
527+ if (isReactiveVoid ) {
528+ var handler = reactive .handlerType ();
529+ if (handler .contains ("Reactor" )) {
530+ buffer .add (
531+ statement (
532+ indent (controllerIndent ),
533+ "return " ,
534+ call ,
535+ ".then(reactor.core.publisher.Mono.just(io.jooby.rpc.trpc.TrpcResponse.empty()))" ,
536+ semicolon (kt )));
537+ } else if (handler .contains ("Mutiny" )) {
538+ buffer .add (
539+ statement (
540+ indent (controllerIndent ),
541+ "return " ,
542+ call ,
543+ ".replaceWith(io.jooby.rpc.trpc.TrpcResponse.empty())" ,
544+ semicolon (kt )));
545+ } else if (handler .contains ("ReactiveSupport" )) {
546+ buffer .add (
547+ statement (
548+ indent (controllerIndent ),
549+ "return " ,
550+ call ,
551+ ".thenApply(x -> io.jooby.rpc.trpc.TrpcResponse.empty())" ,
552+ semicolon (kt )));
553+ } else if (handler .contains ("Reactivex" )) {
554+ buffer .add (
555+ statement (
556+ indent (controllerIndent ),
557+ "return " ,
558+ call ,
559+ ".toSingleDefault(io.jooby.rpc.trpc.TrpcResponse.empty())" ,
560+ semicolon (kt )));
561+ } else {
562+ buffer .add (
563+ statement (
564+ indent (controllerIndent ),
565+ "return " ,
566+ call ,
567+ ".map(x -> io.jooby.rpc.trpc.TrpcResponse.empty())" ,
568+ semicolon (kt )));
569+ }
570+ } else {
571+ var handler = reactive .handlerType ();
572+ if (kt ) {
573+ buffer .add (
574+ statement (
575+ indent (controllerIndent ),
576+ "return " ,
577+ call ,
578+ ".map { io.jooby.rpc.trpc.TrpcResponse.of(it) }" ));
579+ } else {
580+ if (handler .contains ("ReactiveSupport" )) {
581+ buffer .add (
582+ statement (
583+ indent (controllerIndent ),
584+ "return " ,
585+ call ,
586+ ".thenApply(io.jooby.rpc.trpc.TrpcResponse::of)" ,
587+ semicolon (kt )));
588+ } else if (handler .contains ("Mutiny" )) {
589+ buffer .add (
590+ statement (
591+ indent (controllerIndent ),
592+ "return " ,
593+ call ,
594+ ".onItem().transform(io.jooby.rpc.trpc.TrpcResponse::of)" ,
595+ semicolon (kt )));
596+ } else {
597+ // Reactor (Mono), RxJava (Single), etc.
598+ buffer .add (
599+ statement (
600+ indent (controllerIndent ),
601+ "return " ,
602+ call ,
603+ ".map(io.jooby.rpc.trpc.TrpcResponse::of)" ,
604+ semicolon (kt )));
605+ }
606+ }
607+ }
608+ } else if (returnType .isVoid ()) {
526609 buffer .add (statement (indent (controllerIndent ), call , semicolon (kt )));
527610 buffer .add (
528611 statement (
@@ -543,9 +626,9 @@ public List<String> generateHandlerCall(boolean kt) {
543626 if (!parameters .isEmpty ()) buffer .add (statement (indent (2 ), "}" ));
544627 buffer .add (statement ("}" , System .lineSeparator ()));
545628
546- // Shared Unchecked Cast suppression
629+ // Suppress both UNCHECKED_CAST and USELESS_CAST to keep the Kotlin compiler perfectly quiet
547630 if (isUncheckedCast ()) {
548- if (kt ) buffer .addFirst (statement ("@Suppress(\" UNCHECKED_CAST\" )" ));
631+ if (kt ) buffer .addFirst (statement ("@Suppress(\" UNCHECKED_CAST\" , \" USELESS_CAST \" )" ));
549632 else buffer .addFirst (statement ("@SuppressWarnings(\" unchecked\" )" ));
550633 }
551634
0 commit comments