apache / shenyu

Apache ShenYu is a Java native API Gateway for service proxy, protocol conversion and API governance.
https://shenyu.apache.org/
Apache License 2.0
8.41k stars 2.92k forks source link

[BUG] WebFluxResultUtils shenyuResult the last request result was not cleared #2578

Closed janusdo closed 2 years ago

janusdo commented 2 years ago

Is there an existing issue for this?

Current Behavior

In the second request error, the data value is the last response data, WebFluxResultUtils shenyuResult the last request result was not cleared.

First request result { "code": 200, "data": { "id": "4c73bc08-bdf3-46d8-ba6c-1b5175ec57d1" }, "requestId": "b488575b-9315-4266-91be-d2d69d171af0", "message": "Success!" }

Second request result { "code": 400, "data": { "id": "4c73bc08-bdf3-46d8-ba6c-1b5175ec57d1" }, "requestId": "e86ecfde-34c6-44fb-8b34-c4261688025e", "message": "Sign is not pass!" }

How to customize sorting by code, message, requestid and data?

Thanks!

Expected Behavior

Second request result { "code": 400, "message": "Sign is not pass!", "requestId": "e86ecfde-34c6-44fb-8b34-c4261688025e" }

Steps To Reproduce

No response

Environment

ShenYu version(s): 2.4.1

Debug logs

No response

Anything else?

No response

yu199195 commented 2 years ago

this is result by shenyu?

{
"code": 400,
"data": {
"id": "4c73bc08-bdf3-46d8-ba6c-1b5175ec57d1"
},
"requestId": "e86ecfde-34c6-44fb-8b34-c4261688025e",
"message": "Sign is not pass!"
}
qicz commented 2 years ago

maybe this data is not from shenyu, shenyu response contains not the request id. @janusdo

janusdo commented 2 years ago

requestId is my custom attribute. A unique ID is generated for each request.

When calling WebFluxResultUtils.result, If result is error, shenyResult.clear() Is not called.

qicz commented 2 years ago

requestId is my custom attribute. A unique ID is generated for each request.

When calling WebFluxResultUtils.result, If result is error, shenyResult.clear() Is not called.

2.4.1 or last version from master ?

janusdo commented 2 years ago

last version from master

qicz commented 2 years ago

last version from master

Do you use the put function to add data?

janusdo commented 2 years ago

yes, use put function to add data. When the result is JSON,the map is not reset.

qicz commented 2 years ago

yes, use put function to add data. When the result is JSON,the map is not reset.

I have been already fixed this bug. You can wait for the merge and try again.

qicz commented 2 years ago

@janusdo After discussion, we decided to transform this feature and open up the format of the data for users to customize according to the situation.