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

[#2842]Replace Fastjson with Jackson #2893

Merged
merged 4 commits into from May 26, 2020

Conversation

KomachiSion
Copy link
Collaborator

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

For #2842 .
Replace Fastjson with Jackson.

Brief changelog

  • Handle serialization exception in JacksonUtils
  • Replace all fastjson with jackson in nacos-api
  • Replace fastjson with jackson for nacos-client

Verifying this change

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

Copy link
Collaborator

@yanlinly yanlinly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Override
public String toString() {	    public String toString() {
    ObjectMapper objectMapper = new ObjectMapper();	        return "Instance{" +
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);	            "instanceId='" + instanceId + '\'' +
    try {	            ", ip='" + ip + '\'' +
        return objectMapper.writeValueAsString(this);	            ", port=" + port +
    } catch (JsonProcessingException e) {	            ", weight=" + weight +
        throw new RuntimeException("Instance toJson failed", e);	            ", healthy=" + healthy +
    }	            ", enabled=" + enabled +
        ", ephemeral=" + ephemeral +
        ", clusterName='" + clusterName + '\'' +
        ", serviceName='" + serviceName + '\'' +
        ", metadata=" + metadata +
        '}';
}	    }

ephemeral 这个字段是后来增加了,如果之前没有的看一下是为空还是null,如果是null看一下是否有问题

Copy link
Collaborator

@yanlinly yanlinly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NacosDeserializationException / NacosSerializationException 看一下差别有多大,如果一个能搞定建议搞一个。 因为我看这个类大部分是一样的。 如果对比同领域都拆开以便更精细控制表达可以留着

@KomachiSion
Copy link
Collaborator Author

@Override
public String toString() {	    public String toString() {
    ObjectMapper objectMapper = new ObjectMapper();	        return "Instance{" +
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);	            "instanceId='" + instanceId + '\'' +
    try {	            ", ip='" + ip + '\'' +
        return objectMapper.writeValueAsString(this);	            ", port=" + port +
    } catch (JsonProcessingException e) {	            ", weight=" + weight +
        throw new RuntimeException("Instance toJson failed", e);	            ", healthy=" + healthy +
    }	            ", enabled=" + enabled +
        ", ephemeral=" + ephemeral +
        ", clusterName='" + clusterName + '\'' +
        ", serviceName='" + serviceName + '\'' +
        ", metadata=" + metadata +
        '}';
}	    }

ephemeral 这个字段是后来增加了,如果之前没有的看一下是为空还是null,如果是null看一下是否有问题

目前api.pojo.Instance的toString方法并没有被使用,naming中子类重写了toString方法,所以这里影响不大。

@KomachiSion
Copy link
Collaborator Author

KomachiSion commented May 26, 2020

NacosDeserializationException / NacosSerializationException 看一下差别有多大,如果一个能搞定建议搞一个。 因为我看这个类大部分是一样的。 如果对比同领域都拆开以便更精细控制表达可以留着

可以通过错误码区分。通过错误码区分的话 可以合并成一个NacosSerializationException

@yanlinly yanlinly merged commit a07b0c5 into alibaba:develop May 26, 2020
@yanlinly yanlinly changed the title [ISSUE #2842]Replace Fastjson with Jackson for nacos-api and nacos-client [#2842]Replace Fastjson with Jackson Jun 2, 2020
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 this pull request may close these issues.

None yet

3 participants