Return-Path: X-Original-To: apmail-olingo-commits-archive@minotaur.apache.org Delivered-To: apmail-olingo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5CEA818411 for ; Fri, 12 Feb 2016 06:58:05 +0000 (UTC) Received: (qmail 30848 invoked by uid 500); 12 Feb 2016 06:58:05 -0000 Delivered-To: apmail-olingo-commits-archive@olingo.apache.org Received: (qmail 30828 invoked by uid 500); 12 Feb 2016 06:58:05 -0000 Mailing-List: contact commits-help@olingo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@olingo.apache.org Delivered-To: mailing list commits@olingo.apache.org Received: (qmail 30819 invoked by uid 99); 12 Feb 2016 06:58:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Feb 2016 06:58:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0A6E1E0231; Fri, 12 Feb 2016 06:58:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mibo@apache.org To: commits@olingo.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: olingo-odata2 git commit: [OLINGO-875] Add null check for location Date: Fri, 12 Feb 2016 06:58:05 +0000 (UTC) Repository: olingo-odata2 Updated Branches: refs/heads/master 2f8e7c2c8 -> 55655f3d9 [OLINGO-875] Add null check for location Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/55655f3d Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/55655f3d Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/55655f3d Branch: refs/heads/master Commit: 55655f3d9378bff41d9c05f8766c1a9ecedd153e Parents: 2f8e7c2 Author: Michael Bolz Authored: Fri Feb 12 07:48:31 2016 +0100 Committer: Michael Bolz Committed: Fri Feb 12 07:48:31 2016 +0100 ---------------------------------------------------------------------- .../odata2/core/batch/BatchHandlerImpl.java | 6 ++-- .../apache/olingo/odata2/fit/ref/BatchTest.java | 9 +++++- .../resources/batchFailFirstCreateRequest.batch | 33 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/55655f3d/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java index 6b8f13d..75eb265 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHandlerImpl.java @@ -109,8 +109,10 @@ public class BatchHandlerImpl implements BatchHandler { private void fillContentIdMap(final ODataResponse response, final String contentId, final String baseUri) { String location = response.getHeader(HttpHeaders.LOCATION); - String relLocation = location.replace(baseUri + "/", ""); - contentIdMap.put("$" + contentId, relLocation); + if(location != null) { + String relLocation = location.replace(baseUri + "/", ""); + contentIdMap.put("$" + contentId, relLocation); + } } private ODataRequest modifyRequest(final ODataRequest request, final List odataSegments) http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/55655f3d/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/BatchTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/BatchTest.java b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/BatchTest.java index 11c3d44..dec3ff8 100644 --- a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/BatchTest.java +++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/BatchTest.java @@ -107,7 +107,14 @@ public class BatchTest extends AbstractRefTest { String responseBody = StringHelper.inputStreamToString(response.getEntity().getContent(), true); assertTrue(responseBody.contains("HTTP/1.1 404 Not Found")); } - + + @Test + public void testFailFirstRequest() throws Exception { + HttpResponse response = execute("/batchFailFirstCreateRequest.batch", "batch_cf90-46e5-1246"); + String responseBody = StringHelper.inputStreamToString(response.getEntity().getContent(), true); + assertTrue(responseBody.contains("HTTP/1.1 404 Not Found")); + } + @Test public void testGPPG() throws Exception { HttpResponse response = execute("/batchWithContentIdPart2.batch", "batch_cf90-46e5-1246"); http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/55655f3d/odata2-lib/odata-fit/src/test/resources/batchFailFirstCreateRequest.batch ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-fit/src/test/resources/batchFailFirstCreateRequest.batch b/odata2-lib/odata-fit/src/test/resources/batchFailFirstCreateRequest.batch new file mode 100644 index 0000000..67e0d6c --- /dev/null +++ b/odata2-lib/odata-fit/src/test/resources/batchFailFirstCreateRequest.batch @@ -0,0 +1,33 @@ +--batch_cf90-46e5-1246 +Content-Type: multipart/mixed; boundary=changeset_824f-ce08-1e9d + +--changeset_824f-ce08-1e9d +Content-Type: application/http +Content-Transfer-Encoding: binary +Content-ID: employee + +POST Employeess HTTP/1.1 +Content-ID: employee +Content-Type: application/octet-stream +Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1 +MaxDataServiceVersion: 2.0 + + +--changeset_824f-ce08-1e9d +Content-Type: application/http +Content-Transfer-Encoding: binary +Content-Id: AAA + +PUT Employee('2')/EmployeeName HTTP/1.1 +Content-Length: 100000 +Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1 +DataServiceVersion: 1.0 +Content-Id: AAA +Content-Type: application/json;odata=verbose +MaxDataServiceVersion: 2.0 + +{"EmployeeName":"Robert Fall"} + +--changeset_824f-ce08-1e9d-- + +--batch_cf90-46e5-1246-- \ No newline at end of file