Fixed runnable to allow acces to pending messages
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
@@ -145,6 +145,9 @@ public final class ReadingRunnable implements Runnable {
|
||||
* @throws IOException if the pipe is closed */
|
||||
public String getMessage() throws IOException {
|
||||
synchronized (lock) {
|
||||
if (!messages.isEmpty()) {
|
||||
return messages.poll();
|
||||
}
|
||||
if (!running) {
|
||||
throw new IOException(CLOSED_PIPE);
|
||||
}
|
||||
@@ -164,6 +167,9 @@ public final class ReadingRunnable implements Runnable {
|
||||
* @throws IOException if the input was closed */
|
||||
public String getNextMessage(final long timeout) throws IOException {
|
||||
synchronized (lock) {
|
||||
if (!messages.isEmpty()) {
|
||||
return messages.poll();
|
||||
}
|
||||
if (!running) {
|
||||
throw new IOException(CLOSED_PIPE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user