Fix available message test

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2018-10-27 14:02:31 -04:00
parent 171f79518d
commit 0ab39b24f6

View File

@ -177,7 +177,7 @@ public final class ReadingRunnable implements Runnable {
}
}
public void waitForDelivery(String message) throws InterruptedException {
public void waitForDelivery(final String message) throws InterruptedException {
Object mLock;
synchronized (messageBlockerLock) {
if (!messageBlocker.containsKey(message)) {
@ -196,10 +196,11 @@ public final class ReadingRunnable implements Runnable {
* @throws IOException if the pipe is closed */
public boolean hasMessage() throws IOException {
synchronized (lock) {
if (!running) {
final boolean empty = messages.isEmpty();
if (!running && empty) {
throw new IOException(CLOSED_PIPE);
}
return !messages.isEmpty();
return !empty;
}
}