Skip to content
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

关于SDK优化的几个建议 #4

Closed
Eric-Lee-Handyman opened this issue Jul 14, 2022 · 0 comments · Fixed by #6
Closed

关于SDK优化的几个建议 #4

Eric-Lee-Handyman opened this issue Jul 14, 2022 · 0 comments · Fixed by #6

Comments

@Eric-Lee-Handyman
Copy link

Eric-Lee-Handyman commented Jul 14, 2022

wecom-temp-119762-4ebfcce96d5ddd08d5ce4328a9579411

1. 对上传的文件大小是否有限制?如果没有,建议采用缓冲 buffer 流式写到 request body 里,不要直接设置整个 file 的字节数组进去,否则上传大文件可能导致服务端就 OOM。


wecom-temp-129110-6f3d74476166cbf417b1183285a8a581
2. GsonUtil 这里的 gsonBuilder 是单例,但是 Gson 对象不是单例,每次都会创建一个新的 Gson 对象。


wecom-temp-324856-cdb1d7f9d9fa2677eb99c4b27b059f58
3. out_trade_no 需要做下 url encode,这里要看下 httpclient 有没有帮你做了这个操作。商户支付的订单号由商户自定义生成,仅支持使用字母、数字、中划线-、下划线_、竖线|、星号这些英文半角字符的组合,abcd1234-_| encode 的结果是 abcd1234-_%7C%2A。


wecom-temp-219046-c7e91a5b9614b7406622da4221105a3b
4. ACCEPT 的 header 应该是指定 json,这里只会返回 json,为什么设置“/”?


wecom-temp-287563-6d1096a481293db5eb447c9eb3e5d46b
5. 这里是不支持泛型类的,这里如果有类似 class PrepayResponse 这种类的时候,反序列化是会失败的。


wecom-temp-239562-15c413537d124afc02ef7120af62ea5c
6. 这类接口你给用户的感觉就是不会抛任何异常,但其实你的这些代码有抛 RuntimeException 的风险,你需要把这个暴露出来,告诉用户这个接口会抛异常,让用户有感知,以便他自己决策是否需要处理。

@lianup lianup linked a pull request Jul 15, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant