jetty.project
jetty.project copied to clipboard
Review RolloverFileOutputStream locking
Spawned by #5083.
Jetty version 9.4.x
Description
RolloverFileOutputStream locking should be improved/removed.
Currently it locks on a class lock for no reasons, since __rollover is only ever written in the constructor (and thus could be final).
There should be some synchronization between the writes and the scheduled task (so that the file can be swapped without losing log lines), but the class locks seem unnecessary.
The __rollover field is static, so the lock is ensuring that only a single static timer is created for all RoFOSs. Perhaps Timer is no longer the best class and maybe we should somehow allow the servers scheduler to be accessed, but we don't want to create a Timer thread for every instance.
The __rollover field should be initialized in a static field, not in the constructor.
If we can also get rid of Timer that will be great, we can use Executors.newSingleThreadScheduledExecutor() instead.
Yes we need to keep the locking between writes and the task to avoid losing log lines.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.