-
Notifications
You must be signed in to change notification settings - Fork 962
Fix asJson method to pass mapper in WebClientRequestPreparation #5512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Motivation: Resolve issue line#5454 with proper handling of ObjectMapper instance. Modifications: Pass the provided ObjectMapper to the ResponseAs.json method: asJson(Class<? extends T> clazz, ObjectMapper mapper). Result: The asJson method pass the provided ObjectMapper instance to the ResponseAs.json method as it should.
@@ -240,7 +240,7 @@ public <T> FutureTransformingRequestPreparation<ResponseEntity<T>> asJson(Class< | |||
ObjectMapper mapper) { | |||
requireNonNull(clazz, "clazz"); | |||
requireNonNull(mapper, "mapper"); | |||
return asEntity(ResponseAs.json(clazz)); | |||
return asEntity(ResponseAs.json(clazz, mapper)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a unit test to detect unexpected changes in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the test code in WebClientRequestPreparationTest.
You can review the changes in the following commit: 8bdcb3e.
However, I am not sure it helps detect unexpected changes in the future.
Could you let me know which test cases should be added?
@YangSiJun528 Gentle ping. 😉 |
Sorry for the delayed response. I will add the unit test as requested. |
be2bcd1
to
ae7754c
Compare
I mistakenly merged main into this PR branch, so I had to force reset it to undo the changes. |
private static WebClient client; | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
client = WebClient.of(server.httpUri()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't have to have this as a field. We could just use the client in the method.
core/src/test/java/com/linecorp/armeria/client/WebClientRequestPreparationTest.java
Show resolved
Hide resolved
I have updated the test code to reflect the review comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank @YangSiJun528! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
Well done, @YangSiJun528! 😄 |
…#5512) Motivation: Resolve issue line#5454 with proper handling of ObjectMapper instance. Modifications: - Pass the provided ObjectMapper to the ResponseAs.json method: `WebClientRequestPreparation.asJson(Class<? extends T> clazz, ObjectMapper mapper)`. Result: - The `asJson` method pass the provided ObjectMapper instance to the `ResponseAs.json` method as it should - Closes line#5454
Motivation:
Resolve issue #5454 with proper handling of ObjectMapper instance.
Modifications:
WebClientRequestPreparation.asJson(Class<? extends T> clazz, ObjectMapper mapper)
.Result:
asJson
method pass the provided ObjectMapper instance to theResponseAs.json
method as it should