-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
Just unify the MD5 generation on both sides using the same utility class |
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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.
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 stringVerifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.