aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-10-14 17:47:08 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-10-14 17:47:08 +0200
commitf0c452cc8a83d0396375caf5486699a392b88acf (patch)
treedae72e4787929decceba1acfcb3fa1b042ebad35
parentad379f928f476f92a235019e149074c400362105 (diff)
Add logging on unexpected behaviour
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/handler/BufferedContentChannel.java4
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java9
2 files changed, 10 insertions, 3 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/BufferedContentChannel.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/BufferedContentChannel.java
index fdfb2cb3abb..6df281ce5bc 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/BufferedContentChannel.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/BufferedContentChannel.java
@@ -102,7 +102,7 @@ public final class BufferedContentChannel implements ContentChannel {
}
try {
while (this.content == null) {
- lock.wait(); // waiting for connecTo()
+ lock.wait(); // waiting for connectTo()
}
} catch (InterruptedException e) {
throw new IllegalStateException(e);
@@ -129,7 +129,7 @@ public final class BufferedContentChannel implements ContentChannel {
}
try {
while (this.content == null) {
- lock.wait(); // waiting for connecTo()
+ lock.wait(); // waiting for connectTo()
}
} catch (InterruptedException e) {
throw new IllegalStateException(e);
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
index ff36c108572..147dd9e77cd 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
@@ -80,6 +80,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
@@ -640,6 +641,7 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
private final ReadableContentChannel delegate = new ReadableContentChannel();
private final Consumer<InputStream> reader;
+ private final AtomicBoolean written = new AtomicBoolean();
public ForwardingContentChannel(Consumer<InputStream> reader) {
this.reader = reader;
@@ -650,17 +652,21 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
public void write(ByteBuffer buf, CompletionHandler handler) {
try {
delegate.write(buf, logException);
+ written.set(true);
handler.completed();
}
catch (Exception e) {
+ log.log(WARNING, "Failed writing request data", e);
handler.failed(e);
}
}
- /** Close is complete when we have close the buffer. */
+ /** Close is complete when we have closed the buffer. */
@Override
public void close(CompletionHandler handler) {
try {
+ if ( ! written.get())
+ log.log(WARNING, "Closed without any content. Really!? Usage error (no content needed) or bug.");
delegate.close(logException);
try (UnsafeContentInputStream in = new UnsafeContentInputStream(delegate)) {
reader.accept(in);
@@ -668,6 +674,7 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
handler.completed();
}
catch (Exception e) {
+ log.log(WARNING, "Failed closing request data", e);
handler.failed(e);
}
}