public class AppenderAttachableImplLockTest
extends Object
This test shows the general problem I described in LBCORE-67.
In the two test cases below, an appender that throws an OutOfMemoryError
while getName is called - but this is just an example to show the general
problem.
The tests below fail without fixing LBCORE-67 and pass when Joern Huxhorn's
patch is applied.
Additionally, the following, probably more realistic, situations could
happen:
-addAppender: appenderList.add() could throw OutOfMemoryError. This could
only be shown by using an appenderList mock but appenderList does not (and
should not) have a setter. This would leave the write lock locked.
-iteratorForAppenders: new ArrayList() could throw an OutOfMemoryError,
leaving the read lock locked.
I can't imagine a bad situation in isAttached, detachAppender(Appender) or
detachAppender(String) but I'd change the code anyway for consistency. I'm
also pretty sure that something stupid can happen at any time so it's best to
just stick to conventions.
- Author:
- Joern Huxhorn