HhH666-ux commented on PR #16543:
URL: https://github.com/apache/dubbo/pull/16543#issuecomment-6441699580

   Fixed the failing test — the expectation was stale, not the implementation.
   
   `md5.testfile.txt` is 12 bytes while `getMD5(File)` reads through an 8 KiB 
buffer. The old loop called `md.update(buf)` without a length, so the single 
iteration hashed the whole buffer: the file content followed by ~8180 zero 
bytes. That is why the old expectation looked like a normal digest — it was the 
digest of the zero-padded buffer:
   
   | input | MD5 |
   | --- | --- |
   | the 12 bytes of `md5.testfile.txt` | `/D/5joxqDTCH1RXARz+Gdw==` (what the 
new code returns) |
   | those 12 bytes padded to 8192 | `iNZ+5qHafVNPLJxHwLKJ3w==` (the old 
expectation) |
   
   `a38a5b4` updates the expectation and additionally asserts it against 
`getMD5(byte[])`, so the test states the intent (digest of the file content) 
instead of pinning whatever the buffer handling happened to produce.
   
   The other overloads are unaffected: `getMD5(String)` and `getMD5(byte[])` 
hash the array directly via `md.digest(source)`. Only `getMD5(File)` and 
`getMD5(InputStream)` went through the read loop, and 
`testMD5ForStreamWithShortFinalRead` / `testMD5ForStreamWithZeroAvailable` 
already cover the loop itself — this was the only test that had the buggy value 
baked in.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to