You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2017/09/08 12:55:13 UTC

[1/2] olingo-odata4 git commit: [OLINGO-1152] Fix IllegalArgumentException when enum property is null.

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 4cae638ff -> 0a2ebd795


[OLINGO-1152] Fix IllegalArgumentException when enum property is null.

Signed-off-by: Christian Amend <ch...@sap.com>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/6b34920a
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/6b34920a
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/6b34920a

Branch: refs/heads/master
Commit: 6b34920a5b0e465875ceebddc8a85fec086b8160
Parents: 4cae638
Author: Tom van Wietmarschen <aa...@gmail.com>
Authored: Thu Jul 20 16:49:26 2017 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Sep 8 14:50:58 2017 +0200

----------------------------------------------------------------------
 .../olingo/client/core/serialization/JsonDeserializer.java       | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6b34920a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java
index ec896bb..b2cfd49 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonDeserializer.java
@@ -385,7 +385,9 @@ public class JsonDeserializer implements ODataDeserializer {
       break;
 
     case ENUM:
-      valuable.setValue(ValueType.ENUM, node.asText());
+      if(!node.isNull()) {
+    	  valuable.setValue(ValueType.ENUM, node.asText());
+      }
       break;
 
     case PRIMITIVE:


[2/2] olingo-odata4 git commit: [OLINGO-1152] Test case for null enum values

Posted by ch...@apache.org.
[OLINGO-1152] Test case for null enum values

Signed-off-by: Christian Amend <ch...@sap.com>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/0a2ebd79
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/0a2ebd79
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/0a2ebd79

Branch: refs/heads/master
Commit: 0a2ebd7953c95eded80c0d050a33c2c036cfa014
Parents: 6b34920
Author: Tom van Wietmarschen <aa...@gmail.com>
Authored: Tue Aug 22 15:08:20 2017 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Sep 8 14:51:40 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/olingo/client/core/JSONTest.java | 15 +++++++++++++++
 .../org/apache/olingo/client/core/olingo1152.json    |  6 ++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0a2ebd79/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
index caef339..646c562 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
@@ -36,6 +36,7 @@ import org.apache.olingo.client.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientCollectionValue;
 import org.apache.olingo.client.api.domain.ClientComplexValue;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
 import org.apache.olingo.client.core.serialization.JsonDeserializer;
 import org.apache.olingo.commons.api.Constants;
@@ -482,4 +483,18 @@ public class JSONTest extends AbstractTest {
       i++;
     }
   }
+  
+  @Test
+  public void issueOLINGO1152() throws Exception {
+    InputStream inputStream = getClass().getResourceAsStream(
+        "olingo1152" + "." + getSuffix(ContentType.APPLICATION_JSON));
+    ClientEntity entity = client.getReader().readEntity(inputStream, ContentType.APPLICATION_JSON);
+    assertNotNull(entity);
+    ClientProperty prop = entity.getProperty("Gender");
+    assertNotNull(prop);
+    ClientValue value = prop.getValue();
+    assertNotNull(value);
+    assertTrue(value.asEnum() == null);
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0a2ebd79/lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1152.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1152.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1152.json
new file mode 100644
index 0000000..7f288c1
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1152.json
@@ -0,0 +1,6 @@
+{
+  "@odata.type": "#Microsoft.OData.SampleService.Models.TripPin.Person",
+  "@odata.id": "http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/TripPinServiceRW/People('russellwhyte')",
+  "Gender@odata.type": "#Microsoft.OData.SampleService.Models.TripPin.PersonGender",
+  "Gender": null
+}
\ No newline at end of file