Skip to content

Commit

Permalink
Aesh console printstream redirect may cause a deadlock with virtual t…
Browse files Browse the repository at this point in the history
…hreads.

Replacing the queue implementation with a lock-free variant resolves the issue
  • Loading branch information
ozangunalp committed Jul 17, 2023
1 parent 83c0937 commit 1c770a8
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
Expand Down Expand Up @@ -56,7 +56,7 @@ public class AeshConsole extends QuarkusConsole {
* Because Aesh can log deadlocks are possible on Windows if a write fails, unless care
* is taken.
*/
private final LinkedBlockingDeque<String> writeQueue = new LinkedBlockingDeque<>();
private final ConcurrentLinkedQueue<String> writeQueue = new ConcurrentLinkedQueue<>();
private final Lock connectionLock = new ReentrantLock();
private static final ThreadLocal<Boolean> IN_WRITE = new ThreadLocal<>() {
@Override
Expand Down

0 comments on commit 1c770a8

Please sign in to comment.