[logback-dev] svn commit: r2139 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Tue Feb 3 22:19:51 CET 2009
Author: ceki
Date: Tue Feb 3 22:19:51 2009
New Revision: 2139
Modified:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java
Log:
Use the recommended idion for j.u.c.locks Lock.
See also http://java.sun.com/javase/6/docs/api/java/util/concurrent/locks/Lock.html
This issue was discussed on the logback-dev list in Feb 2009 under the subject
"IllegalMonitorStateException inAppenderAttachableImpl.appendLoopOnAppenders()"
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java Tue Feb 3 22:19:51 2009
@@ -39,8 +39,8 @@
if (newAppender == null) {
throw new IllegalArgumentException("Null argument disallowed");
}
+ w.lock();
try {
- w.lock();
if (!appenderList.contains(newAppender)) {
appenderList.add(newAppender);
}
@@ -54,8 +54,8 @@
*/
public int appendLoopOnAppenders(E e) {
int size = 0;
+ r.lock();
try {
- r.lock();
for (Appender<E> appender : appenderList) {
appender.doAppend(e);
size++;
@@ -74,8 +74,8 @@
*/
public Iterator<Appender<E>> iteratorForAppenders() {
List<Appender<E>> copy;
+ r.lock();
try {
- r.lock();
copy = new ArrayList<Appender<E>>(appenderList);
} finally {
r.unlock();
@@ -96,8 +96,8 @@
}
Appender<E> found = null;
+ r.lock();
try {
- r.lock();
for (Appender<E> appender : appenderList) {
if (name.equals(appender.getName())) {
found = appender;
@@ -121,8 +121,8 @@
return false;
}
boolean attached = false;
+ r.lock();
try {
- r.lock();
for (Appender<E> a : appenderList) {
if (a == appender) {
attached = true;
@@ -139,8 +139,8 @@
* Remove and stop all previously attached appenders.
*/
public void detachAndStopAllAppenders() {
+ w.lock();
try {
- w.lock();
for (Appender<E> a : appenderList) {
a.stop();
}
@@ -159,8 +159,8 @@
return false;
}
boolean result;
+ w.lock();
try {
- w.lock();
result = appenderList.remove(appender);
} finally {
w.unlock();
@@ -177,8 +177,8 @@
return false;
}
boolean removed = false;
+ w.lock();
try {
- w.lock();
for (Appender<E> a : appenderList) {
if (name.equals((a).getName())) {
removed = appenderList.remove(a);
More information about the logback-dev
mailing list