summaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-10-17 23:05:11 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2018-10-17 23:05:11 +0200
commitff3929298b5d25511cec88ee987e9f81eb8d7f02 (patch)
tree878c25e3aaafc69a59c6eb05ff68c18e217feffb /vespa-http-client
parente25493a26039af0d4a42743fc16f0fc1902fb65e (diff)
If posting to self, the Q will be unbounded
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java2
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java10
2 files changed, 11 insertions, 1 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
index dc753deb9f9..328260e6761 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
@@ -165,7 +165,7 @@ class IOThread implements Runnable, AutoCloseable {
public void post(final Document document) throws InterruptedException {
- documentQueue.put(document, false);
+ documentQueue.put(document, Thread.currentThread() == thread);
}
@Override
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java
index 4148e652d55..82538179ef9 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/CloseableQTestCase.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.http.client.core.communication;
import com.yahoo.vespa.http.client.core.Document;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class CloseableQTestCase {
@@ -35,4 +36,13 @@ public class CloseableQTestCase {
} catch (InterruptedException e) {
}
}
+
+ @Test
+ public void requireThatSelfIsUnbounded() throws InterruptedException {
+ DocumentQueue q = new DocumentQueue(1);
+ q.put(new Document("1", "data", null /* context */), true);
+ q.put(new Document("2", "data", null /* context */), true);
+ q.put(new Document("3", "data", null /* context */), true);
+ assertEquals(3, q.size());
+ }
}