You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2016/02/12 07:58:05 UTC
olingo-odata2 git commit: [OLINGO-875] Add null check for location
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 <mi...@sap.com>
Authored: Fri Feb 12 07:48:31 2016 +0100
Committer: Michael Bolz <mi...@sap.com>
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<PathSegment> 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