| 1 | package com.renomad.minum.logging; | |
| 2 | ||
| 3 | ||
| 4 | import java.io.Serial; | |
| 5 | import java.util.ArrayDeque; | |
| 6 | import java.util.concurrent.locks.ReentrantLock; | |
| 7 | ||
| 8 | /** | |
| 9 | * Used in {@link TestLogger} as a circular queue to store | |
| 10 | * the most recent log statements for analysis. | |
| 11 | */ | |
| 12 | public final class TestLoggerQueue extends ArrayDeque<String> { | |
| 13 | ||
| 14 | @Serial | |
| 15 | private static final long serialVersionUID = -149106325553645154L; | |
| 16 | ||
| 17 | private final ReentrantLock queueLock; | |
| 18 | private final int capacity; | |
| 19 | ||
| 20 | public TestLoggerQueue(int capacity){ | |
| 21 | this.capacity = capacity; | |
| 22 | this.queueLock = new ReentrantLock(); | |
| 23 | } | |
| 24 | ||
| 25 | @Override | |
| 26 | public boolean add(String e) { | |
| 27 |
1
1. add : removed call to java/util/concurrent/locks/ReentrantLock::lock → KILLED |
queueLock.lock(); |
| 28 | try { | |
| 29 | if (size() >= capacity) | |
| 30 | removeFirst(); | |
| 31 |
2
1. add : replaced boolean return with true for com/renomad/minum/logging/TestLoggerQueue::add → TIMED_OUT 2. add : replaced boolean return with false for com/renomad/minum/logging/TestLoggerQueue::add → KILLED |
return super.add(e); |
| 32 | } finally { | |
| 33 |
1
1. add : removed call to java/util/concurrent/locks/ReentrantLock::unlock → TIMED_OUT |
queueLock.unlock(); |
| 34 | } | |
| 35 | } | |
| 36 | } | |
Mutations | ||
| 27 |
1.1 |
|
| 31 |
1.1 2.2 |
|
| 33 |
1.1 |