garydgregory commented on PR #941:
URL: https://github.com/apache/commons-io/pull/941#issuecomment-7070331015

   @atharv1205 
   
   The PR reproduces the reported failure. However, I don’t think this 
implementation is ready to merge.
   
   The main problem is that different read results do not establish that the 
file was replaced. An existing reader can return EOF while a newly opened 
reader sees an append to the same file. The PR treats this as rotation, drains 
the original reader, and resets the replacement reader to zero.
   
   A deterministic test reproduces the resulting duplicate delivery:
   - Expected: [first, after]
   - Actual: [first, after, first, after]
   A persistently stale original reader can also cause previously delivered 
lines to be replayed. Rechecking that reader does not reliably solve this: 
another visibility change can occur during the recheck.
   
   There are additional concerns:
   - The size-ahead test misses the problematic transition. Its content remains 
permanently empty, so it never exercises data becoming visible between 
operations.
   - The `FileNotFoundException` catch is too broad. It covers seeking, 
reading, and closing the probe, as well as opening it. Failures after a 
successful open can therefore be silently treated as an unavailable path.
   - Recovery opens the replacement twice. The probe reader is discarded, and 
another reader is opened for consumption. This adds I/O and another opportunity 
for the path to change between checking and reading.
   PR #942 instead refreshes a stalled reader at its existing offset. For 
IO-591, that offset is already zero, so this recovers all content written after 
the empty-file rotations. At nonzero offsets, it avoids replaying earlier lines 
merely because readers have different views of the data. A refresh does not 
generate a rotation notification; existing size/path-based rotation handling 
remains in place.
   
   It also retains the original reader when opening the fresh reader fails, 
uses the successfully opened reader directly, and limits the optional-open 
exception handling to the open itself.
   
   The expanded tests cover delayed visibility, persistently stale readers, 
nonzero offsets, repeated open failures, seek/read/close failures, shutdown, 
and resource cleanup, alongside real-file rotation tests. The rotation 
regressions fail against unmodified main, and the replay tests expose the 
unsafe implementations.
   
   


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