为什么这个代码会为每个调用打印不同的结果?
log.info("String to MD5 ->" + FileContentRaw + "<-");
log.info("MD5 Result 1 Apache->" + org.apache.commons.codec.digest.DigestUtils.md5(FileContentRaw).toString() + "<-");
log.info("MD5 Result 2 Apache->" + org.apache.commons.codec.digest.DigestUtils.md5(FileContentRaw).toString() + "<-");
log.info("MD5 Result 3 Apache->" + org.apache.commons.codec.digest.DigestUtils.md5(FileContentRaw).toString() + "<-");
log.info("MD5 Result 4 Apache->" + org.apache.commons.codec.digest.DigestUtils.md5(FileContentRaw).toString() + "<-");其结果是:
2016/11/21 11:22:29 INFO - jmeter.util.BeanShellTestElement: String to MD5 ->{"type":"StatsReq","msg":[{"symList":["AAPL.O","MFFT.O"],"startDate":"2015-01-03","endDate":"2015-01-03","dataType":"trade","assetClass":"tmx","analytics":["VWAP","TWAP"],"startTime":null,"endTime":null,"granularity":null,"granularityUnit":null,"fill":null,"timeZone":null,"inputTimeZone":null,"outputTimeZone":null,"temporality":null}],"id":"gevv4nfhbul0rrhlcco2as63to","date":"Mon, 21 Nov 2016 11:22:29 EST"}<-
2016/11/21 11:22:29 INFO - jmeter.util.BeanShellTestElement: MD5 Result 1 Apache->[B@49f63d7c<-
2016/11/21 11:22:29 INFO - jmeter.util.BeanShellTestElement: MD5 Result 2 Apache->[B@182c34a7<-
2016/11/21 11:22:29 INFO - jmeter.util.BeanShellTestElement: MD5 Result 3 Apache->[B@56b1896b<-
2016/11/21 11:22:29 INFO - jmeter.util.BeanShellTestElement: MD5 Result 4 Apache->[B@355dc639<- 发布于 2016-11-21 20:21:50
你的问题是:
返回一个byte[]
因此,您正在对一个数组执行toString(),该数组返回该数组的引用,因此即使数组的内容相同,每次也会得到对象引用的不同值。
您应该显示org.apache.commons.codec.digest.DigestUtils.md5Hex(),它将为您提供相同的值,并且是一个字符串。
https://stackoverflow.com/questions/40725114
复制相似问题