[LOGMGR-319] Rework locking for Loom compatibility #380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
synchronized
constructs that cover blocking code to use a shared (per-instance)ReentrantLock
ExtHandler
subclassesprotected
outputLock
object which was used for synchronization among subclasses ofWriterHandler
and replace with sharedlock
setCharset
with lock to retain behavior ofjava.util.logging.Handler
j.u.l.Handler
which are protected bysynchronized
in that classReentrantLock
This is technically a compatibility-impacting change (and thus should not be backported) since the
protected
outputLock
field has been removed fromWriterHandler
and not replaced. The new lock field is calledlock
and it is onExtHandler
itself. The new field must have a distinct name from the old field, otherwise existing third-party code which tries tosynchronize
on the lock field will lock on theReentrantLock
's monitor, not theReentrantLock
itself.Another behavioral change is that the handler tree previously had a few locks (three or four), with subclass hierarchies often maintaining their own lock. I don't expect this to be a problem (if anything I expect to avoid possible deadlock scenarios) but it is worth mentioning.
In one case a different lock was used to read and write a non-
volatile
field on a handler which was a source of possible obscure bugs; this has been fixed to use the commonlock
.Related to openjdk/jdk#13832. Depends on #378.