Drifter-yh opened a new issue, #11500:
URL: https://github.com/apache/rocketmq/issues/11500

   ### Runtime platform environment
   Windows 11, local filesystem. No broker deployment was used.
   
   ### RocketMQ version
   `develop` at `592d59d12db356f8c98332d9e355a89d92590db3`.
   
   ### JDK Version
   Microsoft OpenJDK 17.0.14.
   
   ### Describe the Bug
   `IOTinyUtils.copyFile` opens the destination with `FileOutputStream` before 
opening the source. If both paths refer to the same existing file, the 
destination open truncates the source and the method returns successfully with 
an empty file. Different paths can also refer to the same file through a hard 
link.
   
   This is a public utility defect. A repository search found no production 
call sites, so no broker data-loss scenario is claimed.
   
   ### Steps to Reproduce
   1. Write `important data` to a temporary file.
   2. Call `IOTinyUtils.copyFile(path, path)` using its absolute path.
   3. Read the file: it is empty and no exception was reported.
   
   ### What Did You Expect to See?
   Reject the operation before opening the destination and preserve the source 
bytes, including when the destination is a hard link to the source.
   
   ### What Did You See Instead?
   The 14-byte source becomes zero bytes and the call returns normally.
   
   ### Additional Context
   A focused JUnit test reproduces the loss on the stated revision. A local 
patch checks `Files.isSameFile` before opening the destination; focused tests 
for the identical path, a hard link, and a distinct target pass. This is 
distinct from #11461 (bare target path) and #10208 (resource closure); both 
concern the same method.
   
   AI assistance: OpenAI Codex was used for analysis, implementation, and tests.
   


-- 
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]

Reply via email to