Skip to content

Commit b6fb6e3

Browse files
committed
changes after feedback from Tibor Digana
Signed-off-by: Ceki Gulcu <[email protected]>
1 parent 816da3d commit b6fb6e3

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java

+3-9
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ public class SimpleLogger extends MarkerIgnoringBase {
159159
protected static final int LOG_LEVEL_OFF = LOG_LEVEL_ERROR + 10;
160160

161161
private static boolean INITIALIZED = false;
162-
static SimpleLoggerConfiguration CONFIG_PARAMS = null;
163-
164-
private static final long MAX_TRY_LOCK_DURATION = 200L;
165-
static ReentrantLock lock = new ReentrantLock();
162+
static private SimpleLoggerConfiguration CONFIG_PARAMS = null;
166163

167164
static void lazyInit() {
168165
if (INITIALIZED) {
@@ -320,15 +317,12 @@ protected String renderLevel(int level) {
320317
void write(StringBuilder buf, Throwable t) {
321318
PrintStream targetStream = CONFIG_PARAMS.outputChoice.getTargetPrintStream();
322319

323-
try {
324-
lock.tryLock(MAX_TRY_LOCK_DURATION, TimeUnit.MILLISECONDS);
320+
synchronized (CONFIG_PARAMS) {
325321
targetStream.println(buf.toString());
326322
writeThrowable(t, targetStream);
327323
targetStream.flush();
328-
} catch (InterruptedException e) {
329-
} finally {
330-
lock.unlock();
331324
}
325+
332326
}
333327

334328
protected void writeThrowable(Throwable t, PrintStream targetStream) {

slf4j-simple/src/test/java/org/slf4j/simple/multiThreadedExecution/MultithereadedExecutionTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class WithException implements Runnable {
9090
Logger logger = LoggerFactory.getLogger(WithException.class);
9191

9292
@Override
93-
public void run() { // TODO Auto-generated method stub
93+
public void run() {
9494
int i = 0;
9595

9696
while (!signal) {
@@ -106,7 +106,7 @@ public void run() { // TODO Auto-generated method stub
106106

107107
}
108108
}
109-
109+
110110
class Other implements Runnable {
111111
Throwable throwable;
112112
Logger logger = LoggerFactory.getLogger(Other.class);

slf4j-simple/src/test/java/org/slf4j/simple/multiThreadedExecution/StateCheckingPrintStream.java

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ enum State {
3636
INITIAL, UNKNOWN, HELLO, THROWABLE, AT1, AT2, OTHER;
3737
}
3838

39-
PrintStream other;
40-
4139
List<String> stringList = Collections.synchronizedList(new ArrayList<String>());
4240

4341
State currentState = State.INITIAL;

0 commit comments

Comments
 (0)