You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/06/15 11:16:12 UTC

[1/4] camel git commit: CAMEL-11413: camel-olingo - Potential NPE in getting content-type header

Repository: camel
Updated Branches:
  refs/heads/camel-2.19.x 07d0455f5 -> b0bf09a29
  refs/heads/master fef52d7ea -> cbeb84965


CAMEL-11413: camel-olingo - Potential NPE in getting content-type header


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e9516229
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e9516229
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e9516229

Branch: refs/heads/master
Commit: e9516229c559258fcc0d06382bb328573d6426a8
Parents: fef52d7
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jun 15 11:44:48 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jun 15 11:44:48 2017 +0200

----------------------------------------------------------------------
 .../api/impl/AbstractFutureCallback.java        |  5 ++-
 .../olingo4/api/impl/Olingo4AppImpl.java        |  4 +-
 .../olingo4/api/impl/Olingo4Helper.java         | 42 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e9516229/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
index 1a206fa..b710f04 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
@@ -37,6 +37,8 @@ import org.apache.olingo.commons.api.ex.ODataException;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 
+import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
 * Helper implementation of {@link org.apache.http.concurrent.FutureCallback}
  * for {@link org.apache.camel.component.olingo4.api.impl.Olingo4AppImpl}
@@ -58,8 +60,7 @@ public abstract class AbstractFutureCallback<T> implements FutureCallback<HttpRe
         if (HttpStatusCode.BAD_REQUEST.getStatusCode() <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= NETWORK_CONNECT_TIMEOUT_ERROR) {
             if (response.getEntity() != null) {
                 try {
-                    final ContentType responseContentType = ContentType.parse(
-                        response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                    final ContentType responseContentType = getContentTypeHeader(response);
                               
                     if (ODATA_MIME_TYPE_PATTERN.matcher(responseContentType.toContentTypeString()).matches()) {
                         final ODataReader reader = ODataClientFactory.getClient().getReader();

http://git-wip-us.apache.org/repos/asf/camel/blob/e9516229/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
index 7dffd1c..bea94b5 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
@@ -108,6 +108,8 @@ import org.apache.olingo.server.core.uri.parser.Parser;
 import org.apache.olingo.server.core.uri.parser.UriParserException;
 import org.apache.olingo.server.core.uri.validator.UriValidationException;
 
+import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
  * Application API used by Olingo4 Component.
  */
@@ -640,7 +642,7 @@ public final class Olingo4AppImpl implements Olingo4App {
                     final UriInfo uriInfo = parseUri(edm, batchPartQueryRequest.getResourcePath(), null);
 
                     if (HttpStatusCode.BAD_REQUEST.getStatusCode() <= batchPartLineStatusCode && batchPartLineStatusCode <= AbstractFutureCallback.NETWORK_CONNECT_TIMEOUT_ERROR) {
-                        final ContentType responseContentType = ContentType.parse(batchPartHttpResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                        final ContentType responseContentType = getContentTypeHeader(batchPartHttpResponse);
                         content = odataReader.readError(batchPartHttpResponse.getEntity().getContent(), responseContentType);
                     } else if (batchPartLineStatusCode == HttpStatusCode.NO_CONTENT.getStatusCode()) {
                         // nothing to do if NO_CONTENT returning

http://git-wip-us.apache.org/repos/asf/camel/blob/e9516229/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java
new file mode 100644
index 0000000..d68aab0
--- /dev/null
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.olingo4.api.impl;
+
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.olingo.commons.api.format.ContentType;
+
+/**
+ * Helper
+ */
+public final class Olingo4Helper {
+
+    private Olingo4Helper() {
+    }
+
+    /**
+     * Gets the content type header in a safe way
+     */
+    public static ContentType getContentTypeHeader(HttpResponse response) {
+        if (response.containsHeader(HttpHeaders.CONTENT_TYPE)) {
+            return ContentType.parse(response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+        } else {
+            return null;
+        }
+    }
+
+}


[4/4] camel git commit: CAMEL-11413: camel-olingo - Potential NPE in getting content-type header

Posted by da...@apache.org.
CAMEL-11413: camel-olingo - Potential NPE in getting content-type header


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b0bf09a2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b0bf09a2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b0bf09a2

Branch: refs/heads/camel-2.19.x
Commit: b0bf09a2952d280785bf7690294e55edd7f8123c
Parents: a64cc31
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jun 15 13:14:06 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jun 15 13:16:02 2017 +0200

----------------------------------------------------------------------
 .../api/impl/AbstractFutureCallback.java        |  5 ++-
 .../olingo2/api/impl/Olingo2AppImpl.java        |  6 ++-
 .../olingo2/api/impl/Olingo4Helper.java         | 42 ++++++++++++++++++++
 3 files changed, 49 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b0bf09a2/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
index 1ad332e..04e22b1 100644
--- a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
@@ -33,6 +33,8 @@ import org.apache.olingo.odata2.api.exception.ODataApplicationException;
 import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.api.processor.ODataErrorContext;
 
+import static org.apache.camel.component.olingo2.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
 * Helper implementation of {@link org.apache.http.concurrent.FutureCallback}
  * for {@link org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl}
@@ -52,8 +54,7 @@ public abstract class AbstractFutureCallback<T> implements FutureCallback<HttpRe
         if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) {
             if (response.getEntity() != null) {
                 try {
-                    final ContentType responseContentType = ContentType.parse(
-                        response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                    final ContentType responseContentType = getContentTypeHeader(response);
 
                     final String mimeType = responseContentType.getMimeType();
                     if (ODATA_MIME_TYPE.matcher(mimeType).matches()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/b0bf09a2/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
index e641162..7b3e0ed 100644
--- a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
@@ -91,6 +91,8 @@ import org.apache.olingo.odata2.api.processor.ODataResponse;
 import org.apache.olingo.odata2.api.uri.PathSegment;
 import org.apache.olingo.odata2.api.uri.UriParser;
 
+import static org.apache.camel.component.olingo2.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
  * Application API used by Olingo2 Component.
  */
@@ -486,9 +488,9 @@ public final class Olingo2AppImpl implements Olingo2App {
                         switch (uriInfo.getUriType()) {
                         case URI9:
                             // $batch
+                            String type = result.containsHeader(HttpHeaders.CONTENT_TYPE) ? result.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue() : null;
                             final List<BatchSingleResponse> singleResponses = EntityProvider.parseBatchResponse(
-                                result.getEntity().getContent(),
-                                result.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                                result.getEntity().getContent(), type);
 
                             // parse batch response bodies
                             final List<Olingo2BatchResponse> responses = new ArrayList<Olingo2BatchResponse>();

http://git-wip-us.apache.org/repos/asf/camel/blob/b0bf09a2/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java
new file mode 100644
index 0000000..749ea6b
--- /dev/null
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.olingo2.api.impl;
+
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentType;
+
+/**
+ * Helper
+ */
+public final class Olingo4Helper {
+
+    private Olingo4Helper() {
+    }
+
+    /**
+     * Gets the content type header in a safe way
+     */
+    public static ContentType getContentTypeHeader(HttpResponse response) {
+        if (response.containsHeader(HttpHeaders.CONTENT_TYPE)) {
+            return ContentType.parse(response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+        } else {
+            return null;
+        }
+    }
+
+}


[2/4] camel git commit: CAMEL-11413: camel-olingo - Potential NPE in getting content-type header

Posted by da...@apache.org.
CAMEL-11413: camel-olingo - Potential NPE in getting content-type header


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cbeb8496
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cbeb8496
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cbeb8496

Branch: refs/heads/master
Commit: cbeb8496512fec459b85e1d7a6d144b2c5a22971
Parents: e951622
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jun 15 13:14:06 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jun 15 13:14:06 2017 +0200

----------------------------------------------------------------------
 .../api/impl/AbstractFutureCallback.java        |  5 ++-
 .../olingo2/api/impl/Olingo2AppImpl.java        |  6 ++-
 .../olingo2/api/impl/Olingo4Helper.java         | 42 ++++++++++++++++++++
 3 files changed, 49 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cbeb8496/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
index 1ad332e..04e22b1 100644
--- a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/AbstractFutureCallback.java
@@ -33,6 +33,8 @@ import org.apache.olingo.odata2.api.exception.ODataApplicationException;
 import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.api.processor.ODataErrorContext;
 
+import static org.apache.camel.component.olingo2.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
 * Helper implementation of {@link org.apache.http.concurrent.FutureCallback}
  * for {@link org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl}
@@ -52,8 +54,7 @@ public abstract class AbstractFutureCallback<T> implements FutureCallback<HttpRe
         if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) {
             if (response.getEntity() != null) {
                 try {
-                    final ContentType responseContentType = ContentType.parse(
-                        response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                    final ContentType responseContentType = getContentTypeHeader(response);
 
                     final String mimeType = responseContentType.getMimeType();
                     if (ODATA_MIME_TYPE.matcher(mimeType).matches()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/cbeb8496/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
index e641162..7b3e0ed 100644
--- a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
@@ -91,6 +91,8 @@ import org.apache.olingo.odata2.api.processor.ODataResponse;
 import org.apache.olingo.odata2.api.uri.PathSegment;
 import org.apache.olingo.odata2.api.uri.UriParser;
 
+import static org.apache.camel.component.olingo2.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
  * Application API used by Olingo2 Component.
  */
@@ -486,9 +488,9 @@ public final class Olingo2AppImpl implements Olingo2App {
                         switch (uriInfo.getUriType()) {
                         case URI9:
                             // $batch
+                            String type = result.containsHeader(HttpHeaders.CONTENT_TYPE) ? result.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue() : null;
                             final List<BatchSingleResponse> singleResponses = EntityProvider.parseBatchResponse(
-                                result.getEntity().getContent(),
-                                result.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                                result.getEntity().getContent(), type);
 
                             // parse batch response bodies
                             final List<Olingo2BatchResponse> responses = new ArrayList<Olingo2BatchResponse>();

http://git-wip-us.apache.org/repos/asf/camel/blob/cbeb8496/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java
new file mode 100644
index 0000000..749ea6b
--- /dev/null
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo4Helper.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.olingo2.api.impl;
+
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentType;
+
+/**
+ * Helper
+ */
+public final class Olingo4Helper {
+
+    private Olingo4Helper() {
+    }
+
+    /**
+     * Gets the content type header in a safe way
+     */
+    public static ContentType getContentTypeHeader(HttpResponse response) {
+        if (response.containsHeader(HttpHeaders.CONTENT_TYPE)) {
+            return ContentType.parse(response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+        } else {
+            return null;
+        }
+    }
+
+}


[3/4] camel git commit: CAMEL-11413: camel-olingo - Potential NPE in getting content-type header

Posted by da...@apache.org.
CAMEL-11413: camel-olingo - Potential NPE in getting content-type header


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a64cc311
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a64cc311
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a64cc311

Branch: refs/heads/camel-2.19.x
Commit: a64cc311ae4797719dea69ca06b5261197b0185b
Parents: 07d0455
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jun 15 11:44:48 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jun 15 13:15:56 2017 +0200

----------------------------------------------------------------------
 .../api/impl/AbstractFutureCallback.java        |  5 ++-
 .../olingo4/api/impl/Olingo4AppImpl.java        |  4 +-
 .../olingo4/api/impl/Olingo4Helper.java         | 42 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a64cc311/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
index 1a206fa..b710f04 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/AbstractFutureCallback.java
@@ -37,6 +37,8 @@ import org.apache.olingo.commons.api.ex.ODataException;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 
+import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
 * Helper implementation of {@link org.apache.http.concurrent.FutureCallback}
  * for {@link org.apache.camel.component.olingo4.api.impl.Olingo4AppImpl}
@@ -58,8 +60,7 @@ public abstract class AbstractFutureCallback<T> implements FutureCallback<HttpRe
         if (HttpStatusCode.BAD_REQUEST.getStatusCode() <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= NETWORK_CONNECT_TIMEOUT_ERROR) {
             if (response.getEntity() != null) {
                 try {
-                    final ContentType responseContentType = ContentType.parse(
-                        response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                    final ContentType responseContentType = getContentTypeHeader(response);
                               
                     if (ODATA_MIME_TYPE_PATTERN.matcher(responseContentType.toContentTypeString()).matches()) {
                         final ODataReader reader = ODataClientFactory.getClient().getReader();

http://git-wip-us.apache.org/repos/asf/camel/blob/a64cc311/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
index 7dffd1c..bea94b5 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
@@ -108,6 +108,8 @@ import org.apache.olingo.server.core.uri.parser.Parser;
 import org.apache.olingo.server.core.uri.parser.UriParserException;
 import org.apache.olingo.server.core.uri.validator.UriValidationException;
 
+import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
+
 /**
  * Application API used by Olingo4 Component.
  */
@@ -640,7 +642,7 @@ public final class Olingo4AppImpl implements Olingo4App {
                     final UriInfo uriInfo = parseUri(edm, batchPartQueryRequest.getResourcePath(), null);
 
                     if (HttpStatusCode.BAD_REQUEST.getStatusCode() <= batchPartLineStatusCode && batchPartLineStatusCode <= AbstractFutureCallback.NETWORK_CONNECT_TIMEOUT_ERROR) {
-                        final ContentType responseContentType = ContentType.parse(batchPartHttpResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+                        final ContentType responseContentType = getContentTypeHeader(batchPartHttpResponse);
                         content = odataReader.readError(batchPartHttpResponse.getEntity().getContent(), responseContentType);
                     } else if (batchPartLineStatusCode == HttpStatusCode.NO_CONTENT.getStatusCode()) {
                         // nothing to do if NO_CONTENT returning

http://git-wip-us.apache.org/repos/asf/camel/blob/a64cc311/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java
new file mode 100644
index 0000000..d68aab0
--- /dev/null
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4Helper.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.olingo4.api.impl;
+
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.olingo.commons.api.format.ContentType;
+
+/**
+ * Helper
+ */
+public final class Olingo4Helper {
+
+    private Olingo4Helper() {
+    }
+
+    /**
+     * Gets the content type header in a safe way
+     */
+    public static ContentType getContentTypeHeader(HttpResponse response) {
+        if (response.containsHeader(HttpHeaders.CONTENT_TYPE)) {
+            return ContentType.parse(response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
+        } else {
+            return null;
+        }
+    }
+
+}