Gérald Quintana created LOGBACK-1382:
----------------------------------------

             Summary: AsyncAppender#putUninterruptibly looks suspicious
                 Key: LOGBACK-1382
                 URL: https://jira.qos.ch/browse/LOGBACK-1382
             Project: logback
          Issue Type: Task
          Components: logback-core
    Affects Versions: 1.2.3
         Environment: 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 and the code in the finally block may 
never occur.

 
{code:java}
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();
        }
    }
}
{code}
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.

 

 
            Reporter: Gérald Quintana
            Assignee: Logback dev list






--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-dev

Reply via email to