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

[ISSUE #2618]modify config service md5 generation method #2647

Merged
merged 3 commits into from
Apr 21, 2020
Merged

[ISSUE #2618]modify config service md5 generation method #2647

merged 3 commits into from
Apr 21, 2020

Conversation

wangweizZZ
Copy link
Collaborator

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

What is the purpose of the change

#2618

Brief changelog

modify com.alibaba.nacos.common.utils.Md5Utils
use org.apache.commons.codec generate md5 string

Verifying this change

XXXX

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.

@CLAassistant
Copy link

CLAassistant commented Apr 18, 2020

CLA assistant check
All committers have signed the CLA.

@chuntaojun
Copy link
Collaborator

Just unify the MD5 generation on both sides using the same utility class

@chuntaojun
Copy link
Collaborator

Drop the MD5 utility classes into the common module

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.client.config.utils;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The utility class is already at the end of Utils

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sorry,I don't understand what you mean. the utility class is move from client module to common module. do you mean name should like MD5Utils end with Utils?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes

common/pom.xml Outdated
@@ -44,6 +44,11 @@
<artifactId>commons-io</artifactId>
</dependency>

<dependency>
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this dependency is not used, so it can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, i agree

@@ -67,7 +66,7 @@
public Object interfacePublishSingle(ProceedingJoinPoint pjp, HttpServletRequest request,
HttpServletResponse response, String dataId, String group, String tenant,
String content) throws Throwable {
final String md5 = content == null ? null : Md5Utils.getMD5(content, Constants.ENCODE);
final String md5 = content == null ? null : MD5.getInstance().getMD5String(content);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the MD5 implementation will not be as good as the MD5Utils you delete because of the locking mechanism, you can only modify the string method of MD5Utils

old

return new BigInteger(1, messageDigest.digest(bytes)).toString(HEX_VALUE_COUNT);

new

public String bytes2string(byte[] bt) {
        int l = bt.length;

        char[] out = new char[l << 1];

        for (int i = 0, j = 0; i < l; i++) {
            out[j++] = digits[(0xF0 & bt[i]) >>> 4];
            out[j++] = digits[0x0F & bt[i]];
        }

        return new String(out);
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your patient.I choose this one ,consider MessageDigest classes is instantiated only once.

@chuntaojun chuntaojun merged commit 900fa66 into alibaba:develop Apr 21, 2020
@yanlinly yanlinly added this to the 1.3.0 milestone May 14, 2020
@yanlinly yanlinly mentioned this pull request May 15, 2020
5 tasks
@yanlinly yanlinly mentioned this pull request Jun 5, 2020
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants