Repository: camel Updated Branches: refs/heads/master 5586f91c4 -> 7ba190216
CAMEL-11057: Undertow Producer : NPE if tryConvertTo fails to convert exchange body to ByteBuffer Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3bc26bef Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3bc26bef Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3bc26bef Branch: refs/heads/master Commit: 3bc26bef77b8d91944ebc20d2e46d5c1b4587f34 Parents: 5586f91 Author: lburgazzoli <lburgazz...@gmail.com> Authored: Thu Mar 23 14:03:31 2017 +0100 Committer: lburgazzoli <lburgazz...@gmail.com> Committed: Thu Mar 23 14:03:31 2017 +0100 ---------------------------------------------------------------------- .../org/apache/camel/component/undertow/UndertowProducer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/3bc26bef/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java index 0bca663..a4133df 100644 --- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java +++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowProducer.java @@ -128,7 +128,9 @@ public class UndertowProducer extends DefaultAsyncProducer { final TypeConverter tc = endpoint.getCamelContext().getTypeConverter(); final ByteBuffer bodyAsByte = tc.tryConvertTo(ByteBuffer.class, body); - if (body != null) { + // As tryConvertTo is used to convert the body, we should do null check + // or the call bodyAsByte.remaining() may throw an NPE + if (body != null && bodyAsByte != null) { requestHeaders.put(Headers.CONTENT_LENGTH, bodyAsByte.remaining()); }