Details
-
Task
-
Resolution: Unresolved
-
Major
-
None
-
1.2.3
-
None
-
Description
The code in AsyncAppenderBase#putUninterruptibly is suspicious, if InterruptedException is raised in blockingQueue.put(...), the interrupted flag is set to true but as there is a while(true) around the current Thread will not be interrupted, loop forever and the code in the finally block may never occur.
private void putUninterruptibly(E eventObject) { boolean interrupted = false; try { while (true) { try { blockingQueue.put(eventObject); break; } catch (InterruptedException e) { interrupted = true; } } } finally { if (interrupted) { Thread.currentThread().interrupt(); } } }
What's the purpose of this infinite loop?
I suspect the intent was to write while(!interrupted&&!pushed) instead of while(true).
To me, the blockingQueue.put is a blocking operation, the current thread will wait until it can push the event in the queue. Attempting multiple retries seems useless and dangerous to me. At least the number of retries should be bounded.
Attachments
Issue Links
- relates to (out)
-
LOGBACK-910 AsyncAppenderBase swallows InterruptedException
- Resolved
-
LOGBACK-1247 AsyncAppender drops events when the current thread is interrupted
- Closed