Replies: 10 comments 4 replies
-
If I add an Then it generates following problem: So it’s not a possible solution. |
Beta Was this translation helpful? Give feedback.
-
Here are the dependencies I’m using: <dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency> In addition I use |
Beta Was this translation helpful? Give feedback.
-
You can always do In your particular case, it may be sufficient to replace one of the |
Beta Was this translation helpful? Give feedback.
-
@benkard Now I have further problem: From above screenshot, you can see that by using If I enable it by using then it will produce the following error: This is because now there is one extra level of nested I have no idea how to further fixing it. |
Beta Was this translation helpful? Give feedback.
-
I have separated out the root cause: From above screenshot you can see I have aligned two nested levels of So the |
Beta Was this translation helpful? Give feedback.
-
@benkard I simplified the code did some further tests, and here’s the result: So the root cause seems because of the Do you have any idea on this? |
Beta Was this translation helpful? Give feedback.
-
@benkard By casting the I guess this problem is solved, if I have any more problem I’ll start a new thread. Thanks for help! In addition here’s all the working combinations if anyone else need it: // All the working methods
@ServerRequestFilter
public Uni<RestResponse<Void>> check(ContainerRequestContext ctx) throws Exception {
return Uni.createFrom().nullItem();
}
@ServerRequestFilter
public Uni<RestResponse<Void>> check2(ContainerRequestContext ctx) throws Exception {
return null;
}
@ServerRequestFilter
public Uni<RestResponse<Void>> check3(ContainerRequestContext ctx) throws Exception {
return Uni.createFrom().nullItem().onItem().transform(
_ok -> null
);
}
@ServerRequestFilter
public Uni<RestResponse<Void>> check4(ContainerRequestContext ctx) throws Exception {
return Uni.createFrom().nullItem().onItem().transformToUni(
_ok -> (Uni<RestResponse<Void>>) null
).onFailure().recoverWithItem(
_bad -> null
);
}
@ServerRequestFilter
public Uni<RestResponse<Void>> check4b(ContainerRequestContext ctx) throws Exception {
return Uni.createFrom().nullItem().onItem().transformToUni(
_ok -> (Uni<RestResponse<Void>>) null
).onFailure().recoverWithItem(
_bad -> RestResponse.status(Response.Status.FORBIDDEN)
);
}
@ServerRequestFilter
public Uni<RestResponse<Void>> check5(ContainerRequestContext ctx) throws Exception {
return Uni.createFrom().nullItem().onItem().transformToUni(
_ok -> Uni.createFrom().nullItem().onItem().transform(_ok2 -> null)
);
} |
Beta Was this translation helpful? Give feedback.
-
Additional example: @ServerRequestFilter
public Uni<RestResponse<Void>> check6(ContainerRequestContext ctx) throws Exception {
return Uni.createFrom().nullItem().onItem().transformToUni(
_ok -> Uni.createFrom()
.nullItem()
.onItem()
.transformToUni(_ok2 -> (Uni<RestResponse<Void>>) null)
.onFailure().recoverWithItem(
err -> null
)
).onFailure().recoverWithItem(
err -> null
);
} |
Beta Was this translation helpful? Give feedback.
-
After applying what I have learned from this thread, I finally make my filter work. But here is one more note to take: As the screenshot shown above, I can’t directly use In addition, I can’t use And it doesn’t conform to the return type, so I have to cast the type by myself: return Uni.createFrom().item((RestResponse<Void>) null); At last, in Anyway I have learned a lot and it’s fun! |
Beta Was this translation helpful? Give feedback.
-
This is really great. Well documented and I learned so much in this single thread than what I did in part week. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to implement a
@ServerRequestFilter
, and it calls several levels of async calls, which generates nestedUnis
, and here is the screenshot of the code:However this makes a problem that makes the return type has nested level of
Unis
:And this breaks the convention of
@ServerRequestFilter
:Is there any solution to my problem?
Beta Was this translation helpful? Give feedback.
All reactions