jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Review RolloverFileOutputStream locking

Open sbordet opened this issue 5 years ago • 5 comments

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.

sbordet avatar Jul 29 '20 07:07 sbordet

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.

gregw avatar Aug 03 '20 11:08 gregw

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.

sbordet avatar Aug 03 '20 19:08 sbordet

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.

github-actions[bot] avatar Jan 25 '22 00:01 github-actions[bot]

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.

github-actions[bot] avatar Jan 26 '23 00:01 github-actions[bot]

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.

github-actions[bot] avatar Jan 27 '24 00:01 github-actions[bot]