You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/11/30 01:40:05 UTC
[GitHub] [incubator-eventmesh] weihubeats opened a new pull request, #2318: update JsonUtils
weihubeats opened a new pull request, #2318:
URL: https://github.com/apache/incubator-eventmesh/pull/2318
Fixes https://github.com/apache/incubator-eventmesh/issues/2317
### Motivation
*Explain the content here.*
*Explain why you want to make the changes and what problem you're trying to solve.*
### Modifications
*Describe the modifications you've done.*
### Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
- If a feature is not applicable for documentation, explain why?
- If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #2318: [ISSUE #2317] Refactoring tool class JsonUtils
Posted by GitBox <gi...@apache.org>.
jonyangx commented on code in PR #2318:
URL: https://github.com/apache/incubator-eventmesh/pull/2318#discussion_r1036591398
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/JsonUtils.java:
##########
@@ -42,29 +52,53 @@ public class JsonUtils {
* @return json string
*/
public static String serialize(Object obj) {
+ if (Objects.isNull(obj)) {
+ return null;
+ }
try {
return OBJECT_MAPPER.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new JsonException("serialize to json error", e);
}
}
+ public static <T> byte[] serialize(String topic, Class<T> data) throws JsonProcessingException {
Review Comment:
Suggest refactor throw exception . Throw RuntimeException or CheckedException.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] jonyangx merged pull request #2318: [ISSUE #2317] Refactoring tool class JsonUtils
Posted by GitBox <gi...@apache.org>.
jonyangx merged PR #2318:
URL: https://github.com/apache/incubator-eventmesh/pull/2318
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] codecov[bot] commented on pull request #2318: update JsonUtils
Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #2318:
URL: https://github.com/apache/incubator-eventmesh/pull/2318#issuecomment-1331555701
# [Codecov](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#2318](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (15ebf4c) into [master](https://codecov.io/gh/apache/incubator-eventmesh/commit/7f5915e91327cabd64fc4f07ba897ed6b6446173?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7f5915e) will **increase** coverage by `0.02%`.
> The diff coverage is `9.67%`.
```diff
@@ Coverage Diff @@
## master #2318 +/- ##
============================================
+ Coverage 11.69% 11.72% +0.02%
- Complexity 890 895 +5
============================================
Files 471 471
Lines 27810 27826 +16
Branches 3007 2999 -8
============================================
+ Hits 3253 3263 +10
- Misses 24258 24265 +7
+ Partials 299 298 -1
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...time/admin/handler/DeleteWebHookConfigHandler.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvRGVsZXRlV2ViSG9va0NvbmZpZ0hhbmRsZXIuamF2YQ==) | `26.66% <0.00%> (ø)` | |
| [...time/admin/handler/InsertWebHookConfigHandler.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvSW5zZXJ0V2ViSG9va0NvbmZpZ0hhbmRsZXIuamF2YQ==) | `26.66% <0.00%> (ø)` | |
| [...e/admin/handler/QueryWebHookConfigByIdHandler.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvUXVlcnlXZWJIb29rQ29uZmlnQnlJZEhhbmRsZXIuamF2YQ==) | `26.66% <0.00%> (ø)` | |
| [...ndler/QueryWebHookConfigByManufacturerHandler.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvUXVlcnlXZWJIb29rQ29uZmlnQnlNYW51ZmFjdHVyZXJIYW5kbGVyLmphdmE=) | `22.22% <0.00%> (ø)` | |
| [...time/admin/handler/UpdateWebHookConfigHandler.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvVXBkYXRlV2ViSG9va0NvbmZpZ0hhbmRsZXIuamF2YQ==) | `26.66% <0.00%> (ø)` | |
| [...a/org/apache/eventmesh/common/utils/JsonUtils.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi91dGlscy9Kc29uVXRpbHMuamF2YQ==) | `17.64% <12.50%> (-13.13%)` | :arrow_down: |
| [...sh/client/grpc/producer/EventMeshGrpcProducer.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXNkay1qYXZhL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY2xpZW50L2dycGMvcHJvZHVjZXIvRXZlbnRNZXNoR3JwY1Byb2R1Y2VyLmphdmE=) | `65.90% <0.00%> (-2.28%)` | :arrow_down: |
| [...rg/apache/eventmesh/runtime/trace/LogExporter.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL3RyYWNlL0xvZ0V4cG9ydGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...ime/admin/handler/RedirectClientByPathHandler.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvUmVkaXJlY3RDbGllbnRCeVBhdGhIYW5kbGVyLmphdmE=) | `84.78% <0.00%> (ø)` | |
| [...e/admin/handler/RedirectClientByIpPortHandler.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvUmVkaXJlY3RDbGllbnRCeUlwUG9ydEhhbmRsZXIuamF2YQ==) | `31.37% <0.00%> (ø)` | |
| ... and [5 more](https://codecov.io/gh/apache/incubator-eventmesh/pull/2318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #2318: [ISSUE #2317] Refactoring tool class JsonUtils
Posted by GitBox <gi...@apache.org>.
jonyangx commented on code in PR #2318:
URL: https://github.com/apache/incubator-eventmesh/pull/2318#discussion_r1036591594
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/JsonUtils.java:
##########
@@ -42,29 +52,53 @@ public class JsonUtils {
* @return json string
*/
public static String serialize(Object obj) {
+ if (Objects.isNull(obj)) {
+ return null;
+ }
try {
return OBJECT_MAPPER.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new JsonException("serialize to json error", e);
}
}
+ public static <T> byte[] serialize(String topic, Class<T> data) throws JsonProcessingException {
+ if (data == null) {
+ return null;
+ }
+ return OBJECT_MAPPER.writeValueAsBytes(data);
+ }
+
/**
* Deserialize json string to object.
*
- * @param str json string
- * @param clz object class
- * @param <T> object type
+ * @param json json string
+ * @param clz object class
+ * @param <T> object type
* @return object
*/
- public static <T> T deserialize(String str, Class<T> clz) {
+ public static <T> T deserialize(String json, Class<T> clz) {
+ if (StringUtils.isEmpty(json)) {
+ return null;
+ }
try {
- return OBJECT_MAPPER.readValue(str, clz);
+ return OBJECT_MAPPER.readValue(json, clz);
} catch (JsonProcessingException e) {
throw new JsonException("deserialize json string to object error", e);
}
}
+ public static <T> T deserialize(Class<T> clazz, byte[] bytes) throws IOException {
Review Comment:
suggest refactor throw exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org