diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-05-11 21:40:10 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-05-11 21:40:10 +0000 |
commit | b04f090f8c55eb2906e890ca8260d77e27e6ccb3 (patch) | |
tree | a0d826c90f50765a1a9c5763cce74cf201152fe8 /vespaclient-container-plugin | |
parent | dfbe98d77704e4c598c28b90e739634dd33d2127 (diff) |
Add first 200 bytes of message to xml exception
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r-- | vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReaderFactory.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReaderFactory.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReaderFactory.java index 6a3229e86b7..419e61fa1c0 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReaderFactory.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReaderFactory.java @@ -3,10 +3,12 @@ package com.yahoo.vespa.http.server; import com.yahoo.document.DocumentTypeManager; import com.yahoo.document.json.JsonFeedReader; +import com.yahoo.text.Utf8; import com.yahoo.vespa.http.client.config.FeedParams; import com.yahoo.vespaxmlparser.FeedReader; import com.yahoo.vespaxmlparser.VespaXMLFeedReader; +import java.io.IOException; import java.io.InputStream; /** @@ -31,7 +33,14 @@ public class FeedReaderFactory { try { return new VespaXMLFeedReader(inputStream, docTypeManager); } catch (Exception e) { - throw new RuntimeException("Could not create VespaXMLFeedReader", e); + byte [] peek; + try { + peek = new byte[Math.min(200, inputStream.available())]; + inputStream.read(peek); + } catch (IOException io) { + peek = new byte [0]; + } + throw new RuntimeException("Could not create VespaXMLFeedReader. First characters are: " + Utf8.toString(peek), e); } case JSON_UTF8: return new JsonFeedReader(inputStream, docTypeManager); |